| | |
| | | type: 'contact', |
| | | } |
| | | ]; |
| | | const userTypeList = [ |
| | | { |
| | | lable: '中职教师', |
| | | value: 'vocSchoolTeachers' |
| | | }, |
| | | { |
| | | lable: '高职教师', |
| | | value: 'vocCollegeTeachers' |
| | | }, |
| | | { |
| | | lable: '普通高校教师', |
| | | value: 'ordUniversityTeachers' |
| | | }, |
| | | { |
| | | lable: '其他读者', |
| | | value: 'otherReaders' |
| | | } |
| | | ]; |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | 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: '', |
| | |
| | | integral: 0, |
| | | menuData, |
| | | moreMenu, |
| | | moreMenu1 |
| | | moreMenu1, |
| | | visible: 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中list数组的索引 |
| | | }) |
| | | } |
| | | this.getTeacherInfo() |
| | | currAuthStep: 2, |
| | | }); |
| | | this.getUserInfo() |
| | | } else { |
| | | this.setData({ |
| | | currAuthStep: 1, |
| | | }); |
| | | wx.navigateTo({ |
| | | url: "/pages/testLogin/index", |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | this.setData({ |
| | | show: false |
| | | }) |
| | | onShow() { |
| | | |
| | | }, |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | this.init(); |
| | | 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 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, |
| | | fullName: teacherInfos.fullName, |
| | | icon: teacherInfos.icon, |
| | | userId: res.userId, |
| | | role: 'Teacher', |
| | | roleId: teacherRole.role.id, |
| | | userType: type |
| | | } |
| | | this.setData({ |
| | | currAuthStep: 2, |
| | | }); |
| | | |
| | | } else if (WeChatInfo) { |
| | | defaultUser = { |
| | | ...WeChatInfo, |
| | | fullName: WeChatInfo.name, |
| | | icon: WeChatInfo.icon, |
| | | userId: res.userId, |
| | | userType: type |
| | | } |
| | | this.setData({ |
| | | currAuthStep: 3, |
| | | }); |
| | | } else if (secretData) { |
| | | defaultUser = { |
| | | fullName: secretData.credential, |
| | | icon: "", |
| | | userId: res.userId, |
| | | userType: type |
| | | } |
| | | } |
| | | this.setData({ |
| | | userInfo: defaultUser |
| | | }) |
| | | this.getTeacherInfo() |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); |
| | | } |
| | | }); |
| | | }, |
| | | //教师信息 |
| | | getTeacherInfo() { |
| | |
| | | } |
| | | } |
| | | 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({ |
| | |
| | | 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) { |
| | | console.log(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", |
| | | }); |
| | | }, |
| | | |
| | |
| | | } |
| | | }, |
| | | |
| | | onPageScroll(e) { |
| | | this.setData({ |
| | | isWhite: e.scrollTop > 20 ? true : false |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | |
| | | onPageScroll(e) { |
| | | this.setData({ |
| | | isWhite: e.scrollTop > 50 ? true : false |
| | | }) |
| | | |
| | | }, |
| | | //跳转关于我们和联系我们 |
| | | onAboutUS() { |
| | | console.log(111); |
| | | } |
| | | }) |