message-detail.vue
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<template>
<view class="page" :style="vuex_theme">
<view class="content">
<view class="t1">
{{detailObj.title}}
</view>
<view class="dv">
<view class="tag">
{{type[detailObj.type]}}
</view>
<view class="time">
{{$u.timeFrom(detailObj.sendTime)}}
</view>
</view>
</view>
<view style="background-color: #F7F7F7; width: 100%; height: 10px;"></view>
<view class="tip">
<view class="ggxq">
公告详情
</view>
<view class="green-line"></view>
</view>
<view class="desc">
<!-- {{detailObj.content}} -->
<u-parse :tagStyle="parsestyle" :content="detailObj.content"></u-parse>
</view>
<view class="fj">
附件
</view>
<view class="greenbg" v-for="(item,index) in attachmentsFile" :key="index" @click="openLink(item.response)">
<image v-if="item.response.mime_type.indexOf('image') != -1" src="/static/img/message/icon_img.png" style="width: 60rpx;height: 60rpx;"></image>
<image v-else src="/static/img/message/icon_file.png" style="width: 60rpx;height: 60rpx;"></image>
<view class="name">
{{item.response.filename}}
</view>
</view>
</view>
</template>
<script>
import {
msgdetailUrl,
getImgUrlApi
} from '@/config/api.js';
export default {
data() {
return {
id: '',
detailObj: {},
type: {
system: '系统公告',
inform: '通知公告',
safety_rules: '安全条例',
vital_document: '重要文件'
},
parsestyle: {
p: 'color: rgba(0,0,0,0.85);font-size:28rpx;font-family: PingFangSC-Light, PingFang SC;',
},
attachmentsFile: [],
}
},
onLoad(e) {
this.id = e.id
msgdetailUrl(this.id).then(res => {
if (res) {
this.detailObj = res
if (this.detailObj.attachments) {
this.attachmentsFile = JSON.parse(this.detailObj.attachments)
}
}
})
},
methods: {
openLink(e) {
var _this = this
uni.showLoading({
title: '努力加载中~',
mask: true
})
if (e.mime_type.indexOf("image") != -1) {
_this.openImage(`${this.vuex_ossUrlPubilc}/${e.object}`)
} else {
let type = ''
if (e.object.substring(e.object.lastIndexOf(".")+1) == 'xlsx') {
type = 'xlsx'
}else if (e.object.substring(e.object.lastIndexOf(".")+1) == 'pdf') {
type = 'pdf'
}else if (e.object.substring(e.object.lastIndexOf(".")+1) == 'docx') {
type = 'docx'
}else if (e.object.substring(e.object.lastIndexOf(".")+1) == 'doc') {
type = 'doc'
}else if (e.object.substring(e.object.lastIndexOf(".")+1) == 'xls') {
type = 'xls'
}
uni.downloadFile({
url: `${this.vuex_ossUrlPubilc}/${e.object}`,
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
fileType: type,
success: function(res) {
console.log('打开文档成功');
},
fail(e) {
console.log('打开文档error', e);
},
complete: function() {
uni.hideLoading();
}
});
}
});
}
// this.$u.api.getImgUrl({
// bucket: e.bucket,
// filePath: e.object
// }).then(data => {
// console.log("data...", data)
// if (e.mime_type.indexOf("image") != -1) {
// _this.openImage(data.url)
// } else {
// uni.downloadFile({
// url: data.url,
// success: function(res) {
// var filePath = res.tempFilePath;
// uni.openDocument({
// filePath: filePath,
// showMenu: true,
// success: function(res) {
// console.log('打开文档成功');
// },
// fail(e) {
// console.log('打开文档error',e);
// },
// complete: function() {
// uni.hideLoading();
// }
// });
// }
// });
// }
// })
},
openImage(imgPath) {
let array = new Array(1).fill(imgPath);
uni.previewImage({
urls: array,
success(res) {
uni.hideLoading();
console.log('openImage success');
},
fail(res) {
uni.hideLoading();
console.log('openImage fail:', res);
}
});
},
}
}
</script>
<style lang="scss" scoped>
.page {
.content {
padding: 25px 16px;
.t1 {
font-size: 20px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.dv {
margin-top: 8px;
display: flex;
justify-content: space-between;
.tag {
display: inline-block;
padding: 5px;
background: rgba(12,177,122,0.06);
border-radius: 2px;
font-size: 11px;
font-family: PingFangSC-Light, PingFang SC;
font-weight: 300;
color: var(--primary-color);
}
.time {
font-size: 14px;
font-family: PingFangSC-Light, PingFang SC;
font-weight: 300;
color: rgba(0,0,0,0.45);
}
}
}
.tip {
padding: 30px 16px 0;
border-bottom: 0.5px solid #E5E5E6;
.ggxq {
font-size: 16px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.green-line {
margin-top: 12px;
margin-left: 12px;
width: 40px;
height: 4px;
background: linear-gradient(270deg, #26B961 0%, #26B961 100%);
}
}
.desc {
margin: 20px 16px 0;
// font-size: 14px;
// font-family: PingFangSC-Regular, PingFang SC;
// font-weight: 400;
// color: rgba(0,0,0,0.65);
}
.fj {
margin: 30px 16px 0;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #000000;
}
.greenbg {
margin: 40rpx 32rpx 0;
display: flex;
align-items: center;
// width: 100%;
height: 68px;
background: rgba(12,177,122,0.03);
border-radius: 8px;
padding: 0 40rpx;
.name {
margin-left: 8px;
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #000000;
}
}
}
</style>