From 10db09788d74b441a2efd85f5d4614e944b07bb3 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 26 三月 2024 20:07:11 +0800 Subject: [PATCH] 问题修改 --- pages/personalCenter/index.js | 261 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 200 insertions(+), 61 deletions(-) diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index 2c1760e..190cc96 100644 --- a/pages/personalCenter/index.js +++ b/pages/personalCenter/index.js @@ -3,63 +3,63 @@ { 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', }, { title: '鎴戠殑璇佷功', icon: '/static/images/personal/certificate.png', - url: '/pages/personalCenter/certificate/index', + url: '', type: 'certificate', }, { 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', - }, - { - title: '鍑轰功鐢宠', - icon: '/static/images/personal/chushu.png', - url: '/pages/personalCenter/publishBooks/index', - type: 'publishBooks', }, { title: '鎴戠殑涓婁紶', icon: '/static/images/personal/upload.png', url: '', type: 'upload', + }, + { + title: '鍑轰功鐢宠', + icon: '/static/images/personal/chushu.png', + url: '/packagePersonal/pages/publishBooks/index', + type: 'publishBooks', } ]; const moreMenu = [ { 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: '', + 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,127 @@ integral: 0, menuData, moreMenu, - moreMenu1 + moreMenu1, + visible: false, + baseRefresh: { + value: 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() { + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + active: 4 + }) + } }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { - this.init(); + this.setData({ + 'baseRefresh.value': true, + }) + 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.setData({ + userTypeActive: JSON.parse(userTypeData.data).userType, + }); + type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable; + } else { + 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, + icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '', + userId: res.userId, + role: 'Teacher', + roleId: teacherRole.role.id, + userType: type + } + this.setData({ + currAuthStep: 2, + }); + + } else if (WeChatInfo) { + defaultUser = { + ...WeChatInfo, + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name, + icon: nickNameData ? 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 : secretData.credential, + icon: nickNameData ? JSON.parse(nickNameData.data).icon : "", + userId: res.userId, + userType: type, + role: 'Student', + } + } + this.setData({ + userInfo: defaultUser + }) + this.getTeacherInfo() + wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); + setTimeout(() => { + this.setData({ + 'baseRefresh.value': false, + }) + }, 500); + } + }); }, //鏁欏笀淇℃伅 getTeacherInfo() { @@ -163,7 +250,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({ @@ -175,10 +261,64 @@ } }) }, + //鏁欏笀璁よ瘉 + toCertification() { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + }, + //淇敼鐢ㄦ埛绫诲瀷 + editUserType() { + if (!this.data.visible) { + this.setData({ + visible: true, + }); + } + }, + onVisibleChange(e) { + this.setData({ + visible: e.detail.visible, + }); + }, + tabUserTypeClick(e) { + let { info } = e.currentTarget.dataset; + this.setData({ + userTypeActive: info.value, + }); + }, + submit() { + let userTypeInfo = { + requests: [ + { + data: JSON.stringify({ userType: this.data.userTypeActive }), + name: '鐢ㄦ埛绫诲瀷', + type: 'userType' + } + ] + } + app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => { + if (res) { + wx.showToast({ + title: "淇敼鎴愬姛", + icon: 'success', + duration: 1000, + }) + this.getUserInfo() + this.setData({ + visible: false, + }); + } + }) + }, + //璁剧疆 + gotoUserEditPage() { + wx.navigateTo({ + url: "/packagePersonal/pages/userSetting/index", + }); + }, //鐐瑰嚮鐩綍 toPages(item) { - console.log(item) let info = item.currentTarget.dataset.info if (info.url) { wx.navigateTo({ @@ -193,17 +333,16 @@ } }, + onScroll(e) { + this.setData({ + isWhite: e.detail.scrollTop > 10 ? true : false + }) + }, + /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ onShareAppMessage() { }, - - onPageScroll(e) { - this.setData({ - isWhite: e.scrollTop > 50 ? true : false - }) - - } }) \ No newline at end of file -- Gitblit v1.9.1