From abe464066e3b72f49f130f7dec92fb4a4a0a8bf4 Mon Sep 17 00:00:00 2001
From: RuicyWu <1063154311@qq.com>
Date: Wed, 24 Jun 2026 16:15:44 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=99=84=E4=BB=B6=E6=B8=B2?=
=?UTF-8?q?=E6=9F=93=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages-biz/notice/noticeDetail.vue | 166 +++++++++++++++++++++++++-----
1 file changed, 142 insertions(+), 24 deletions(-)
diff --git a/pages-biz/notice/noticeDetail.vue b/pages-biz/notice/noticeDetail.vue
index e67fcbf..05129b1 100644
--- a/pages-biz/notice/noticeDetail.vue
+++ b/pages-biz/notice/noticeDetail.vue
@@ -7,9 +7,19 @@
:show-with-animation="true"
:selectable="true">
-
-
- {{ item.fileName }}
+
+
+
+ 📎
+ 附件下载
+
+
+
+ 📄
+ {{ item.fileName || '附件' + (index + 1) }}
+
+ 下载
+
@@ -32,27 +42,30 @@
onShow(){
this.recordView(this.id)
},
+ computed: {
+ attachmentList() {
+ return this.attachments || []
+ }
+ },
methods:{
recordView(assetId) {
let token = this.$getToken()
- let userInfo = uni.getStorageSync('userInfo')
- if(token){
+ let userInfo = uni.getStorageSync('userInfo')
+ if (!token) {
return
}
- if (token) {
- let url = "/potential/add";
- this.$u.get(url, {
- assetId: this.id,
- assetsName: '查看公告' + this.title,
- userType: userInfo.userType
- }, {
- 'WT': this.$getToken()
- }).then(obj => {
-
- }).catch(err => {
- console.log("记录客户浏览记录失败", err)
- })
- }
+ let url = "/potential/add";
+ this.$u.get(url, {
+ assetId: this.id,
+ assetsName: '查看公告' + this.title,
+ userType: userInfo.userType
+ }, {
+ 'WT': token
+ }).then(() => {
+
+ }).catch(err => {
+ console.log("记录客户浏览记录失败", err)
+ })
},
getDetail(){
this.$u.get(`/notice/detail?id=${this.id}`,{},{}).then(res=>{
@@ -65,18 +78,56 @@
_this.imgList.push(_this.$config.staticUrl + img)
})
}
- this.attachments = res.data.attachments;
+ if(res.data.attachments) {
+ this.attachments = res.data.attachments;
+ }
this.recordView(this.id)
}
})
},
download(item){
+ const url = this.$config.staticUrl + item.fileUrl
+ console.log('下载地址:', url)
+ uni.showLoading({ title: '下载中...' })
uni.downloadFile({
- url: this.$config.staticUrl + item.fileUrl,
+ url: url,
success(res) {
- uni.openDocument({
- filePath: res.tempFilePath
- })
+ console.log('下载结果:', res)
+ uni.hideLoading()
+ if (res.statusCode === 200) {
+ // 保存文件到本地
+ uni.saveFile({
+ tempFilePath: res.tempFilePath,
+ success(saveRes) {
+ uni.showModal({
+ title: '下载成功',
+ content: '文件已保存,是否打开?',
+ success(modalRes) {
+ if (modalRes.confirm) {
+ uni.openDocument({
+ filePath: saveRes.savedFilePath,
+ fail(err) {
+ console.log('打开文件失败:', err)
+ uni.showToast({ title: '无法打开此类型文件', icon: 'none' })
+ }
+ })
+ }
+ }
+ })
+ },
+ fail(err) {
+ console.log('保存文件失败:', err)
+ uni.showToast({ title: '保存失败', icon: 'none' })
+ }
+ })
+ } else {
+ uni.showToast({ title: '下载失败', icon: 'none' })
+ }
+ },
+ fail(err) {
+ console.log('下载失败:', err)
+ uni.hideLoading()
+ uni.showToast({ title: '下载失败', icon: 'none' })
}
})
}
@@ -98,5 +149,72 @@
line-height: 1.8;
white-space: pre-wrap !important;
}
+
+ .attachment-section {
+ margin: 20rpx 24rpx;
+ padding: 24rpx;
+ background-color: #f8f9fa;
+ border-radius: 16rpx;
+ }
+
+ .section-title {
+ display: flex;
+ align-items: center;
+ margin-bottom: 20rpx;
+ font-size: 30rpx;
+ font-weight: 600;
+ color: #333;
+ }
+
+ .title-icon {
+ margin-right: 10rpx;
+ }
+
+ .attachment-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 20rpx 24rpx;
+ margin-bottom: 16rpx;
+ background-color: #fff;
+ border-radius: 12rpx;
+ box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
+
+ &:last-child {
+ margin-bottom: 0;
+ }
+
+ &:active {
+ background-color: #f0f0f0;
+ }
+ }
+
+ .file-info {
+ display: flex;
+ align-items: center;
+ flex: 1;
+ }
+
+ .file-icon {
+ margin-right: 16rpx;
+ font-size: 36rpx;
+ }
+
+ .file-name {
+ font-size: 28rpx;
+ color: #333;
+ flex: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .download-btn {
+ padding: 10rpx 24rpx;
+ font-size: 24rpx;
+ color: #fff;
+ background-color: #e74c3c;
+ border-radius: 8rpx;
+ }