2025-11-14 11:39:33 +08:00
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<u-navbar :is-back="true" :title="title" :border-bottom="false"></u-navbar>
|
|
|
|
|
<view class="u-content">
|
|
|
|
|
<u-parse :html="content"
|
|
|
|
|
:autosetTitle="true"
|
|
|
|
|
:show-with-animation="true"
|
|
|
|
|
:selectable="true"></u-parse>
|
|
|
|
|
</view>
|
2026-06-24 16:15:44 +08:00
|
|
|
<u-swiper :list="imgList" v-if="imgList.length"></u-swiper>
|
|
|
|
|
<view class="attachment-section" v-if="attachmentList.length">
|
|
|
|
|
<view class="section-title">
|
|
|
|
|
<text class="title-icon">📎</text>
|
|
|
|
|
<text>附件下载</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="attachment-item" v-for="(item,index) in attachmentList" :key="index" @tap="download(item)">
|
|
|
|
|
<view class="file-info">
|
|
|
|
|
<text class="file-icon">📄</text>
|
|
|
|
|
<text class="file-name">{{ item.fileName || '附件' + (index + 1) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<text class="download-btn">下载</text>
|
|
|
|
|
</view>
|
2026-01-30 09:01:38 +08:00
|
|
|
</view>
|
2025-11-14 11:39:33 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2026-01-15 17:18:24 +08:00
|
|
|
id:null,
|
2025-11-14 11:39:33 +08:00
|
|
|
title:'资讯',
|
2026-01-30 09:01:38 +08:00
|
|
|
content: ``,
|
|
|
|
|
imgList:[],
|
|
|
|
|
attachments:[]
|
2025-11-14 11:39:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad(option) {
|
2026-01-15 17:18:24 +08:00
|
|
|
this.id = option.id
|
|
|
|
|
this.getDetail()
|
2025-11-14 11:39:33 +08:00
|
|
|
},
|
2026-05-14 14:42:51 +08:00
|
|
|
onShow(){
|
|
|
|
|
this.recordView(this.id)
|
|
|
|
|
},
|
2026-06-24 16:15:44 +08:00
|
|
|
computed: {
|
|
|
|
|
attachmentList() {
|
|
|
|
|
return this.attachments || []
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-01-15 17:18:24 +08:00
|
|
|
methods:{
|
2026-05-14 14:42:51 +08:00
|
|
|
recordView(assetId) {
|
|
|
|
|
let token = this.$getToken()
|
2026-06-24 16:15:44 +08:00
|
|
|
let userInfo = uni.getStorageSync('userInfo')
|
|
|
|
|
if (!token) {
|
2026-05-14 14:42:51 +08:00
|
|
|
return
|
|
|
|
|
}
|
2026-06-24 16:15:44 +08:00
|
|
|
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)
|
|
|
|
|
})
|
2026-05-14 14:42:51 +08:00
|
|
|
},
|
2026-01-15 17:18:24 +08:00
|
|
|
getDetail(){
|
2026-05-14 14:42:51 +08:00
|
|
|
this.$u.get(`/notice/detail?id=${this.id}`,{},{}).then(res=>{
|
2026-01-15 17:18:24 +08:00
|
|
|
if(res.flag) {
|
|
|
|
|
this.title = res.data.noticeTitle;
|
|
|
|
|
this.content = res.data.noticeContent;
|
2026-01-30 09:01:38 +08:00
|
|
|
if(res.data.imgs) {
|
|
|
|
|
const _this = this;
|
|
|
|
|
res.data.imgs.forEach(img=>{
|
|
|
|
|
_this.imgList.push(_this.$config.staticUrl + img)
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-06-24 16:15:44 +08:00
|
|
|
if(res.data.attachments) {
|
|
|
|
|
this.attachments = res.data.attachments;
|
|
|
|
|
}
|
2026-05-14 14:42:51 +08:00
|
|
|
this.recordView(this.id)
|
2026-01-15 17:18:24 +08:00
|
|
|
}
|
|
|
|
|
})
|
2026-01-30 09:01:38 +08:00
|
|
|
},
|
|
|
|
|
download(item){
|
2026-06-24 16:15:44 +08:00
|
|
|
const url = this.$config.staticUrl + item.fileUrl
|
|
|
|
|
console.log('下载地址:', url)
|
|
|
|
|
uni.showLoading({ title: '下载中...' })
|
2026-01-30 09:01:38 +08:00
|
|
|
uni.downloadFile({
|
2026-06-24 16:15:44 +08:00
|
|
|
url: url,
|
2026-01-30 09:01:38 +08:00
|
|
|
success(res) {
|
2026-06-24 16:15:44 +08:00
|
|
|
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' })
|
2026-01-30 09:01:38 +08:00
|
|
|
}
|
|
|
|
|
})
|
2026-01-15 17:18:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-11-14 11:39:33 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
page{
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.u-content{
|
|
|
|
|
margin:0 10rpx;
|
|
|
|
|
padding: 24rpx;
|
|
|
|
|
font-size: 34rpx;
|
|
|
|
|
color: $u-main-color;
|
|
|
|
|
line-height: 1.8;
|
|
|
|
|
white-space: pre-wrap !important;
|
|
|
|
|
}
|
2026-06-24 16:15:44 +08:00
|
|
|
|
|
|
|
|
.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;
|
|
|
|
|
}
|
2025-11-14 11:39:33 +08:00
|
|
|
</style>
|
|
|
|
|
|