浏览代码

绑定孩子逻辑变更

WINDOWS-7IFQK7E\EDY 2 年之前
父节点
当前提交
81a508636b
共有 2 个文件被更改,包括 38 次插入71 次删除
  1. 0 28
      src/components.d.ts
  2. 38 43
      src/pages/_user/index.vue

+ 0 - 28
src/components.d.ts

@@ -11,40 +11,13 @@ declare module '@vue/runtime-core' {
     RemoteList: typeof import('./components/RemoteList/index.vue')['default']
     RouterLink: typeof import('vue-router')['RouterLink']
     RouterView: typeof import('vue-router')['RouterView']
-    VanButton: typeof import('vant/es')['Button']
     VanCard: typeof import('vant/es')['Card']
-    VanCascader: typeof import('vant/es')['Cascader']
-    VanCellGroup: typeof import('vant/es')['CellGroup']
-    VanCheckbox: typeof import('vant/es')['Checkbox']
-    VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
-    VanCollapse: typeof import('vant/es')['Collapse']
-    VanCollapseItem: typeof import('vant/es')['CollapseItem']
     VanConfigProvider: typeof import('vant/es')['ConfigProvider']
-    VanCountDown: typeof import('vant/es')['CountDown']
-    VanDialog: typeof import('vant/es')['Dialog']
-    VanDivider: typeof import('vant/es')['Divider']
-    VanDropdownItem: typeof import('vant/es')['DropdownItem']
-    VanDropdownMenu: typeof import('vant/es')['DropdownMenu']
-    VanField: typeof import('vant/es')['Field']
-    VanForm: typeof import('vant/es')['Form']
     VanGrid: typeof import('vant/es')['Grid']
     VanGridItem: typeof import('vant/es')['GridItem']
     VanIcon: typeof import('vant/es')['Icon']
-    VanImage: typeof import('vant/es')['Image']
     VanList: typeof import('vant/es')['List']
-    VanLoading: typeof import('vant/es')['Loading']
-    VanNavBar: typeof import('vant/es')['NavBar']
-    VanOverlay: typeof import('vant/es')['Overlay']
-    VanPopup: typeof import('vant/es')['Popup']
     VanPullRefresh: typeof import('vant/es')['PullRefresh']
-    VanRadio: typeof import('vant/es')['Radio']
-    VanRadioGroup: typeof import('vant/es')['RadioGroup']
-    VanRate: typeof import('vant/es')['Rate']
-    VanSkeleton: typeof import('vant/es')['Skeleton']
-    VanStep: typeof import('vant/es')['Step']
-    VanSteps: typeof import('vant/es')['Steps']
-    VanSticky: typeof import('vant/es')['Sticky']
-    VanSubmitBar: typeof import('vant/es')['SubmitBar']
     VanSwipe: typeof import('vant/es')['Swipe']
     VanSwipeItem: typeof import('vant/es')['SwipeItem']
     VanTab: typeof import('vant/es')['Tab']
@@ -52,6 +25,5 @@ declare module '@vue/runtime-core' {
     VanTabbarItem: typeof import('vant/es')['TabbarItem']
     VanTabs: typeof import('vant/es')['Tabs']
     VanTag: typeof import('vant/es')['Tag']
-    VanUploader: typeof import('vant/es')['Uploader']
   }
 }

+ 38 - 43
src/pages/_user/index.vue

@@ -4,7 +4,7 @@
     <span
       v-if="userInfo.user_role_id == '77'"
       class="changeStu"
-      @click="changeStu()"
+      @click="childData.length != '0' ? (toChange = true) : (toChange = false)"
       ><img
         class="w-12px h-13px inline-block mr-8px"
         src="@/assets/images/change.png"
@@ -19,7 +19,7 @@
     </div>
     <div class="user-info">
       <div class="user-shot">
-        <img :src="userInfo.user_avatar.big" alt="" />
+        <!-- <img :src="userInfo.user_avatar.big" alt="" /> -->
       </div>
       <div class="info">
         <h3 class="user-name">
@@ -188,28 +188,7 @@ export default {
       childData: [],
       childId: "",
       childName: "",
-      stuList: [
-        {
-          user_id: "1",
-          realname: "",
-          isCheck: false,
-        },
-        {
-          user_id: "2",
-          realname: "",
-          isCheck: false,
-        },
-        {
-          user_id: "3",
-          realname: "",
-          isCheck: false,
-        },
-        {
-          user_id: "4",
-          realname: "",
-          isCheck: false,
-        },
-      ],
+      initUserId: "",
     };
   },
   methods: {
@@ -221,7 +200,6 @@ export default {
           this.isManage = false;
         }
       });
-      console.log(this.userInfo, 333);
     },
     loginOut() {
       localStorage.clear();
@@ -276,11 +254,25 @@ export default {
       }).then((res) => {
         if (res.code == "1") {
           this.childData = res.data.info;
-        }
-        if (this.childData.length != "0") {
-          this.toChange = true;
-        } else {
-          showToast("请先绑定孩子~");
+          if (this.childData.length == "0") {
+            showToast("请先绑定孩子~");
+          }
+          if (localStorage.getItem("childInfo_")) {
+            let userXx = JSON.parse(localStorage.getItem("childInfo_"));
+            this.activeChild = userXx.user_id;
+            this.childId = userXx.user_role_id;
+            this.childName = userXx.user_realname;
+          } else if (this.childData[0].user_id) {
+            localStorage.setItem(
+              "childInfo_",
+              JSON.stringify(this.childData[0])
+            );
+            let userXx = this.childData[0];
+            this.activeChild = userXx.user_id;
+            this.childId = userXx.user_role_id;
+            this.childName = userXx.user_realname;
+            //  console.log(this.childData[0].user_id, 2222);
+          }
         }
       });
     },
@@ -288,10 +280,7 @@ export default {
       this.childId = item.user_role_id;
       this.childName = item.user_realname;
       this.activeChild = item.user_id;
-      localStorage.setItem(
-        "childInfo_" + this.userInfo.user_id,
-        JSON.stringify(item)
-      );
+      localStorage.setItem("childInfo_", JSON.stringify(item));
     },
     submitDM() {
       showToast("切换成功~");
@@ -303,15 +292,21 @@ export default {
     this.IsManage();
   },
   created() {
-    let data = localStorage.getItem("childInfo_" + this.userInfo.user_id);
-    if (data) {
-      let userXx = JSON.parse(
-        localStorage.getItem("childInfo_" + this.userInfo.user_id)
-      );
-      this.activeChild = userXx.user_id;
-      this.childId = userXx.user_role_id;
-      this.childName = userXx.user_realname;
-    }
+    this.changeStu();
+
+    console.log(
+      this.userInfo,
+
+      1111
+    );
+    // if (localStorage.getItem("childInfo_")) {
+    //   let userXx = JSON.parse(
+    //     localStorage.getItem("childInfo_" + this.userInfo.user_id)
+    //   );
+    //   this.activeChild = userXx.user_id;
+    //   this.childId = userXx.user_role_id;
+    //   this.childName = userXx.user_realname;
+    // }
   },
 };
 </script>