From a6e9a6511aa289ea16da6623d63bef133906c2e1 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期四, 28 三月 2024 14:20:44 +0800
Subject: [PATCH] geren

---
 pages/personalCenter/index.js |   84 ++++++++++++++++++++++-------------------
 1 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js
index 190cc96..0d20c2e 100644
--- a/pages/personalCenter/index.js
+++ b/pages/personalCenter/index.js
@@ -1,6 +1,8 @@
-const app = getApp()
-const menuData = [
-  {
+const app = getApp();
+import {
+  loginInfo
+} from '../../assets/js/login';
+const menuData = [{
     title: '鎴戠殑璁㈠崟',
     icon: '/static/images/personal/order.png',
     url: '/packagePersonal/pages/myOrder/index',
@@ -49,8 +51,7 @@
     type: 'publishBooks',
   }
 ];
-const moreMenu = [
-  {
+const moreMenu = [{
     title: '鎴戠殑娑堟伅',
     icon: '/static/images/personal/notification.png',
     url: '/packagePersonal/pages/myMassage/index',
@@ -63,8 +64,7 @@
     type: 'feedback',
   }
 ];
-const moreMenu1 = [
-  {
+const moreMenu1 = [{
     title: '鍏充簬鎴戜滑',
     icon: '/static/images/personal/about.png',
     url: '/packagePersonal/pages/aboutUs/index?types=jsek_aboutUs',
@@ -77,8 +77,7 @@
     type: 'contact',
   }
 ];
-const userTypeList = [
-  {
+const userTypeList = [{
     lable: '涓亴鏁欏笀',
     value: 'vocSchoolTeachers'
   },
@@ -119,7 +118,11 @@
     visible: false,
     baseRefresh: {
       value: false
-    }
+    },
+    loadingProps: {
+      size: '50rpx',
+    },
+    scrollTop: 0,
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -132,18 +135,22 @@
       barHeight: systInfo.statusBarHeight,
       navBarHeight: navBarHeight,
     });
-    if (wx.getStorageSync(app.config.tokenKey)) {
-      this.setData({
-        currAuthStep: 2,
-      });
-      this.getUserInfo()
+    // 妫�鏌ョ櫥褰曠姸鎬�
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.setData({
+            currAuthStep: 2,
+          });
+          this.getUserInfo()
+        }
+      })
     } else {
       this.setData({
         currAuthStep: 1,
       });
-      wx.navigateTo({
-        url: "/pages/testLogin/index",
-      });
+      this.getUserInfo()
     }
   },
   onShow() {
@@ -165,8 +172,7 @@
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
-  onReachBottom() {
-  },
+  onReachBottom() {},
   // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
   getUserInfo() {
     app.MG.identity.getCurrentAppUser().then(res => {
@@ -181,18 +187,17 @@
           });
           type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
         } else {
-          type = '-'
+          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')
         let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
         if (teacherRole && teacherInfos) {
           defaultUser = {
             ...teacherInfos,
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name,
+            nickName: teacherInfos.name,
             icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
             userId: res.userId,
             role: 'Teacher',
@@ -215,14 +220,6 @@
           this.setData({
             currAuthStep: 3,
           });
-        } else if (secretData) {
-          defaultUser = {
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : "",
-            userId: res.userId,
-            userType: type,
-            role: 'Student',
-          }
         }
         this.setData({
           userInfo: defaultUser
@@ -281,20 +278,22 @@
     });
   },
   tabUserTypeClick(e) {
-    let { info } = e.currentTarget.dataset;
+    let {
+      info
+    } = e.currentTarget.dataset;
     this.setData({
       userTypeActive: info.value,
     });
   },
   submit() {
     let userTypeInfo = {
-      requests: [
-        {
-          data: JSON.stringify({ userType: this.data.userTypeActive }),
-          name: '鐢ㄦ埛绫诲瀷',
-          type: 'userType'
-        }
-      ]
+      requests: [{
+        data: JSON.stringify({
+          userType: this.data.userTypeActive
+        }),
+        name: '鐢ㄦ埛绫诲瀷',
+        type: 'userType'
+      }]
     }
     app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => {
       if (res) {
@@ -337,8 +336,15 @@
     this.setData({
       isWhite: e.detail.scrollTop > 10 ? true : false
     })
+    const {
+      scrollTop
+    } = e.detail;
+    this.setData({
+      scrollTop
+    });
   },
 
+
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */

--
Gitblit v1.9.1