| | |
| | | const app = getApp() |
| | | const menuData = [ |
| | | { |
| | | const app = getApp(); |
| | | import moment from 'moment' |
| | | import { |
| | | loginInfo |
| | | } from '../../assets/js/login'; |
| | | const menuData = [{ |
| | | title: '我的订单', |
| | | icon: '/static/images/personal/order.png', |
| | | url: '/packagePersonal/pages/myOrder/index', |
| | |
| | | { |
| | | title: '我的证书', |
| | | icon: '/static/images/personal/certificate.png', |
| | | url: '', |
| | | url: '/pages/personalCenter/certificate/index', |
| | | type: 'certificate', |
| | | }, |
| | | { |
| | |
| | | type: 'publishBooks', |
| | | } |
| | | ]; |
| | | const moreMenu = [ |
| | | { |
| | | const moreMenu = [{ |
| | | title: '我的消息', |
| | | icon: '/static/images/personal/notification.png', |
| | | url: '/packagePersonal/pages/myMassage/index', |
| | |
| | | type: 'feedback', |
| | | } |
| | | ]; |
| | | const moreMenu1 = [ |
| | | { |
| | | const moreMenu1 = [{ |
| | | title: '关于我们', |
| | | icon: '/static/images/personal/about.png', |
| | | url: '/packagePersonal/pages/aboutUs/index?types=jsek_aboutUs', |
| | |
| | | type: 'contact', |
| | | } |
| | | ]; |
| | | const userTypeList = [ |
| | | { |
| | | const userTypeList = [{ |
| | | lable: '中职教师', |
| | | value: 'vocSchoolTeachers' |
| | | }, |
| | |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | scoll: false, |
| | | isWhite: false, |
| | | userInfo: {}, |
| | | currAuthStep: 1, |
| | |
| | | moreMenu, |
| | | moreMenu1, |
| | | visible: false, |
| | | baseRefresh: { |
| | | value: false |
| | | }, |
| | | loadingProps: { |
| | | size: '10rpx', |
| | | }, |
| | | scrollTop: 0, |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | 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 { |
| | | this.setData({ |
| | | currAuthStep: 3, |
| | | }); |
| | | this.getUserInfo() |
| | | this.getIntegral() |
| | | } |
| | | }, |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | this.setData({ |
| | | 'baseRefresh.value': true, |
| | | }) |
| | | this.getUserInfo() |
| | | this.getIntegral() |
| | | wx.stopPullDownRefresh() |
| | | }, |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | }, |
| | | onReachBottom() {}, |
| | | // 获取登录用户身份 |
| | | getUserInfo() { |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | |
| | | 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, |
| | | 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, |
| | |
| | | } 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); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | }); |
| | | }, |
| | | tabUserTypeClick(e) { |
| | | console.log(e) |
| | | let { info } = e.currentTarget.dataset; |
| | | let { |
| | | info |
| | | } = e.currentTarget.dataset; |
| | | this.setData({ |
| | | userTypeActive: info.value, |
| | | }); |
| | | }, |
| | | submit() { |
| | | let userTypeInfo = { |
| | | requests: [ |
| | | { |
| | | data: JSON.stringify({ userType: this.data.userTypeActive }), |
| | | name: '用户类型', |
| | | type: 'userType' |
| | | } |
| | | ] |
| | | requests: [{ |
| | | data: JSON.stringify({ |
| | | userType: this.data.userTypeActive |
| | | }), |
| | | name: '用户类型', |
| | | type: 'userType' |
| | | }] |
| | | } |
| | | app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => { |
| | | if (res) { |
| | |
| | | }); |
| | | }, |
| | | |
| | | getIntegral() { |
| | | app.MG.store |
| | | .getUserWallet({ |
| | | type: 'integral' |
| | | }) |
| | | .then((res) => { |
| | | this.setData({ |
| | | integral: res.balance, |
| | | }); |
| | | }) |
| | | }, |
| | | getIntegralList() { |
| | | wx.navigateTo({ |
| | | url: `/pages/personalCenter/pointsRecord/index`, |
| | | }); |
| | | |
| | | }, |
| | | |
| | | |
| | | //点击目录 |
| | | toPages(item) { |
| | | console.log(item) |
| | | let info = item.currentTarget.dataset.info |
| | | if (info.url) { |
| | | wx.navigateTo({ |
| | |
| | | } |
| | | }, |
| | | |
| | | onPageScroll(e) { |
| | | 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.scrollTop > 20 ? true : false |
| | | isWhite: data |
| | | }) |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |