| | |
| | | this.detail = res.data |
| | | this.showDetail = true |
| | | if(this.detail.resourceType == 1){ |
| | | wx.showLoading({ |
| | | title: '课程获取中...', |
| | | mask: true |
| | | }) |
| | | this.$nextTick(() => { |
| | | // this.videoUrl = this.videoBaseUrl + this.detail.resourcePath |
| | | if (!this.detail.resourcePath) { |
| | | wx.hideLoading() |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: '文件路径不存在', |
| | | duration: 2000 |
| | | }) |
| | | return |
| | | } |
| | | this.videoUrl = this.detail.resourcePath |
| | | this.moduleKey++ |
| | | this.$nextTick(() => { |
| | | if(isClick == true){ |
| | | wx.hideLoading() |
| | | uni.createVideoContext('myVideo', this).play(); |
| | | } |
| | | wx.hideLoading() |
| | | }) |
| | | }) |
| | | wx.hideLoading() |
| | | }else{ |
| | | const t = this |
| | | uni.downloadFile({ |
| | | url: this.detail.resourcePath, |
| | | // url: 'http://106.15.95.149:8056/api/images/20250718/00571736c0c741e895318c2edd8a3f9d.PDF', |
| | | wx.showLoading({ |
| | | title: '课程获取中...', |
| | | mask: true |
| | | }) |
| | | if (!t.detail.resourcePath) { |
| | | wx.hideLoading() |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: '文件路径不存在', |
| | | duration: 2000 |
| | | }) |
| | | return |
| | | } |
| | | wx.downloadFile({ |
| | | url: t.detail.resourcePath, |
| | | success: function (res) { |
| | | if (res.statusCode !== 200 || !res.tempFilePath) { |
| | | wx.hideLoading() |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: '文件下载失败', |
| | | duration: 2000 |
| | | }) |
| | | return |
| | | } |
| | | const data = { |
| | | chapterId: chapterId, |
| | | courseId: courseId, |
| | |
| | | } |
| | | postNewStudy(data).then(re=>{ |
| | | if(re.code == 200){ |
| | | this.studyId = re.data |
| | | this.handleUpdate(3) |
| | | t.studyId = re.data |
| | | t.handleUpdate(3) |
| | | }else{ |
| | | uni.$u.toast(res.message) |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | duration: 2000, |
| | | position: 'top', |
| | | title: `${res.message}` |
| | | }); |
| | | } |
| | | }) |
| | | }).catch(err => { |
| | | console.error('学习记录提交失败:', err) |
| | | }) |
| | | var filePath = res.tempFilePath |
| | | uni.openDocument({ |
| | | wx.openDocument({ |
| | | filePath: filePath, |
| | | showMenu: true, |
| | | success: function (res) { |
| | | console.log('打开文档成功'); |
| | | } |
| | | wx.hideLoading() |
| | | }, |
| | | fail: function(res){ |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | duration: 2000, |
| | | position: 'top', |
| | | title: `打开文件失败: ${res.errMsg || '未知错误'}` |
| | | }); |
| | | wx.hideLoading() |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | fail: function(res){ |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | duration: 2000, |
| | | position: 'top', |
| | | title: `下载失败: ${res.errMsg || '网络错误'}` |
| | | }); |
| | | wx.hideLoading() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }else{ |
| | | uni.$u.toast(res.message) |
| | | } |
| | | }) |
| | | |
| | | }).catch(err => { |
| | | console.error('获取课程详情失败:', err) |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: '网络请求失败', |
| | | duration: 2000 |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | goBack(){ |