From b1bca18120265cfa39041e4707f4e64bb33d5d10 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Fri, 23 Jan 2026 13:25:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.js | 4 +- packages/mycourse/courseStatus.vue | 210 +++++++++++++++++------------ 2 files changed, 128 insertions(+), 86 deletions(-) diff --git a/common/config.js b/common/config.js index f69e14f..4f0fb9f 100644 --- a/common/config.js +++ b/common/config.js @@ -1,7 +1,7 @@ const mode = 'production'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 let ROOTPATH = ''; //域名 -let baseUrl = "https://suzhoukeji-test.ali251.langye.net" -// let baseUrl = "https://wx.sstbc.com" +// let baseUrl = "https://suzhoukeji-test.ali251.langye.net" +let baseUrl = "https://wx.sstbc.com" switch (mode) { case 'devLocal': ROOTPATH = baseUrl diff --git a/packages/mycourse/courseStatus.vue b/packages/mycourse/courseStatus.vue index 3db4a47..c11eda3 100644 --- a/packages/mycourse/courseStatus.vue +++ b/packages/mycourse/courseStatus.vue @@ -3,12 +3,12 @@ - + {{userInfo.username}}: {{info.reason?info.reason:wait_tip}} - + {{userInfo.username}}: @@ -23,26 +23,26 @@ 我要放弃 - + {{userInfo.username}}: {{info.reason?info.reason:fault_tip}} - + {{userInfo.username}}: {{info.reason?info.reason:back_tip}} - - - - {{userInfo.username}}: - {{info.giveup_reason?info.giveup_reason:'您已主动放弃该课程。'}} - - - - {{userInfo.username}}: - 您已取消该课程报名。 + + + + {{userInfo.username}}: + {{info.giveup_reason?info.giveup_reason:'您已主动放弃该课程。'}} + + + + {{userInfo.username}}: + 您已取消该课程报名。 @@ -51,7 +51,7 @@ - 提示 @@ -135,52 +135,94 @@ if (this.base.isNull(this.form.giveup_reason)) { this.base.toast("请输入放弃原因") return - } - this.$u.api.courseUpdateSign({ - id:this.info.id, - giveup_reason:this.form.giveup_reason, - status:5 - }).then(res => { - that.base.toast("已放弃课程", 1500, function() { - that.showCancel = false - setTimeout(function() { - uni.redirectTo({ - url:"/packages/mycourse/index" - }) - }, 1500) - }) + } + this.$u.api.courseUpdateSign({ + id:this.info.id, + giveup_reason:this.form.giveup_reason, + status:5 + }).then(res => { + that.base.toast("已放弃课程", 1500, function() { + that.showCancel = false + setTimeout(function() { + uni.redirectTo({ + url:"/packages/mycourse/index" + }) + }, 1500) + }) }) }, openFiles(files) { console.log("files", files) - let that = this - uni.downloadFile({ - url: files[0].url, - success: function(res) { - if (res.statusCode === 200) { - console.log("临时路径", res.tempFilePath) - let filePath = res.tempFilePath - //调用uni.openDocument打开文件 - uni.openDocument({ - filePath: filePath, - success: function(res) { - console.log("打开文档成功"); - }, - fail: function(res) { - console.log("uni.openDocument,fail"); - console.log(res) - }, - complete: function(res) { - console.log("uni.openDocument,complete"); - console.log(res) - } - }); - } - }, - fail: function(err) { - console.log('文件下载失败', err) - } + if (!files || files.length === 0) { + return + } + + const file = files[0] + const fileUrl = file.url || file.path || '' + + // 判断是否为图片文件 + const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg'] + const isImage = imageExtensions.some(ext => { + const lowerUrl = fileUrl.toLowerCase() + return lowerUrl.includes(ext) || lowerUrl.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg)(\?|$)/i) }) + + if (isImage) { + // 如果是图片,使用预览功能 + const urls = files.map(f => f.url || f.path).filter(Boolean) + uni.previewImage({ + urls: urls, + current: fileUrl, + success: function(res) { + console.log("预览图片成功"); + }, + fail: function(err) { + console.log("预览图片失败", err); + uni.showToast({ + title: '预览图片失败', + icon: 'none' + }) + } + }) + } else { + // 如果是其他文件,下载后打开 + let that = this + uni.downloadFile({ + url: fileUrl, + success: function(res) { + if (res.statusCode === 200) { + console.log("临时路径", res.tempFilePath) + let filePath = res.tempFilePath + //调用uni.openDocument打开文件 + uni.openDocument({ + filePath: filePath, + success: function(res) { + console.log("打开文档成功"); + }, + fail: function(res) { + console.log("uni.openDocument,fail"); + console.log(res) + uni.showToast({ + title: '打开文件失败', + icon: 'none' + }) + }, + complete: function(res) { + console.log("uni.openDocument,complete"); + console.log(res) + } + }); + } + }, + fail: function(err) { + console.log('文件下载失败', err) + uni.showToast({ + title: '文件下载失败', + icon: 'none' + }) + } + }) + } } } @@ -202,34 +244,34 @@ } .slot-content { - padding: 30rpx; - padding-top:20rpx; - &>view{ - padding-top:20rpx; - } - &-title{ - text-align: center; - } - &-tip{ - text-indent: 2em; - } - &-btn{ - display: flex; - align-items: center; - justify-content: space-between; - &>view { - width: 40%; - text-align: center; - margin: 0 auto; - color: #fff; - background: linear-gradient(to right, #5e5fbc, #0d0398); - border-radius: 30rpx; - padding: 10rpx; - } - &>view:first-child{ - background: #ddd; - color:#333 - } + padding: 30rpx; + padding-top:20rpx; + &>view{ + padding-top:20rpx; + } + &-title{ + text-align: center; + } + &-tip{ + text-indent: 2em; + } + &-btn{ + display: flex; + align-items: center; + justify-content: space-between; + &>view { + width: 40%; + text-align: center; + margin: 0 auto; + color: #fff; + background: linear-gradient(to right, #5e5fbc, #0d0398); + border-radius: 30rpx; + padding: 10rpx; + } + &>view:first-child{ + background: #ddd; + color:#333 + } } }