From 4bc1c36faeec2f90e5acfa836732e49fe0b245e9 Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期五, 12 四月 2024 20:47:03 +0800 Subject: [PATCH] 云学习11 --- pages/personalCenter/index.js | 84 ++++++++++++++++++++++++++---------------- 1 files changed, 52 insertions(+), 32 deletions(-) diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index a6682bd..c756a91 100644 --- a/pages/personalCenter/index.js +++ b/pages/personalCenter/index.js @@ -1,4 +1,7 @@ -const app = getApp() +const app = getApp(); +import { + loginInfo +} from '../../assets/js/login'; const menuData = [{ title: '鎴戠殑璁㈠崟', icon: '/static/images/personal/order.png', @@ -44,7 +47,7 @@ { title: '鍑轰功鐢宠', icon: '/static/images/personal/chushu.png', - url: '/packagePersonal/pages/publishBooks/index', + url: '', type: 'publishBooks', } ]; @@ -99,6 +102,7 @@ data: { barHeight: '', navBarHeight: '', + scoll: false, isWhite: false, userInfo: {}, currAuthStep: 1, @@ -132,25 +136,30 @@ barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, }); - if (wx.getStorageSync(app.config.tokenKey)) { - this.setData({ - currAuthStep: 2, - }); - this.getUserInfo() - } else { - this.setData({ - currAuthStep: 1, - }); - wx.navigateTo({ - url: "/pages/testLogin/index", - }); - } + }, onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ active: 4 }) + } + // 妫�鏌ョ櫥褰曠姸鎬� + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.setData({ + currAuthStep: 2, + }); + this.getUserInfo() + } + }) + } else { + this.setData({ + currAuthStep: 3, + }); + this.getUserInfo() } }, /** @@ -178,21 +187,21 @@ 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 = '-' + 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"); + let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword') if (teacherRole && teacherInfos) { defaultUser = { ...teacherInfos, - nickName: nickNameData ? JSON.parse(nickNameData.data).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, @@ -205,8 +214,8 @@ } 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', @@ -216,12 +225,15 @@ }); } else if (secretData) { defaultUser = { - nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential, - icon: nickNameData ? JSON.parse(nickNameData.data).icon : "", + 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, - role: 'Student', } + this.setData({ + currAuthStep: 3, + }); } this.setData({ userInfo: defaultUser @@ -335,15 +347,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