From 04c7b0163caeae4ab1c5da62e301fa993101cfad Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 31 三月 2025 10:40:45 +0800 Subject: [PATCH] bug修改 --- pages/personalCenter/index.js | 156 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 120 insertions(+), 36 deletions(-) diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index a6682bd..341ca0e 100644 --- a/pages/personalCenter/index.js +++ b/pages/personalCenter/index.js @@ -1,4 +1,8 @@ -const app = getApp() +const app = getApp(); +import moment from 'moment' +import { + loginInfo +} from '../../assets/js/login'; const menuData = [{ title: '鎴戠殑璁㈠崟', icon: '/static/images/personal/order.png', @@ -14,7 +18,8 @@ { title: '鎴戠殑璇佷功', icon: '/static/images/personal/certificate.png', - url: '', + // url: '', + url: '/pages/personalCenter/certificate/index', type: 'certificate', }, { @@ -38,14 +43,28 @@ { title: '鎴戠殑涓婁紶', icon: '/static/images/personal/upload.png', - url: '', + // url: '', + url: '/pages/personalCenter/myUpload/index', type: 'upload', }, { title: '鍑轰功鐢宠', icon: '/static/images/personal/chushu.png', + // url: '', url: '/packagePersonal/pages/publishBooks/index', type: 'publishBooks', + }, + { + title: '鎴戠殑璇剧▼', + icon: '/static/images/personal/course.png', + url: '/packageCourse/pages/course/index', + type: 'course', + }, + { + title: '鎴戠殑鐝骇', + icon: '/static/images/personal/class.png', + url: '/packageCourse/pages/studentClass/index', + type: 'class', } ]; const moreMenu = [{ @@ -99,6 +118,7 @@ data: { barHeight: '', navBarHeight: '', + scoll: false, isWhite: false, userInfo: {}, currAuthStep: 1, @@ -117,7 +137,7 @@ value: false }, loadingProps: { - size: '50rpx', + size: '10rpx', }, scrollTop: 0, }, @@ -132,25 +152,36 @@ 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() + this.getIntegral() + } else { + wx.switchTab({ + url: '/pages/home/home', + }) + } + }) + } else { + this.setData({ + currAuthStep: 3, + }); + this.getUserInfo() + this.getIntegral() } }, /** @@ -161,6 +192,8 @@ 'baseRefresh.value': true, }) this.getUserInfo() + this.getIntegral() + wx.stopPullDownRefresh() }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� @@ -178,21 +211,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 +238,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,16 +249,32 @@ }); } 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 }) + if (defaultUser?.role == 'Teacher') { + const data = [...this.data.menuData] + const list = data.filter(item => item.type != 'class') + this.setData({ + menuData: list + }) + } else { + const data = [...this.data.menuData] + const list = data.filter(item => item.type != 'course') + this.setData({ + menuData: list + }) + } this.getTeacherInfo() wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); setTimeout(() => { @@ -318,6 +367,25 @@ }); }, + getIntegral() { + app.MG.store + .getUserWallet({ + type: 'integral' + }) + .then((res) => { + this.setData({ + integral: res.balance, + }); + }) + }, + getIntegralList() { + wx.navigateTo({ + url: `/pages/personalCenter/pointsRecord/index`, + }); + + }, + + //鐐瑰嚮鐩綍 toPages(item) { let info = item.currentTarget.dataset.info @@ -335,17 +403,33 @@ }, onScroll(e) { - this.setData({ - isWhite: e.detail.scrollTop > 10 ? true : false - }) - const { - scrollTop - } = e.detail; - this.setData({ - scrollTop - }); + 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: data + }) + }, + // delectBtn() { + // app.MG.ugc + // .delTopicMessage({ + // messageIds: [2986, 1302, 1301, 3074, 1305, 1304] + // }) + // .then((res) => { + // console.log('鍒犻櫎鎴愬姛') + // }) + // }, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� -- Gitblit v1.9.1