소스 검색

feature_20260427_经销商用户多身份切换

zhujindu 1 주 전
부모
커밋
b9a6225b0f
2개의 변경된 파일22개의 추가작업 그리고 14개의 파일을 삭제
  1. 9 0
      src/api/week.js
  2. 13 14
      src/views/week/changeChain.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,
+  });
+}

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

@@ -3,11 +3,12 @@
     <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.chainList && userInfo.chainList.length > 0">
+          <van-radio-group v-model="userInfo.chainCode" @change="chainChange">
+            <van-radio v-for="value in userInfo.chainList" :key="value.id" :name="value.id">
+              {{ value.name }}
+            </van-radio>
+          </van-radio-group>
         </div>
       </div>
     </div>
@@ -15,7 +16,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 +30,13 @@ export default {
   },
   created() {},
   methods: {
-    change(value) {
+    chainChange(value) {
       console.log(value);
-      this.toastLoading(0, '加载中...', true);
-      setPhotoMethod({ photoMethod: value ? 1 : 0 }).then((res) => {
-        this.toastLoading().clear();
-        if (res.code == 200) {
-          this.$toast('设置成功');
-          // 获取移动端获取用户信息接口
-          store.dispatch('getUserInfo');
+      switchchainIdentity({ chainCode: value }).then((res) => {
+        if (res.code === 200) {
+          store.dispatch('user/getUserInfo').then(() => {
+            this.$toast('切换成功');
+          });
         }
       });
     },