From e2b9cf5cb19ba0ae4bffd787d96f0d0cb8fb63bf Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 09 七月 2024 15:52:58 +0800 Subject: [PATCH] css --- pages/personalCenter/index.js | 166 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 122 insertions(+), 44 deletions(-) diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index 1ecdbf5..b1c172f 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', @@ -45,12 +47,11 @@ { title: '鍑轰功鐢宠', icon: '/static/images/personal/chushu.png', - url: '/packagePersonal/pages/publishBooks/index', + url: '', 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' }, @@ -103,6 +102,7 @@ data: { barHeight: '', navBarHeight: '', + scoll: false, isWhite: false, userInfo: {}, currAuthStep: 1, @@ -117,6 +117,13 @@ moreMenu, moreMenu1, visible: false, + baseRefresh: { + value: false + }, + loadingProps: { + size: '10rpx', + }, + scrollTop: 0, }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -129,35 +136,46 @@ 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() + } }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ onPullDownRefresh() { + this.setData({ + 'baseRefresh.value': true, + }) this.getUserInfo() + wx.stopPullDownRefresh() }, /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - }, + onReachBottom() {}, // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤 getUserInfo() { app.MG.identity.getCurrentAppUser().then(res => { @@ -167,21 +185,24 @@ let userTypeData = res.infoList.find((item) => item.type == 'userType') let type = ""; if (userTypeData) { - this.data.userTypeActive = JSON.parse(userTypeData.data).userType; - type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable; + this.setData({ + userTypeActive: JSON.parse(userTypeData.data).userType, + }); + 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, - fullName: teacherInfos.fullName, - icon: teacherInfos.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, @@ -194,27 +215,37 @@ } else if (WeChatInfo) { defaultUser = { ...WeChatInfo, - fullName: WeChatInfo.name, - 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 + userType: type, + role: 'Student', } this.setData({ currAuthStep: 3, }); } else if (secretData) { defaultUser = { - fullName: secretData.credential, - 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, - userType: type + role: "Student", + userType: type, } + this.setData({ + currAuthStep: 3, + }); } this.setData({ userInfo: defaultUser }) this.getTeacherInfo() wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); + setTimeout(() => { + this.setData({ + 'baseRefresh.value': false, + }) + }, 500); } }); }, @@ -250,7 +281,6 @@ }, //淇敼鐢ㄦ埛绫诲瀷 editUserType() { - console.log(44) if (!this.data.visible) { this.setData({ visible: true, @@ -262,6 +292,38 @@ 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({ @@ -271,7 +333,6 @@ //鐐瑰嚮鐩綍 toPages(item) { - console.log(item) let info = item.currentTarget.dataset.info if (info.url) { wx.navigateTo({ @@ -286,14 +347,31 @@ } }, + 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: data + }) + }, + + /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ onShareAppMessage() { }, - //璺宠浆鍏充簬鎴戜滑鍜岃仈绯绘垜浠� - onAboutUS() { - console.log(111); - } }) \ No newline at end of file -- Gitblit v1.9.1