Sfoglia il codice sorgente

Merge branch 'feature_20260427_经销商用户多身份切换' into uat(dev)

# Conflicts:
#	src/api/week.js
zhujindu 1 settimana fa
parent
commit
4a5c8d18a6
3 ha cambiato i file con 40 aggiunte e 15 eliminazioni
  1. 9 0
      src/api/week.js
  2. 24 14
      src/views/week/changeChain.vue
  3. 7 1
      src/views/week/index.vue

+ 9 - 0
src/api/week.js

@@ -34,3 +34,12 @@ export function reportAnalysis(query) {
     params: query,
   });
 }
+
+// 切换经销商身份接口
+export function switchChainIdentity(query) {
+  return request({
+    url: '/mobile/switchChainIdentity',
+    method: 'get',
+    params: query,
+  });
+}

+ 24 - 14
src/views/week/changeChain.vue

@@ -3,11 +3,17 @@
     <van-nav-bar class="navBar" title="切换经销商" left-arrow @click-left="onClickLeft" />
     <div class="content">
       <div class="module">
-        <div class="box">
-          <div class="label">允许拍照时缩放,但每张会保存到本地相册</div>
-          <div class="value">
-            <van-switch v-model="switchChecked" size="20" @change="change" />
-          </div>
+        <div
+          class="box"
+          v-if="userInfo.userMultipleChains && userInfo.userMultipleChains.length > 0">
+          <van-radio-group v-model="userInfo.chainCode" @change="chainChange">
+            <van-radio
+              v-for="value in userInfo.userMultipleChains"
+              :key="value.chainCode"
+              :name="value.chainCode">
+              {{ value.chainName }}
+            </van-radio>
+          </van-radio-group>
         </div>
       </div>
     </div>
@@ -15,7 +21,7 @@
 </template>
 <script>
 import { mapState } from 'vuex';
-import { setPhotoMethod } from '@/api/week';
+import { switchChainIdentity } from '@/api/week';
 import store from '@/store';
 export default {
   name: 'changeChain',
@@ -29,15 +35,16 @@ export default {
   },
   created() {},
   methods: {
-    change(value) {
-      console.log(value);
-      this.toastLoading(0, '加载中...', true);
-      setPhotoMethod({ photoMethod: value ? 1 : 0 }).then((res) => {
+    chainChange(value) {
+      this.toastLoading(0, '切换中,请稍候...', true);
+      switchChainIdentity({ chainCode: value }).then((res) => {
         this.toastLoading().clear();
-        if (res.code == 200) {
-          this.$toast('设置成功');
-          // 获取移动端获取用户信息接口
-          store.dispatch('getUserInfo');
+        if (res.code === 200) {
+          store.dispatch('getUserInfo').then(() => {
+            this.$toast('切换成功');
+          });
+        } else {
+          this.$toast(res.message || '切换失败');
         }
       });
     },
@@ -66,6 +73,9 @@ export default {
         justify-content: space-between;
         padding: 10px;
         font-size: 16px;
+        .van-radio {
+          padding: 8px 0;
+        }
       }
     }
   }

+ 7 - 1
src/views/week/index.vue

@@ -68,7 +68,7 @@
               <van-icon name="setting-o" class="zicon" color="#0158ba" />
             </template>
           </van-cell>
-          <van-cell title="切换经销商" is-link to="/changeChain">
+          <van-cell title="切换经销商" is-link to="/changeChain" v-if="userInfo.userMultipleChains">
             <template #icon>
               <van-icon name="exchange" class="zicon" color="#0158ba" />
             </template>
@@ -272,9 +272,15 @@ import storeselect from '@/assets/Icon/storeselect.png';
 import tabBar from '@/components/tabBar';
 import { getReportInfo, getstoreCoverPosition } from '@/api/index';
 import { selectAllocationPermission } from '@/api/week';
+import { mapState } from 'vuex';
 export default {
   name: 'MyList',
   components: { tabBar },
+  computed: {
+    ...mapState({
+      userInfo: (state) => state.user.userInfo,
+    }),
+  },
   data() {
     return {
       history: history,