From 0555dd7dc2edc553030b7a6d03d6a1cda4b1e336 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期三, 20 三月 2024 15:41:58 +0800
Subject: [PATCH] 111

---
 pages/personalCenter/index.js |  166 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 122 insertions(+), 44 deletions(-)

diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js
index cda03ed..1cfeaa4 100644
--- a/pages/personalCenter/index.js
+++ b/pages/personalCenter/index.js
@@ -77,21 +77,37 @@
     type: 'contact',
   }
 ];
+const userTypeList = [
+  {
+    lable: '涓亴鏁欏笀',
+    value: 'vocSchoolTeachers'
+  },
+  {
+    lable: '楂樿亴鏁欏笀',
+    value: 'vocCollegeTeachers'
+  },
+  {
+    lable: '鏅�氶珮鏍℃暀甯�',
+    value: 'ordUniversityTeachers'
+  },
+  {
+    lable: '鍏朵粬璇昏��',
+    value: 'otherReaders'
+  }
+];
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    barHeight: '',
+    navBarHeight: '',
     isWhite: false,
-    show: false,
-    userInfo: {
-      avatarUrl:
-        'https://we-retail-static-1300977798.cos.ap-guangzhou.myqcloud.com/retail-ui/components-exp/avatar/avatar-1.jpg',
-      nickName: 'TDesign',
-      phoneNumber: '13438358888',
-    },
+    userInfo: {},
     currAuthStep: 1,
+    userTypeActive: '',
+    userTypeList,
     teacherState: {
       state: '',
       reasonTxt: '',
@@ -99,56 +115,109 @@
     integral: 0,
     menuData,
     moreMenu,
-    moreMenu1
+    moreMenu1,
+    visible: false,
+
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
-  onLoad(options) {
-    console.log(options);
-  },
-
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
-   */
-  onShow() {
-    if (wx.getStorageSync(app.config.userInfoKey)) {
+  onLoad() {
+    const systInfo = wx.getSystemInfoSync();
+    const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
+    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
+    this.setData({
+      barHeight: systInfo.statusBarHeight,
+      navBarHeight: navBarHeight,
+    });
+    if (wx.getStorageSync(app.config.tokenKey)) {
       this.setData({
-        show: true,
-        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
-      })
-
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({
-          selected: 4 //杩欎釜鏁板瓧鏄綋鍓嶉〉闈㈠湪tabBar涓璴ist鏁扮粍鐨勭储寮�
-        })
-      }
-      this.getTeacherInfo()
+        currAuthStep: 2,
+      });
+      this.getUserInfo()
     } else {
+      this.setData({
+        currAuthStep: 1,
+      });
       wx.navigateTo({
         url: "/pages/testLogin/index",
       });
     }
+
   },
-  /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
- */
-  onHide() {
-    this.setData({
-      show: false
-    })
+  onShow() {
+
   },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
   onPullDownRefresh() {
-    this.init();
+    this.getUserInfo()
   },
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
   onReachBottom() {
+  },
+  // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
+  getUserInfo() {
+    app.MG.identity.getCurrentAppUser().then(res => {
+      // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛�
+      if (res) {
+        //鑾峰彇鐢ㄦ埛绫诲瀷
+        let userTypeData = res.infoList.find((item) => item.type == 'userType')
+        let type = "";
+        if (userTypeData) {
+          this.data.userTypeActive = JSON.parse(userTypeData.data).userType;
+          type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
+        } else {
+          type = '-'
+        }
+        let defaultUser = {};
+        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')
+        let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
+        if (teacherRole && teacherInfos) {
+          defaultUser = {
+            ...teacherInfos,
+            fullName: teacherInfos.fullName,
+            icon: teacherInfos.icon,
+            userId: res.userId,
+            role: 'Teacher',
+            roleId: teacherRole.role.id,
+            userType: type
+          }
+          this.setData({
+            currAuthStep: 2,
+          });
+
+        } else if (WeChatInfo) {
+          defaultUser = {
+            ...WeChatInfo,
+            fullName: WeChatInfo.name,
+            icon: WeChatInfo.icon,
+            userId: res.userId,
+            userType: type
+          }
+          this.setData({
+            currAuthStep: 3,
+          });
+        } else if (secretData) {
+          defaultUser = {
+            fullName: secretData.credential,
+            icon: "",
+            userId: res.userId,
+            userType: type
+          }
+        }
+        this.setData({
+          userInfo: defaultUser
+        })
+        this.getTeacherInfo()
+        wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo));
+      }
+    });
   },
   //鏁欏笀淇℃伅
   getTeacherInfo() {
@@ -163,7 +232,6 @@
       }
     }
     app.MG.ugc.getTopicMessageList(data).then((res) => {
-      console.log(this.data.userInfo, "userInfo")
       const resData = res.datas.find((i) => i.appUserCreator.userId == this.data.userInfo.userId)
       if (resData) {
         this.setData({
@@ -179,6 +247,23 @@
   toCertification() {
     wx.navigateTo({
       url: "/packageDomain/pages/teacherCertification/index",
+    });
+  },
+  //淇敼鐢ㄦ埛绫诲瀷
+  editUserType() {
+    this.setData({
+      visible: true,
+    });
+  },
+  onVisibleChange(e) {
+    this.setData({
+      visible: e.detail.visible,
+    });
+  },
+  //璁剧疆
+  gotoUserEditPage() {
+    wx.navigateTo({
+      url: "/packagePersonal/pages/userSetting/index",
     });
   },
 
@@ -203,13 +288,6 @@
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
   onShareAppMessage() {
-
-  },
-
-  onPageScroll(e) {
-    this.setData({
-      isWhite: e.scrollTop > 50 ? true : false
-    })
 
   },
   //璺宠浆鍏充簬鎴戜滑鍜岃仈绯绘垜浠�

--
Gitblit v1.9.1