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 |  190 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 136 insertions(+), 54 deletions(-)

diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js
index e7c30db..1cfeaa4 100644
--- a/pages/personalCenter/index.js
+++ b/pages/personalCenter/index.js
@@ -3,13 +3,13 @@
   {
     title: '鎴戠殑璁㈠崟',
     icon: '/static/images/personal/order.png',
-    url: '/pages/personalCenter/myOrder/index',
+    url: '/packagePersonal/pages/myOrder/index',
     type: 'order',
   },
   {
     title: '婵�娲诲晢鍝�',
     icon: '/static/images/personal/jihuo.png',
-    url: '/pages/personalCenter/activateProduct/index',
+    url: '/packagePersonal/pages/activateProduct/index',
     type: 'activateProduct',
   },
   {
@@ -21,19 +21,19 @@
   {
     title: '鎴戠殑鏀惰棌',
     icon: '/static/images/personal/wodeshoucang.png',
-    url: '/pages/personalCenter/myCollection/index',
+    url: '/packagePersonal/pages/myCollection/index',
     type: 'collection',
   },
   {
     title: '鎴戠殑涓嬭浇',
     icon: '/static/images/personal/download.png',
-    url: '/pages/personalCenter/downloads/index',
+    url: '/packagePersonal/pages/downloads/index',
     type: 'download',
   },
   {
     title: '鏍蜂功鐢宠',
     icon: '/static/images/personal/yangshushenqing.png',
-    url: '/pages/personalCenter/sampleBooks/index',
+    url: '/packagePersonal/pages/sampleBooks/index',
     type: 'sampleBook',
   },
   {
@@ -45,7 +45,7 @@
   {
     title: '鍑轰功鐢宠',
     icon: '/static/images/personal/chushu.png',
-    url: '/pages/personalCenter/publishBooks/index',
+    url: '/packagePersonal/pages/publishBooks/index',
     type: 'publishBooks',
   }
 ];
@@ -53,13 +53,13 @@
   {
     title: '鎴戠殑娑堟伅',
     icon: '/static/images/personal/notification.png',
-    url: '/pages/personalCenter/myMassage/index',
+    url: '/packagePersonal/pages/myMassage/index',
     type: 'message',
   },
   {
     title: '寤鸿涓庡弽棣�',
     icon: '/static/images/personal/feedback.png',
-    url: '/pages/personalCenter/feedBack/index',
+    url: '/packagePersonal/pages/feedBack/index',
     type: 'feedback',
   }
 ];
@@ -67,14 +67,32 @@
   {
     title: '鍏充簬鎴戜滑',
     icon: '/static/images/personal/about.png',
-    url: '/pages/aboutUs/index',
+    url: '/packagePersonal/pages/aboutUs/index?types=jsek_aboutUs',
     type: 'aboutUs',
   },
   {
     title: '鑱旂郴鎴戜滑',
     icon: '/static/images/personal/contact.png',
-    url: '',
+    url: '/packagePersonal/pages/aboutUs/index?types=jsek_contactUs',
     type: 'contact',
+  }
+];
+const userTypeList = [
+  {
+    lable: '涓亴鏁欏笀',
+    value: 'vocSchoolTeachers'
+  },
+  {
+    lable: '楂樿亴鏁欏笀',
+    value: 'vocCollegeTeachers'
+  },
+  {
+    lable: '鏅�氶珮鏍℃暀甯�',
+    value: 'ordUniversityTeachers'
+  },
+  {
+    lable: '鍏朵粬璇昏��',
+    value: 'otherReaders'
   }
 ];
 Page({
@@ -83,15 +101,13 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   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({
@@ -178,7 +246,24 @@
   //鏁欏笀璁よ瘉
   toCertification() {
     wx.navigateTo({
-      url: "/pages/teacherCertification/index",
+      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",
     });
   },
 
@@ -205,11 +290,8 @@
   onShareAppMessage() {
 
   },
-
-  onPageScroll(e) {
-    this.setData({
-      isWhite: e.scrollTop > 50 ? true : false
-    })
-
+  //璺宠浆鍏充簬鎴戜滑鍜岃仈绯绘垜浠�
+  onAboutUS() {
+    console.log(111);
   }
 })
\ No newline at end of file

--
Gitblit v1.9.1