| | |
| | | } |
| | | } |
| | | this.onTabsChange(e) |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.getUserInfo() |
| | | } |
| | | }) |
| | | } else { |
| | | this.getUserInfo() |
| | | } |
| | | }, |
| | | |
| | | // 获取登录用户身份 |
| | | getUserInfo() { |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | | // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认) |
| | | if (res) { |
| | | //获取用户类型 |
| | | let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') |
| | | let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') |
| | | let eMailData = res.secretList.find(i => i.type == 'EMail') |
| | | if (eMailData) { |
| | | this.setData({ |
| | | input: eMailData.credential |
| | | }) |
| | | } else if (teacherRole && teacherInfos) { |
| | | this.setData({ |
| | | input: JSON.parse(teacherInfos.data).email |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | input: '' |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | |
| | | } |
| | | }); |
| | | }, |
| | | openBookFair(event) { |
| | | const item = event.currentTarget.dataset.item |
| | | if (item.fileType == "pdf") { |
| | | wx.navigateTo({ |
| | | url: "/packageBookService/pages/components/webView/index?md5=" + |
| | | item.freeFile + |
| | | "&fileName=" + |
| | | item.name + |
| | | "&fileType=" + |
| | | item.fileType + "&bookBuy=true" |
| | | // "&freePage=" + |
| | | // this.data.fileInfo.freePage + |
| | | |
| | | + |
| | | "&bookId=" + |
| | | item.id, |
| | | }); |
| | | } else { |
| | | Toast({ |
| | | context: this, |
| | | selector: '#t-toast', |
| | | message: '此书不能查看', |
| | | theme: 'warning', |
| | | direction: 'column', |
| | | }); |
| | | } |
| | | }, |
| | | onSearchSubmit() { |
| | | this.setData({ |
| | | loading: true, |
| | |
| | | this.setData({ |
| | | [key]: true, |
| | | dialogKey: key, |
| | | input: '', |
| | | Md5: item.datas.freeFile.FileList[0].Md5 |
| | | }); |
| | | }, |