From f4ed2c4a1412f7256614e04e18683ca15a89bb25 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Wed, 05 Nov 2025 08:58:21 +0800
Subject: [PATCH] 新增
---
pages/tabBar/current/detail.vue | 95 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 81 insertions(+), 14 deletions(-)
diff --git a/pages/tabBar/current/detail.vue b/pages/tabBar/current/detail.vue
index b8807b1..ec9d330 100644
--- a/pages/tabBar/current/detail.vue
+++ b/pages/tabBar/current/detail.vue
@@ -237,22 +237,58 @@
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,
@@ -262,29 +298,60 @@
}
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(){
--
Gitblit v1.9.2