Quellcode durchsuchen

Merge branch 'feature_20260427_经销商用户多身份切换' into release

zhujindu vor 1 Tag
Ursprung
Commit
557547db61
4 geänderte Dateien mit 132 neuen und 0 gelöschten Zeilen
  1. 9 0
      src/api/week.js
  2. 6 0
      src/router/index.js
  3. 102 0
      src/views/week/changeChain.vue
  4. 15 0
      src/views/week/index.vue

+ 9 - 0
src/api/week.js

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

+ 6 - 0
src/router/index.js

@@ -557,6 +557,12 @@ const router = new VueRouter({
           component: () => import('@/views/week/SUPTaskApproval/SUPTaskApprovalDetail.vue'),
           meta: { title: '主管任务审批详情', keepAlive: true },
         },
+        {
+          path: '/changeChain',
+          name: 'changeChain',
+          component: () => import('@/views/week/changeChain.vue'),
+          meta: { title: '切换经销商' },
+        },
       ],
     },
     {

+ 102 - 0
src/views/week/changeChain.vue

@@ -0,0 +1,102 @@
+<template>
+  <div class="changeChain">
+    <van-nav-bar class="navBar" title="切换经销商" left-arrow @click-left="onClickLeft" />
+    <div class="content">
+      <div class="module">
+        <div
+          class="box"
+          v-if="userInfo && userInfo.userMultipleChains && userInfo.userMultipleChains.length > 0">
+          <van-radio-group v-model="selectedChainIndex" @change="chainChange">
+            <van-radio
+              v-for="(value, index) in userInfo.userMultipleChains"
+              :key="`${value.chainCode}-${index}`"
+              :name="index">
+              {{ value.chainName }}
+            </van-radio>
+          </van-radio-group>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import { switchChainIdentity } from '@/api/week';
+import store from '@/store';
+export default {
+  name: 'changeChain',
+  computed: {
+    ...mapState({
+      userInfo: (state) => state.user.userInfo,
+    }),
+  },
+  data() {
+    return {
+      selectedChainIndex: null,
+    };
+  },
+  watch: {
+    'userInfo.userMultipleChains'(val) {
+      this.initSelectedChain(val);
+    },
+  },
+  created() {
+    this.initSelectedChain(this.userInfo && this.userInfo.userMultipleChains);
+  },
+  methods: {
+    initSelectedChain(val) {
+      if (val && val.length > 0) {
+        const currentIndex = val.findIndex((item) => item.check);
+        this.selectedChainIndex = currentIndex >= 0 ? currentIndex : 0;
+      }
+    },
+    chainChange(index) {
+      const chain = this.userInfo.userMultipleChains[index];
+      if (!chain) {
+        return;
+      }
+      this.toastLoading(0, '切换中,请稍候...', true);
+      switchChainIdentity({ userMultipleChainId: chain.multipleChainId }).then((res) => {
+        this.toastLoading().clear();
+        if (res.code === 200) {
+          store.dispatch('getUserInfo').then(() => {
+            this.$toast('切换成功');
+          });
+        } else {
+          this.$toast(res.message || '切换失败');
+        }
+      });
+    },
+    onClickLeft() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+.changeChain {
+  width: 100%;
+  height: 100%;
+  .content {
+    margin: 10px 16px;
+    .module {
+      margin-bottom: 10px;
+      .title {
+        font-size: 16px;
+        padding: 10px 0;
+      }
+      .box {
+        background: #fff;
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        padding: 10px;
+        font-size: 16px;
+        .van-radio {
+          padding: 8px 0;
+        }
+      }
+    }
+  }
+}
+</style>

+ 15 - 0
src/views/week/index.vue

@@ -68,6 +68,15 @@
               <van-icon name="setting-o" class="zicon" color="#0158ba" />
             </template>
           </van-cell>
+          <van-cell
+            title="切换经销商"
+            is-link
+            to="/changeChain"
+            v-if="userInfo && userInfo.userMultipleChains">
+            <template #icon>
+              <van-icon name="exchange" class="zicon" color="#0158ba" />
+            </template>
+          </van-cell>
         </van-cell-group>
         <!--      客资类-->
         <van-cell-group inset class="mtb10">
@@ -267,9 +276,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,