Jelajahi Sumber

跳转的临时解决方案 后面请优化 @傅威

shish 6 tahun lalu
induk
melakukan
aac8773e31

+ 0 - 4
store/src/admin/adminShop/bind.vue

@@ -111,11 +111,7 @@ export default {
       generateAdmin(this.form).then(res => {
         this.showBindArea = false
         this.showSuccessArea = true
-        console.log(res)
-        //这个shopId没有保存进去,无法到后台页面
         uni.setStorageSync('shopId', res.data.shopId)
-        console.log('保存shopId的情况')
-        console.log(uni.getStorageSync('storage_key'))
         //this.$msg("添加成功!");
       });
     },

+ 22 - 9
store/src/mixins/globalMixins.js

@@ -19,7 +19,7 @@ export default {
 	// 	...mapGetters({ userInfo: 'getUser' })
 	// },
 	// 页面生命周期才触发
-	onLoad:	function (option) {
+	onLoad: function (option) {
 		this.option = option || null
 		if (option.token) {
 			uni.setStorageSync('token', option.token)
@@ -28,21 +28,34 @@ export default {
 			uni.setStorageSync('account', option.account)
 		}
 
+
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
 		if (isLogin() == false) {
 			wxLoginFn()
 				.then(res => {
-					if(+res.data.shopId > 0) {
-						this.$util.pageTo({
-							url: "/admin/home/workbench",
-							type: 3
+
+					// @傅威 明天要发版,我做了个临时解决方案,这块请优化
+					//现在我们分 官网 和 后台 的页面。其中官网页面不会很多
+					//shopId=0 (即非管理员) 时不能让访问后台的页面
+					//不管shopId值是多少(是否管理员),有些页面都应允许访问
+					if (res.redirectPage != 'admin/adminShop/bind') {
+
+
+
+						if (+res.data.shopId > 0) {
+							this.$util.pageTo({
+								url: "/admin/home/workbench",
+								type: 3
 							});
-					}else{
-						this.$util.pageTo({
-							url: "/admin/official/index",
-							type: 2
+						} else {
+							this.$util.pageTo({
+								url: "/admin/official/index",
+								type: 2
 							});
+						}
+
 					}
+
 					getUser()
 				})
 		}

+ 8 - 1
store/src/utils/auth.js

@@ -91,7 +91,14 @@ export async function wxLoginFn(update) {
 					if (util.isEmpty(subRes)){
 						return false
 					} 
-					resolve(subRes)
+
+					// @傅威 明天要发版,我做了个临时解决方案,这块请优化好
+					
+					var pages = getCurrentPages();  
+					var page = (pages[pages.length - 1]).route;
+
+					resolve({redirectPage:page,...subRes})
+
 					uni.setStorageSync('token', subRes.data.token)
 					uni.setStorageSync('shopId', subRes.data.shopId)
 					store.commit('setLoginInfo', subRes.data.user)