新用户的授权和权限更新修改

This commit is contained in:
ylj20011123 2026-01-22 16:31:39 +08:00
parent e56b53fb0c
commit 6f8d811054
4 changed files with 223 additions and 226 deletions

23
App.vue
View File

@ -53,11 +53,24 @@ export default {
});
let _this = this;
if (this.user.WeChat_MiniProToken) {
this.memberLogin();
} else {
this.getLoginCode();
}
// Promise,
// : getApp(), onLaunch App
this.loginPromise = new Promise(async (resolve, reject) => {
if (this.user.WeChat_MiniProToken) {
await this.memberLogin()
resolve()
} else {
await this.getLoginCode()
resolve()
}
// (10)
setTimeout(() => {
console.warn('登录超时,继续加载页面');
resolve();
}, 10000);
});
this.setVisitChannels(options.scene);
const updateManager = uni.getUpdateManager();

View File

@ -1,47 +1,70 @@
<template>
<div class="main">
<image class="typeImg" src="https://eshangtech.com/ShopICO/ahyd-BID/commercial/noData.svg"></image>
<p class="text" v-if="type==='index'">抱歉,数据为第三方接口传输无法进行画像分析</p>
<p class="noAuthor" v-else-if="type==='noAuthor'">抱歉您没有权限查看数智化看板请联系管理员进行授权</p>
<p class="text" v-else>抱歉,第三方数据未传,无法分析</p>
<image class="typeImg" src="https://eshangtech.com/ShopICO/ahyd-BID/commercial/noData.svg"></image>
<p class="text" v-if="type === 'index'">抱歉,数据为第三方接口传输无法进行画像分析</p>
<p class="noAuthor" v-else-if="type === 'noAuthor'">抱歉您没有权限查看数智化看板请联系管理员进行授权</p>
<p class="text" v-else>抱歉,第三方数据未传,无法分析</p>
</div>
</template>
<script>
export default {
name: "noData",
data(){
return {
type:''
}
},
onLoad(query){
if (query.type){
this.type = query.type
}
let userInfo = uni.getStorageSync('vuex')
userInfo = JSON.parse(userInfo)
console.log('userInfo',userInfo)
console.log(userInfo.userData.AuthorityInfo['89a1f248-2113-4d57-84b1-c2e6edb9e8ee'])
if (userInfo.userData.AuthorityInfo['89a1f248-2113-4d57-84b1-c2e6edb9e8ee']===1){
setTimeout(()=>{
uni.switchTab({
url:`/pages/index/index`
})
},200)
}
},
onUnload() {
this.$util.addUserBehavior()
},
methods:{
name: "noData",
data() {
return {
type: ''
}
},
onLoad(query) {
let _this = this
// userInfo
console.log('noData', this.$store.state);
if (this.$store.state.userData.Membership_Id) {
} else {
uni.showModal({
title: '温馨提示',
content: '请您授权登录后再操作。',
success(res) {
if (res.confirm) {
// ,
_this.$util.toNextRoute('redirectTo', '/pages/register/register')
}
// ,,
}
})
}
if (query.type) {
this.type = query.type
}
let userInfo = uni.getStorageSync('vuex')
userInfo = JSON.parse(userInfo)
console.log('userInfo', userInfo)
console.log(userInfo.userData.AuthorityInfo['89a1f248-2113-4d57-84b1-c2e6edb9e8ee'])
if (userInfo.userData.AuthorityInfo['89a1f248-2113-4d57-84b1-c2e6edb9e8ee'] === 1) {
setTimeout(() => {
uni.switchTab({
url: `/pages/index/index`
})
}, 200)
}
},
onUnload() {
this.$util.addUserBehavior()
},
methods: {
}
}
</script>
<style scoped lang="scss">
.main{
.main {
width: 100%;
display: flex;
flex-direction: column;
@ -49,18 +72,21 @@ export default {
align-items: center;
margin-top: 12px;
padding: 16px 0;
.img{
width:60px;
.img {
width: 60px;
height: 60px;
margin-bottom: 8px;
}
.typeImg{
.typeImg {
width: 80px;
height: 80px;
margin-top: 40vh;
margin-bottom: 16px;
}
.text{
.text {
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;

View File

@ -3620,14 +3620,14 @@
}}</view>
<view class="itemLabel">已完成<text class="unit">/{{
plan.revenueType === "yi" ? "亿元" : "万元"
}}</text></view>
}}</text></view>
</view>
<view class="bottomItem">
<view class="itemValue">{{
plan.BudgetYear_Amount ? plan.BudgetYear_Amount : "-"
}}</view>
<view class="itemLabel">计划<text class="unit">/{{ plan.budgetType === "yi" ? "亿元" : "万元"
}}</text></view>
}}</text></view>
</view>
<view class="bottomItem">
<view class="itemValue">{{
@ -4277,12 +4277,7 @@ export default {
) {
this.getSuggestion();
}
console.log(
"userInfo.userData.AuthorityInfo['03bd2dbf-a5ed-4080-b168-92c3b7412d6f']",
userInfo.userData.AuthorityInfo[
"03bd2dbf-a5ed-4080-b168-92c3b7412d6f"
]
);
if (
userInfo.userData.AuthorityInfo[
"03bd2dbf-a5ed-4080-b168-92c3b7412d6f"
@ -4290,12 +4285,7 @@ export default {
) {
this.businessWarning = true;
}
console.log(
"userInfo.userData.AuthorityInfo['2d25dddc-e67f-4e26-b2d1-da78beed2c11']",
userInfo.userData.AuthorityInfo[
"2d25dddc-e67f-4e26-b2d1-da78beed2c11"
]
);
if (
userInfo.userData.AuthorityInfo[
"2d25dddc-e67f-4e26-b2d1-da78beed2c11"
@ -4304,46 +4294,7 @@ export default {
this.projectWarning = true;
}
//
this.seat = uni.getStorageSync("seatInfo");
if (!this.seat) {
//stroge
if (wx.getPrivacySetting) {
wx.getPrivacySetting({
success: (res) => {
if (res.needAuthorization) {
this.$util.toNextRoute(
"redirectTo",
"/pages/register/register"
);
} else {
wx.getFuzzyLocation({
type: "gcj02",
altitude: true,
success: (res) => {
let seatInfo = {
latitude: res.latitude,
longitude: res.longitude,
};
uni.setStorageSync("seatInfo", seatInfo);
this.seat = seatInfo;
},
});
}
},
});
} else {
uni.showModal({
title: "提示",
content:
"当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
});
return;
}
} else {
//
this.nearestService();
}
if (!this.isReturn) {
this.getData(this.option);
this.handleNoticeMonth();
@ -4382,9 +4333,25 @@ export default {
},
...mapGetters({ user: "getUser" }),
},
onLoad(option) {
console.log("festivalObj", this.festivalObj);
console.log("lastDay", this.lastDay);
async onLoad(option) {
// App.vue
const app = getApp();
// loginPromise ( onLaunch onLoad )
let waitCount = 0;
while (!app.loginPromise && waitCount < 100) {
await new Promise(resolve => setTimeout(resolve, 50)); // 50ms
waitCount++;
}
if (app.loginPromise) {
console.log('等待 App.onLaunch 登录完成...');
await app.loginPromise;
console.log('登录完成,继续执行 onLoad');
} else {
console.warn('loginPromise 未创建,直接继续执行');
}
//
uni.setStorageSync("festival", this.isShowFestival);
@ -4400,7 +4367,6 @@ export default {
if (!this.isShowFestival) {
this.isShowFestival = "other";
}
console.log("this.isShowFestival", this.isShowFestival);
uni.setStorageSync("festival", this.isShowFestival);
//
@ -4450,7 +4416,6 @@ export default {
}
}
this.swiperList = swiperList;
console.log("this.swiperList", this.swiperList);
//
this.selectDetail = this.handleGetSwiperIndex(this.lastDay);
//
@ -4459,7 +4424,6 @@ export default {
this.selectMonth = date.getMonth() + 1;
this.selectMonthIndex =
y > 2023 ? 12 + date.getMonth() + 1 : date.getMonth() + 1;
console.log("this.selectMonth", this.selectMonth);
//
this.startDate = `${date.getFullYear()}-01`;
@ -4470,23 +4434,29 @@ export default {
//
uni.setStorageSync("lastDay", this.lastDay);
uni.setStorageSync("version", this.selectVersion);
//
let userInfo = uni.getStorageSync("vuex");
userInfo = JSON.parse(userInfo);
this.useInfo = JSON.parse(JSON.stringify(userInfo));
console.log("userInfo3232312321312", userInfo);
// storage ()
let storageInfo = uni.getStorageSync("vuex");
// store.state , WeChat_GetBusinessMemberInfo
let userInfo = {
userData: this.$store.state.userData // store.state ,
};
this.useInfo = JSON.parse(JSON.stringify(userInfo));
console.log('userInfo (最新)', JSON.parse(JSON.stringify(userInfo)));
//
if (
userInfo.userData &&
userInfo.userData.UserId &&
userInfo.userData.AuthorityInfo &&
userInfo.userData.AuthorityInfo[
"89a1f248-2113-4d57-84b1-c2e6edb9e8ee"
] === 1
) {
this.isReturn = false;
} else {
return
this.$util.addUserBehavior({
intoRoute: `/pages/commercialBI/noData`,
});
@ -4495,20 +4465,21 @@ export default {
});
}
if (!this.isReturn) {
let userInfo = uni.getStorageSync("vuex");
userInfo = JSON.parse(userInfo);
// 使 userInfo
//
if (
userInfo.userData.AuthorityInfo[
"e2fb458b-d1bd-48fa-805e-fc93dc71efb7"
userInfo.userData.AuthorityInfo &&
(userInfo.userData.AuthorityInfo[
"e2fb458b-d1bd-48fa-805e-fc93dc71efb7"
] === 1 ||
userInfo.userData.AuthorityInfo[
"ea2fc404-d924-4c88-98de-1f4d96137745"
] === 1
userInfo.userData.AuthorityInfo[
"ea2fc404-d924-4c88-98de-1f4d96137745"
] === 1)
) {
this.getSuggestion();
}
if (
userInfo.userData.AuthorityInfo &&
userInfo.userData.AuthorityInfo[
"03bd2dbf-a5ed-4080-b168-92c3b7412d6f"
] === 1
@ -4516,6 +4487,7 @@ export default {
this.businessWarning = true;
}
if (
userInfo.userData.AuthorityInfo &&
userInfo.userData.AuthorityInfo[
"2d25dddc-e67f-4e26-b2d1-da78beed2c11"
] === 1
@ -4648,9 +4620,6 @@ export default {
},
// 3
async handleGetSelectVersion3Data(month) {
console.log("month", month);
console.log("selectMonthIndex", this.selectMonthIndex);
console.log("selectMonth", this.selectMonth);
uni.showLoading({
title: "正在加载...",
});
@ -4667,7 +4636,6 @@ export default {
StatisticsMonth: this.selectMonth, //
StatisticsDate: this.lastDay,
};
console.log("req", req);
const nowData = await request.$webGet(
"CommercialApi/Revenue/GetMonthlyBusinessAnalysis",
req
@ -4684,8 +4652,6 @@ export default {
"CommercialApi/Revenue/GetMonthlyBusinessAnalysis",
allReq
);
console.log("nowData", nowData);
console.log("allData", allData);
let allList = allData.Result_Data.List;
let allRes = {};
if (allList && allList.length > 0) {
@ -4778,9 +4744,6 @@ export default {
}
this.selectVersion3Obj = res;
console.log("allRes", allRes);
console.log("res", res);
uni.hideLoading();
},
//
@ -4897,7 +4860,6 @@ export default {
this.showHaveNotice = !this.showHaveNotice;
},
changeShowRealBox(e) {
console.log('eee', e);
this.realBoxPageX = e.detail.x;
this.realBoxPageY = e.detail.y;
this.showRealBox = !this.showRealBox;
@ -5238,11 +5200,9 @@ export default {
StatisticsType: 1,
ShowCount: 20,
};
console.log("12312312req", req);
request
.$webGet("CommercialApi/BigData/GetBayonetWarning", req)
.then((res) => {
console.log("车流预警", res);
if (res.Result_Data.List && res.Result_Data.List.length > 0) {
this.special = true;
}
@ -5311,7 +5271,6 @@ export default {
// latitude:user.latitude,
// }
// request.$webGet('CommercialApi/BaseInfo/GetServerpartList',req).then(res=>{
// console.log('res',res)
//
// uni.hideLoading()
// })
@ -5540,7 +5499,6 @@ export default {
this.trafficQOQObj = null;
this.dailyExamineObj = null;
this.monthAdd = null;
console.log("this.typeList", this.typeList);
//
this.initYesterdayData(this.selectMonth !== date.getMonth() + 1);
//
@ -5693,40 +5651,32 @@ export default {
// ShowCompareRate: true,
// ShowYearRevenue: true
// }
console.log("this.single", this.single);
const nowDate = new Date(this.single);
let month = JSON.parse(JSON.stringify(this.selectMonth));
console.log("nowDate.getFullYear()", nowDate.getFullYear());
if (month < 10) {
month = "0" + month;
}
let req;
if (type) {
if (nowDate.getMonth() + 1 === this.selectMonth) {
console.log("1");
req = {
pushProvinceCode: this.useInfo.userData.ProvinceCode || "340000",
StatisticsMonth: `${nowDate.getFullYear()}${month}`,
StatisticsDate: this.lastDay,
};
console.log("req", req);
} else {
console.log("2");
req = {
pushProvinceCode: this.useInfo.userData.ProvinceCode || "340000",
StatisticsMonth: `${nowDate.getFullYear()}${month}`,
StatisticsDate: this.lastDay,
};
console.log("req", req);
}
} else {
console.log("3");
req = {
pushProvinceCode: this.useInfo.userData.ProvinceCode || "340000",
StatisticsMonth: `${nowDate.getFullYear()}${month}`,
StatisticsDate: type ? null : this.lastDay,
};
console.log("req", req);
}
uni.showLoading({
title: "正在加载...",
@ -5736,11 +5686,9 @@ export default {
.then((lastData) => {
flag3 = true;
let result = lastData.Result_Data;
console.log("result2", result);
let progressAll = 0;
this.currentPeriodData = result.MonthRevenueModel.CurAccountRoyalty;
console.log("result.BusinessTypeList", result.BusinessTypeList);
let shareList = [{}, {}, {}];
result.BusinessTypeList.forEach((item) => {
progressAll += Number(item.value);
@ -5779,7 +5727,6 @@ export default {
shareList[2] = item;
}
});
console.log("shareList", shareList);
this.moneyRateList = [
Number(shareList[0].value),
Number(shareList[1].value),
@ -5788,10 +5735,8 @@ export default {
let sum = 0;
shareList.forEach((item) => {
console.log("Number(item.value)", Number(item.value));
sum += Number(item.value);
});
console.log("sum", sum);
if (sum === 0) {
this.ydRate = "-";
this.shopRate = "-";
@ -5810,7 +5755,6 @@ export default {
}
this.profitSharingList = shareList;
console.log("result.BusinessTypeList", result.BusinessTypeList);
this.typeList = result.BusinessTypeList;
this.revenueMoney = result.BusinessTypeList[0].showValue;
this.externalMoney = result.BusinessTypeList[1].showValue;
@ -5844,7 +5788,6 @@ export default {
});
this.showTableData = result.MonthRevenueModel;
console.log("result.MonthRevenueModel", result.MonthRevenueModel);
//
this.showTableData.YearRevenueAdd = (
((this.showTableData.YearRevenueAmount -
@ -5991,14 +5934,12 @@ export default {
request
.$webGet("CommercialApi/Revenue/GetProvinceAvgBayonetAnalysis", req)
.then((res) => {
console.log("res11121212", res);
res.Result_Data.List.forEach((item) => {
if (item.Serverpart_Name === "QOQ") {
this.trafficQOQObj = item;
} else if (item.Serverpart_Name === "YOY") {
this.trafficYOYObj = item;
} else {
console.log("this.trafficCurrentObj", this.trafficCurrentObj);
this.trafficCurrentObj = item;
if (this.trafficCurrentObj.Vehicle_AddUpCount / 1000000 >= 1) {
this.trafficCurrentObj.AddUpCount = this.$util.fmoney(
@ -6188,9 +6129,7 @@ export default {
this.bodyList = list;
}
let index1 = (this.showTableData.CashPay / 10000).toString().indexOf(".");
console.log("this.showTableData.CashPay", this.showTableData.CashPay);
let number = this.showTableData.CashPay / 10000;
console.log("number", number);
this.showTableData.CashPayChange = this.$util.fmoney(
this.$util.getMoney(number),
2

View File

@ -9,9 +9,9 @@ const state = {
visitChannels: '',
userData: {}, // 用户基础信息
toDoMsg: {},// 用户首页待办事项
isConnect: true ,// 网络是否链接
isConnect: true,// 网络是否链接
isLoading: false, // 是否在请求数据
isChangeMsgCount: false ,// 是否更新待办事项
isChangeMsgCount: false,// 是否更新待办事项
shouldReLoadingList: false // 是否需要更新当前列表
};
@ -23,16 +23,16 @@ const getters = {
getMenu(state) {
return state.userData.AuthorityInfo
},
getConnect(state){
getConnect(state) {
return state.isConnect
},
getLoading (state) {
getLoading(state) {
return state.isLoading
},
isChangeMsgCount (state) {
isChangeMsgCount(state) {
return state.isChangeMsgCount
},
shouldReLoadingList (state) {
shouldReLoadingList(state) {
return state.shouldReLoadingList
},
@ -40,33 +40,40 @@ const getters = {
const mutations = {
setUser (state, data) {
setUser(state, data) {
state.userData = data
},
setVisitChannels (state, data) {
setVisitChannels(state, data) {
state.visitChannels = data
},
shouldReLoadingList (state, data){
shouldReLoadingList(state, data) {
state.shouldReLoadingList = data
},
isConnect(state,value) {
isConnect(state, value) {
state.isConnect = value
state.isConnect = value
},
setUserTodoList(state,value){
state.toDoMsg = value
setUserTodoList(state, value) {
state.toDoMsg = value
},
};
const actions = {
getLoginCode({ dispatch, state} ){
uni.login({ // 登录
success (res) {
dispatch('memberLogin',res.code) // 获取用户数据
}
})
getLoginCode({ dispatch, state }) {
return new Promise((resolve, reject) => {
uni.login({ // 登录
success(res) {
dispatch('memberLogin', res.code) // 获取用户数据
.then(resolve)
.catch(reject);
},
fail(err) {
reject(err);
}
})
});
},
getTodoList({ dispatch, state,commit}){ // 获取用户待办事项
getTodoList({ dispatch, state, commit }) { // 获取用户待办事项
let _user = state.userData
request.$get("ToDoList", {
userId: _user.UserId,
@ -75,75 +82,87 @@ const actions = {
commit('setUserTodoList', res.Data)
})
},
memberLogin({ dispatch, state,commit},_code) {
async memberLogin({ dispatch, state, commit }, _code) {
let _user = state.userData
request.$get('WeChat_Login',{
// request.$webGet('WebAPI_Push/WeChat/Login',{
const data = await request.$get('WeChat_Login', {
// request.$webGet('WebAPI_Push/WeChat/Login',{
WeChat_Code: _code || '',
}).then(data=>{
if (data.Result_Code === 100) {
let user = data.Result_Data
if (user.Membership_Id) {
dispatch('updateUser',data.Result_Data)
// _this.addUserBehavior(1002) // 记录用户行为
}else{
commit('setUser', user)
uni.showModal({
title:'温馨提示',
content: '请您授权登录后再操作。',
success(res) {
if(res.confirm){
util.toNextRoute('redirectTo', '/pages/register/register')
}
}
})
}
} else if (data.Result_Code === 200) { // session过期
dispatch('getLoginCode')
} else {
console.log(data)
}
})
if (data.Result_Code === 100) {
let user = data.Result_Data
console.log('WeChat_Login 返回的用户数据:', user);
console.log('Membership_Id:', user.Membership_Id);
if (user.Membership_Id) {
return dispatch('updateUser', data.Result_Data)
// _this.addUserBehavior(1002) // 记录用户行为
} else {
commit('setUser', user)
// 先跳转到无权限页面
uni.redirectTo({
url: '/pages/commercialBI/noData?type=noAuthor',
})
// setTimeout(() => {
// uni.showModal({
// title: '温馨提示',
// content: '请您授权登录后再操作。',
// success(res) {
// if (res.confirm) {
// // 点击确定,跳转到注册页
// util.toNextRoute('redirectTo', '/pages/register/register')
// }
// // 点击取消,不做任何操作,停留在无权限页面
// }
// })
// }, 500)
return Promise.reject('无权限')
}
} else if (data.Result_Code === 200) { // session过期
return dispatch('getLoginCode')
} else {
console.log(data)
return Promise.reject(data)
}
},
async updateUser ({dispatch, commit, state},user){
async updateUser({ dispatch, commit, state }, user) {
let _user = user || state.userData
let _id = _user.Membership_Id
if(!_id) return
// console.log(_user)
await request.$get('WeChat_GetBusinessMemberInfo',{Membership_Id:_id}).then(async res=>{
// request.$webGet('WebAPI_Push/Member/GetMemberInfo',{Membership_Id:_id,memberShipId:_id}).then(res=>{
if(res.Result_Code==100) {
let data = res.Result_Data
data.WeChat_MiniProToken = _user.WeChat_MiniProToken
data.WeChat_UserId = _user.WeChat_UserId
data.WeChat_UserName = _user.WeChat_UserName
let UserCityList = data.UserCityAuthority.split(' ')
let str = ''
if (UserCityList && UserCityList.length>0){
UserCityList.forEach(item=>{
if (str){
str+=`,${item}`
}else{
str = item
}
})
}
const serverPart = await request.$webGet('/EShangApiMain/BaseInfo/GetServerpartDDL',{ServerpartCodes: str})
data.serverPartList = serverPart.Result_Data.List
commit('setUser', data)
dispatch('getTodoList')
}else{
uni.redirectTo({
url:`/pages/commercialBI/noData?type=noAuthor`
if (!_id) return
// 直接 await,不使用 .then(),确保同步执行
const res = await request.$get('WeChat_GetBusinessMemberInfo', { Membership_Id: _id })
if (res.Result_Code == 100) {
let data = res.Result_Data
data.WeChat_MiniProToken = _user.WeChat_MiniProToken
data.WeChat_UserId = _user.WeChat_UserId
data.WeChat_UserName = _user.WeChat_UserName
let UserCityList = data.UserCityAuthority.split(' ')
let str = ''
if (UserCityList && UserCityList.length > 0) {
UserCityList.forEach(item => {
if (str) {
str += `,${item}`
} else {
str = item
}
})
}
})
const serverPart = await request.$webGet('/EShangApiMain/BaseInfo/GetServerpartDDL', { ServerpartCodes: str })
data.serverPartList = serverPart.Result_Data.List
commit('setUser', data)
dispatch('getTodoList')
} else {
uni.redirectTo({
url: `/pages/commercialBI/noData?type=noAuthor`
})
}
}
}
export default new Vuex.Store({
@ -156,7 +175,7 @@ export default new Vuex.Store({
CreatePersistedState({
storage: {
getItem: key => uni.getStorageSync(key),
setItem: (key,value) => uni.setStorageSync(key,value),
setItem: (key, value) => uni.setStorageSync(key, value),
removeItem: key => uni.removeStorageSync(key)
}
})