From aacb4b111141c9b37397b528eae1668245ac93b2 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期五, 22 三月 2024 11:16:41 +0800
Subject: [PATCH] 样书

---
 pages/personalCenter/index.js |   59 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js
index 1ecdbf5..b7bd420 100644
--- a/pages/personalCenter/index.js
+++ b/pages/personalCenter/index.js
@@ -167,12 +167,15 @@
         let userTypeData = res.infoList.find((item) => item.type == 'userType')
         let type = "";
         if (userTypeData) {
-          this.data.userTypeActive = JSON.parse(userTypeData.data).userType;
+          this.setData({
+            userTypeActive: JSON.parse(userTypeData.data).userType,
+          });
           type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
         } else {
           type = '-'
         }
         let defaultUser = {};
+        let nickNameData = res.infoList.find((item) => item.type == 'nickName')
         let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
         let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
         let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
@@ -180,8 +183,8 @@
         if (teacherRole && teacherInfos) {
           defaultUser = {
             ...teacherInfos,
-            fullName: teacherInfos.fullName,
-            icon: teacherInfos.icon,
+            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name,
+            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
             userId: res.userId,
             role: 'Teacher',
             roleId: teacherRole.role.id,
@@ -194,8 +197,8 @@
         } else if (WeChatInfo) {
           defaultUser = {
             ...WeChatInfo,
-            fullName: WeChatInfo.name,
-            icon: WeChatInfo.icon,
+            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
+            icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
             userId: res.userId,
             userType: type
           }
@@ -204,8 +207,8 @@
           });
         } else if (secretData) {
           defaultUser = {
-            fullName: secretData.credential,
-            icon: "",
+            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential,
+            icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : "",
             userId: res.userId,
             userType: type
           }
@@ -250,7 +253,6 @@
   },
   //淇敼鐢ㄦ埛绫诲瀷
   editUserType() {
-    console.log(44)
     if (!this.data.visible) {
       this.setData({
         visible: true,
@@ -261,6 +263,37 @@
     this.setData({
       visible: e.detail.visible,
     });
+  },
+  tabUserTypeClick(e) {
+    console.log(e)
+    let { info } = e.currentTarget.dataset;
+    this.setData({
+      userTypeActive: info.value,
+    });
+  },
+  submit() {
+    let userTypeInfo = {
+      requests: [
+        {
+          data: JSON.stringify({ userType: this.data.userTypeActive }),
+          name: '鐢ㄦ埛绫诲瀷',
+          type: 'userType'
+        }
+      ]
+    }
+    app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => {
+      if (res) {
+        wx.showToast({
+          title: "淇敼鎴愬姛",
+          icon: 'success',
+          duration: 1000,
+        })
+        this.getUserInfo()
+        this.setData({
+          visible: false,
+        });
+      }
+    })
   },
   //璁剧疆
   gotoUserEditPage() {
@@ -286,14 +319,16 @@
     }
   },
 
+  onPageScroll(e) {
+    this.setData({
+      isWhite: e.scrollTop > 20 ? true : false
+    })
+  },
+
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
   onShareAppMessage() {
 
   },
-  //璺宠浆鍏充簬鎴戜滑鍜岃仈绯绘垜浠�
-  onAboutUS() {
-    console.log(111);
-  }
 })
\ No newline at end of file

--
Gitblit v1.9.1