shish 6 years ago
parent
commit
32f1229830
3 changed files with 45 additions and 68 deletions
  1. 16 14
      store/src/admin/home/console.vue
  2. 25 53
      store/src/mixins/globalMixins.js
  3. 4 1
      store/src/utils/auth.js

+ 16 - 14
store/src/admin/home/console.vue

@@ -1,7 +1,5 @@
 <template>
 <template>
   <view>
   <view>
-    <view style="font-size:16px;margin-left:30px;" @click="goTo">去官网</view>
-    <view style="font-size:16px;margin-left:30px;margin-top:30px;" @click="goToConsole">去后台</view>
   </view>
   </view>
 </template>
 </template>
 <script>
 <script>
@@ -11,19 +9,23 @@ export default {
   data() {
   data() {
     return {};
     return {};
   },
   },
-  onLoad() {},
+  onLoad() {
+    this.redirectTo();
+  },
   methods: {
   methods: {
-    goTo() {
-      this.$util.pageTo({
-        url: "/admin/official/index",
-        type: 2
-      });
-    },
-    goToConsole() {
-      this.$util.pageTo({
-        url: "/admin/home/workbench",
-        type: 3
-      });
+    redirectTo() {
+      let shopId = uni.getStorageSync("shopId");
+      if (shopId > 0) {
+        this.$util.pageTo({
+          url: "/admin/home/workbench",
+          type: 3
+        });
+      } else {
+        this.$util.pageTo({
+          url: "/admin/official/index",
+          type: 2
+        });
+      }
     }
     }
   }
   }
 };
 };

+ 25 - 53
store/src/mixins/globalMixins.js

@@ -27,61 +27,33 @@ export default {
 		if (option.account) {
 		if (option.account) {
 			uni.setStorageSync('account', option.account)
 			uni.setStorageSync('account', option.account)
 		}
 		}
-		if (constant.source == 'mobile') {
-			if (option.shopId) {
-				uni.setStorageSync('shopId', option.shopId)
-			}
-		}
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
 		uni.setStorageSync('currentQuery', JSON.stringify(option))
-		// 登录
-		if (constant.source == 'store' || constant.source == 'mobile') {
-			if (isLogin()) {
-				// #ifdef H5
-				if (this.init) {
-					if (constant.source == 'store') {
-						getUser()
-					}
-					this.init()
-					// console.log('init', this.init)
-				}
-				// #endif
-				// #ifdef MP-WEIXIN
-				wxLoginFn().then(res => {
-					if (this.init) {
-						if (constant.source == 'store') {
-							getUser()
-						}
-						this.init()
-					}
-				})
-				// #endif
-			} else {
-				// #ifdef H5
-				getCheckLogin().then(res => {
-					if (constant.source == 'store') {
-						if (res) {
-							getUser()
-						}
-					}
-				})
-				// #endif
-				// #ifdef MP-WEIXIN
-				wxLoginFn().then(res => {
-					if (this.init) {
-						if (constant.source == 'store') {
-							getUser()
-						}
-						this.init()
-					}
-				})
-				// #endif
-			}
-		}
-		if (constant.source == 'official') {
-			if (this.init) {
-				this.init()
-			}
+		if (isLogin() == false) {
+			// if (this.init) {
+			// 	if (constant.source == 'store') {
+			// 		getUser()
+			// 	}
+			// 	this.init()
+			// }
+			wxLoginFn().then(res => {
+				getUser()
+			})
 		}
 		}
+		// getCheckLogin().then(res => {
+		// 	if (constant.source == 'store') {
+		// 		if (res) {
+		// 			getUser()
+		// 		}
+		// 	}
+		// })
+		// wxLoginFn().then(res => {
+		// 	if (this.init) {
+		// 		if (constant.source == 'store') {
+		// 			getUser()
+		// 		}
+		// 		this.init()
+		// 	}
+		// })
 	},
 	},
 	mounted() {
 	mounted() {
 		if (this.mInit) {
 		if (this.mInit) {

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

@@ -95,8 +95,11 @@ export async function wxLoginFn(update) {
 	})
 	})
 
 
 	await postWxCode({ code: getObj.code }).then(subRes => {
 	await postWxCode({ code: getObj.code }).then(subRes => {
-		if (UTIL.isEmpty(subRes)) return false
+		if (UTIL.isEmpty(subRes)){
+			return false
+		} 
 		uni.setStorageSync('token', subRes.data.token)
 		uni.setStorageSync('token', subRes.data.token)
+		uni.setStorageSync('shopId', subRes.data.shopId)
 		store.commit('setLoginInfo', subRes.data.user)
 		store.commit('setLoginInfo', subRes.data.user)
 	})
 	})