fuwei 5 лет назад
Родитель
Сommit
f43d5445f8
2 измененных файлов с 15 добавлено и 4 удалено
  1. 11 3
      ghs/src/admin/home/me.vue
  2. 4 1
      ghs/src/utils/auth.js

+ 11 - 3
ghs/src/admin/home/me.vue

@@ -94,6 +94,7 @@
     import DorpdownSelect from "@/components/module/dorpdownSelect";
     import { selectShop } from '@/mixins'
     import { getUser } from '@/utils/auth'
+    import { mapGetters } from 'vuex'
     export default { // 我的
         name:"Me",
         components:{
@@ -102,6 +103,9 @@
             DorpdownSelect
         },
         mixins:[selectShop],
+        computed: {
+		...mapGetters(["getLoginInfo"])
+	},
         data(){
             return {
                 constant: this.$constant,
@@ -122,7 +126,12 @@
                     title: '加载中'
                 });
               try {
-                  let res = await toggleShop({ shopId});
+                  let {data} = await toggleShop({ shopId});
+                  this.$store.commit('setLoginInfo', {
+                        ...this.getLoginInfo,
+                        shopId: data.shopId, // 门店id
+                        shopAdminId: data.id //员工id
+					})
                   getUser(true)
                   this.init()
               } finally {
@@ -131,8 +140,7 @@
               
             },
             changeShop(){
-                console.log(this.userShopAll)
-              let idx = this.userShopAll.findIndex(i=>i.shopId === '2')
+              let idx = this.userShopAll.findIndex(i=>i.id == this.getLoginInfo.shopId)
               let shopId = null
               if(idx === this.userShopAll.length - 1) {
                   shopId = this.userShopAll[0].id

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

@@ -98,7 +98,10 @@ export async function wxLoginFn(update) {
 
 					uni.setStorageSync('token', subRes.data.token)
 					uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
-					store.commit('setLoginInfo', subRes.data.admin)
+					store.commit('setLoginInfo', {
+						...subRes.data.admin,
+						...subRes.data
+					})
 
 					//启动更新逻辑 shish 2020.5.18
 					if (subRes.data.update == 1) {