WINDOWS-7IFQK7E\EDY 2 lat temu
rodzic
commit
ff4b777e17
2 zmienionych plików z 247 dodań i 206 usunięć
  1. 88 47
      src/pages/_user/index.vue
  2. 159 159
      src/store/user.js

+ 88 - 47
src/pages/_user/index.vue

@@ -1,7 +1,18 @@
 <template>
   <header class="header">
     <img src="@/assets/images/user-bg.png" alt="" />
-    <span v-if="userInfo.user_role_id == '77'" class="changeStu" @click="changeStu()"><img class="w-12px h-13px inline-block mr-8px" src="@/assets/images/change.png" />切换学生</span>
+    <span
+      v-if="userInfo.user_role_id == '77'"
+      class="changeStu"
+      @click="changeStu()"
+      ><img
+        class="w-12px h-13px inline-block mr-8px"
+        src="@/assets/images/change.png"
+      />切换学生
+      <span v-if="childId == '76'">(当前已绑定小孩{{ childName }})</span
+      ><span v-else>(当前未绑定小孩)</span>
+    </span>
+
     <div class="logout" @click="loginOut">
       <span></span>
       退出登录
@@ -11,7 +22,10 @@
         <img :src="userInfo.user_avatar.big" alt="" />
       </div>
       <div class="info">
-        <h3 class="user-name">{{ userInfo.user_realname }}<span class="role-type">{{userInfo.user_role_name}}</span></h3>
+        <h3 class="user-name">
+          {{ userInfo.user_realname
+          }}<span class="role-type">{{ userInfo.user_role_name }}</span>
+        </h3>
         <h4 class="user-school">{{ userInfo.sm_info.sm_name }}</h4>
       </div>
     </div>
@@ -107,7 +121,7 @@
     </li>
 
     <!-- 社团教师 -->
-    <li @click="toOther(10)" v-if="userInfo.user_role_id == '75'&&!isManage">
+    <li @click="toOther(10)" v-if="userInfo.user_role_id == '75' && !isManage">
       <div>
         <span class="order-icon o-5"></span>
         <h4 class="order-title">社团课程</h4>
@@ -115,7 +129,7 @@
       <van-icon name="arrow" size="16" color="#E0E0E0" />
     </li>
     <!-- 管理员 -->
-    <li @click="toOther(9) " v-if="userInfo.user_role_id == '72'&&!isManage">
+    <li @click="toOther(9)" v-if="userInfo.user_role_id == '72' && !isManage">
       <div>
         <span class="order-icon o-5"></span>
         <h4 class="order-title">社团开展情况</h4>
@@ -132,24 +146,36 @@
   <div class="change-stu" v-if="toChange">
     <van-icon @click="toChange = false" name="cross" size="0.4*13.3vw" />
     <h3>切换孩子</h3>
-    <div class="mt-17px" >
-      <div @click="initChild(item)" v-for="(item, index) in childData" :key="item">
-        <div v-if="childData.length" class="stu-list  flex w-full h-40px mb-7px rounded px-6px" :class="activeChild==item.user_id?'blueList':''">
-          <span class=" flex w-1/6"><img class="w-28px h-28px " style="borderRadius:50%" :src="item.user_avatar.big" alt=""></span>
-          <span class=" w-3/5">{{ item.user_realname}}</span>
-          <span class="stu-index">孩子{{index+1}}</span>
+    <div class="mt-17px">
+      <div
+        @click="initChild(item)"
+        v-for="(item, index) in childData"
+        :key="item"
+      >
+        <div
+          v-if="childData.length"
+          class="stu-list flex w-full h-40px mb-7px rounded px-6px"
+          :class="activeChild == item.user_id ? 'blueList' : ''"
+        >
+          <span class="flex w-1/6"
+            ><img
+              class="w-28px h-28px"
+              style="borderradius: 50%"
+              :src="item.user_avatar.big"
+              alt=""
+          /></span>
+          <span class="w-3/5">{{ item.user_realname }}</span>
+          <span class="stu-index">孩子{{ index + 1 }}</span>
         </div>
       </div>
-
     </div>
     <div class="submit">
-      <button @click="submitDM()"> 提交 </button>
+      <button @click="submitDM()">提交</button>
     </div>
   </div>
-  
 </template>
 <script>
-import { showToast } from 'vant';
+import { showToast } from "vant";
 
 export default {
   data() {
@@ -160,26 +186,30 @@ export default {
       absentStu: [],
       activeChild: "",
       childData: [],
+      childId: "",
+      childName: "",
       stuList: [
         {
           user_id: "1",
           realname: "",
-          isCheck: false
+          isCheck: false,
         },
         {
           user_id: "2",
           realname: "",
-          isCheck: false
-        }, {
+          isCheck: false,
+        },
+        {
           user_id: "3",
           realname: "",
-          isCheck: false
-        }, {
+          isCheck: false,
+        },
+        {
           user_id: "4",
           realname: "",
-          isCheck: false
-        }
-      ]
+          isCheck: false,
+        },
+      ],
     };
   },
   methods: {
@@ -215,7 +245,7 @@ export default {
           window.location.href = "https://nmlm.bozedu.net/page/my/about.html";
           break;
         case 6:
-          this.$router.push('/my_children')
+          this.$router.push("/my_children");
           // window.location.href =
           //   "https://nmlm.bozedu.net/page/parent/my-children.html";
           break;
@@ -224,19 +254,18 @@ export default {
             "https://nmlm.bozedu.net/page/my/my-class.html";
           break;
         case 8:
-          this.$router.push({ name: "bzrgz", });
+          this.$router.push({ name: "bzrgz" });
           break;
         case 9:
-          this.$router.push({ name: "stkzqk", });
+          this.$router.push({ name: "stkzqk" });
           break;
         case 10:
-          this.$router.push({ name: "stxk_teacher", });
+          this.$router.push({ name: "stxk_teacher" });
           break;
         case 11:
-          showToast('该模块正在开发中~');
+          showToast("该模块正在开发中~");
           break;
       }
-
     },
     changeStu() {
       request({
@@ -247,31 +276,43 @@ 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") {
+          this.toChange = true;
+        } else {
+          showToast("请先绑定孩子~");
+        }
       });
-
-   
     },
     initChild(item) {
+      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_" + this.userInfo.user_id,
+        JSON.stringify(item)
+      );
     },
     submitDM() {
-         showToast('切换成功~');
-      this.toChange = false
-     location.reload();
-    }
-
+      showToast("切换成功~");
+      this.toChange = false;
+      location.reload();
+    },
   },
   mounted() {
     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;
+    }
+  },
 };
 </script>
 <style lang="scss" scoped>
@@ -333,9 +374,9 @@ export default {
       .user-name {
         font-size: 14px;
         color: #fff;
-       
-        .role-type{
-          padding:2px 8px;
+
+        .role-type {
+          padding: 2px 8px;
           font-size: 12px;
           border: 1px solid #ffffff;
           border-radius: 6px;
@@ -504,7 +545,7 @@ export default {
     top: 0.3 * 13.3vw;
   }
   h3 {
-   // width: 1.2 * 13.3vw;
+    // width: 1.2 * 13.3vw;
     height: 0.4 * 13.3vw;
     font-size: 0.3 * 13.3vw;
     position: relative;

Plik diff jest za duży
+ 159 - 159
src/store/user.js