From 366de5b4636679392a1e3d2984fc23bd5eaa5ac3 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 27 八月 2024 17:48:03 +0800
Subject: [PATCH] wenti

---
 pages/personalCenter/index.js |  134 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 113 insertions(+), 21 deletions(-)

diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js
index 0d20c2e..930b345 100644
--- a/pages/personalCenter/index.js
+++ b/pages/personalCenter/index.js
@@ -1,4 +1,5 @@
 const app = getApp();
+import moment from 'moment'
 import {
   loginInfo
 } from '../../assets/js/login';
@@ -102,6 +103,7 @@
   data: {
     barHeight: '',
     navBarHeight: '',
+    scoll: false,
     isWhite: false,
     userInfo: {},
     currAuthStep: 1,
@@ -120,9 +122,11 @@
       value: false
     },
     loadingProps: {
-      size: '50rpx',
+      size: '10rpx',
     },
     scrollTop: 0,
+    visibleIntegral: false,
+    recordList: []
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -135,6 +139,14 @@
       barHeight: systInfo.statusBarHeight,
       navBarHeight: navBarHeight,
     });
+
+  },
+  onShow() {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setData({
+        active: 4
+      })
+    }
     // 妫�鏌ョ櫥褰曠姸鎬�
     const token = wx.getStorageSync(app.config.tokenKey)
     if (!token) {
@@ -144,20 +156,15 @@
             currAuthStep: 2,
           });
           this.getUserInfo()
+          this.getIntegral()
         }
       })
     } else {
       this.setData({
-        currAuthStep: 1,
+        currAuthStep: 3,
       });
       this.getUserInfo()
-    }
-  },
-  onShow() {
-    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-      this.getTabBar().setData({
-        active: 4
-      })
+      this.getIntegral()
     }
   },
   /**
@@ -168,6 +175,8 @@
       'baseRefresh.value': true,
     })
     this.getUserInfo()
+    this.getIntegral()
+    wx.stopPullDownRefresh()
   },
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
@@ -185,7 +194,7 @@
           this.setData({
             userTypeActive: JSON.parse(userTypeData.data).userType,
           });
-          type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
+          type = this.data.userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
         } else {
           type = ''
         }
@@ -194,11 +203,12 @@
         let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
         let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
         let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
+        let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
         if (teacherRole && teacherInfos) {
           defaultUser = {
             ...teacherInfos,
-            nickName: teacherInfos.name,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
+            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo ? WeChatInfo.name : '',
+            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
             userId: res.userId,
             role: 'Teacher',
             roleId: teacherRole.role.id,
@@ -211,11 +221,22 @@
         } else if (WeChatInfo) {
           defaultUser = {
             ...WeChatInfo,
-            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
-            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
+            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
+            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
             userId: res.userId,
             userType: type,
             role: 'Student',
+          }
+          this.setData({
+            currAuthStep: 3,
+          });
+        } else if (secretData) {
+          defaultUser = {
+            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : secretData.credential,
+            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : "",
+            userId: res.userId,
+            role: "Student",
+            userType: type,
           }
           this.setData({
             currAuthStep: 3,
@@ -316,6 +337,69 @@
     });
   },
 
+  getIntegral() {
+    app.MG.store
+      .getUserWallet({
+        type: 'integral'
+      })
+      .then((res) => {
+        this.setData({
+          integral: res.balance,
+        });
+      })
+  },
+  getIntegralList() {
+    app.MG.store
+      .getWalletHistory({
+        Size: 999,
+        Start: 0,
+        sort: {
+          type: 'Desc',
+          field: 'CreateDate'
+        },
+        type: 'integral'
+      })
+      .then((res) => {
+        if (res.datas.length > 0) {
+          res.datas.forEach((element) => {
+            element.createDate = moment(element.createDate).format('YYYY-MM-DD HH:mm:ss')
+            if (element.refType == 'sign') {
+              element.type = '姣忔棩鐧诲綍'
+            }
+            if (element.refType == 'Reward') {
+              element.type = '涓婁紶璧勬簮濂栧姳'
+            }
+            if (element.refType == 'OrderCoinBonus') {
+              element.type = '璁㈠崟鏀粯濂栧姳'
+            }
+            if (element.refType == 'Order' && element.value < 0) {
+              element.type = '璁㈠崟鏀粯鎶垫墸'
+            }
+            if (element.refType == 'Order' && element.value > 0) {
+              element.type = '璁㈠崟鍙栨秷閫�鍥�'
+            }
+            if (element.refType == 'AdminRecharge') {
+              element.type = '绠$悊鍛樺厖鍊�'
+            }
+          })
+          this.setData({
+            recordList: res.datas,
+            visibleIntegral: true
+          });
+        }
+      })
+  },
+  onVisibleIntegralChange(e) {
+    this.setData({
+      visibleIntegral: e.detail.visible,
+    });
+  },
+  onClose() {
+    this.setData({
+      visibleIntegral: false,
+    });
+  },
+
   //鐐瑰嚮鐩綍
   toPages(item) {
     let info = item.currentTarget.dataset.info
@@ -333,15 +417,23 @@
   },
 
   onScroll(e) {
+    if (this.data.scoll) {
+      if (e.detail.scrollTop < 20) {
+        this.data.scoll = false
+        this.isChange(false);
+      }
+    } else {
+      if (e.detail.scrollTop > 20) {
+        this.data.scoll = true
+        this.isChange(true);
+      }
+    }
+  },
+
+  isChange(data) {
     this.setData({
-      isWhite: e.detail.scrollTop > 10 ? true : false
+      isWhite: data
     })
-    const {
-      scrollTop
-    } = e.detail;
-    this.setData({
-      scrollTop
-    });
   },
 
 

--
Gitblit v1.9.1