// pages/resourceDetails/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { navBarHeight: '', barHeight: '', tabPanelstyle: 'display:flex;justify-content:center;align-items:center;', activeValues: [0], dialogKey: true, style: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx;', activeId: '', bookId: '', bookName: '', cmsId: '', parentName: '', parentProductLinkPath: '', productLinkPath: '', threeLeveData: [], showData: '', src: '', selectedId: null, topicId: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(this.data.dialogKey, 'dialogKey'); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 this.setData({ navBarHeight: navBarHeight, barHeight: systInfo.statusBarHeight, activeId: options.activeId, bookId: options.bookId, bookName: options.bookName, cmsId: options.cmsId, parentName: options.parentName, parentProductLinkPath: options.parentProductLinkPath, productLinkPath: options.productLinkPath }) console.log(this.data.parentProductLinkPath, 'parentProductLinkPath'); this.resourceDetailsData() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, onTabsChange(event) { }, onTabsClick(event) { }, handleChange(e) { this.setData({ activeValues: e.detail.value, }); }, onTakeNotes() { }, showDialog(e) { const { key } = e.currentTarget.dataset; this.setData({ [key]: true, dialogKey: key }); }, closeDialog() { this.setData({ dialogKey: false }); }, goBack() { wx.navigateBack(); }, resourceDetailsData() { let query = { path: '*', queryType: '*', productId: this.data.bookId, cmsPath: this.data.parentProductLinkPath, itemFields: { SysType: 'CmsFolder', // 资源类型,试读文件,是否允许下载等参数 selectType: [], freeFile: [], file: [], protectedFile: [], resourcesClassification: [], isDownload: [], jsek_resourceBrief: [], jsek_link: [], jsek_questionBank: [], learnSelectType: [] }, pading: { start: 0, size: 999 } } app.MG.store.getProductDetail(query).then(res => { console.log(res, 'res'); const list = [] res.datas.cmsDatas[0].datas.forEach((item) => { this.data.threeLeveData.push(item) list.push(item) this.setData({ threeLeveData: list }) if (this.data.productLinkPath == item.productLinkPath) { console.log(item, 'item'); this.setData({ showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file }) } // console.log(this.data.threeLeveData, 'threeLeveData'); }) }) }, onVideo(e) { this.setData({ selectedId: e.currentTarget.dataset.index, }) // console.log(e); const item = e.currentTarget.dataset.item // console.log(item); if (item.selectType == "video") { console.log(item.file); this.setData({ showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file }) console.log(this.data.showData); } else { console.log(app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file); } }, getProductUserSubmitTopicGet() { app.MG.ugc.getProductUserSubmitTopic({ productId: this.data.bookId, appRefCode: app.config.appRefCode }).then((res) => { console.log(res); this.setData({ topicId: res.id }) }) }, newTopicMessageGet() { let query = { topicIdOrRefCode: topicId + '', name: titleText.value, content: form.value.noteContent, type: 'note', cmsTypeRefCode: '', newDataListRequest: [] } app.MG.ugc.newTopicMessage(query).then(res => { console.log(res); }) }, // currentTarget onConfirm() { console.log(1111); }, onCancellation() { console.log(222); this.data.dialogKey = false } })