/** * 守法学习材料的获取和打开 */ module.exports = Behavior({ data: { }, methods: { /** * 守法学习材料内容跳转 */ openFile(e) { var index = e.currentTarget.dataset.index let f = this.data.results[index] var url = "" switch (f.lrResourcefiletype) { //文档 case 1: let bodyUrl = f.lrBodyurl wx.showLoading({ title: ' 加载中', mask: true, }) wx.downloadFile({ url: bodyUrl, success: function (res) { wx.hideLoading() const filePath = res.tempFilePath wx.openDocument({ filePath: filePath, success: function (res) { console.log('打开文档成功') }, fail(error) { console.log(error); } }) } }) break; //链接 case 2: url = "" break; //图片 case 3: url = "" break; //视频 case 4: url = "/pages/mLearn/pLearnvideo/pLearnvideo" break; } if (url != "") { wx.navigateTo({ url: url, success: (res) => { res.eventChannel.emit('acceptDataFromOpenerPage', f) }, }) } }, } })