detail.vue
8.6 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<template>
<view class="main">
<view class="toptitle">
<view class="toptitle_left" @click="ht">
<u-icon name="arrow-left" color="#fff" size="20"></u-icon>
</view>
<view class="toptitle_title">
培训详情
</view>
</view>
<view class="" style="padding: 10px;background-color: #fff;border-radius: 5px;margin-bottom: 15px;">
<u-subsection :list="list" fontSize="14" activeColor="#0052D8" :current="current" @change='change'></u-subsection>
</view>
<view class="box" v-if="current == 0">
<view class="tips">
<view class="tip">
</view>
<view class="tiptitle">
基础资料
</view>
</view>
<view class="box_item">
<view class="f1">培训名</view>
<view class="f2">{{info.sbmc}}</view>
</view>
<view class="box_item" style="display: flex;flex-direction: column;align-items: flex-start;">
<view class="f1" style="margin-bottom: 15px;">培训简介</view>
<view class="f2" v-html="info.jj"></view>
</view>
<view class="box_item" style="display: flex;flex-direction: column;align-items: flex-start;">
<view class="f1" style="margin-bottom: 15px;">培训视频</view>
<view v-if="videoList.length === 0" class="f2">暂无视频</view>
<view v-else style="width: 100%;">
<view v-for="item in videoList" :key="item.url" style="margin-bottom: 16px;">
<video :src="fullUrl(item.url)" controls style="width: 100%; height: 200px;"></video>
<!-- <view class="f2" style="margin-top: 8px;">{{item.name}}</view> -->
</view>
</view>
</view>
</view>
<view class="box1" v-if="current == 1">
<view class="tips">
<view class="tip">
</view>
<view class="tiptitle">
相关资料
</view>
</view>
<view class="box_item1" v-for="item in filteredFj1">
<view class="left">
<view class="left_image">
<image v-if="item.type == 'pdf'" src='../../../static/PDF.png' mode=""></image>
<image v-if="item.type == 'doc' || item.type == 'docx'" src='../../../static/WORD.png' mode=""></image>
<image v-if="item.type == 'xlsx' || item.type == 'xls'" src='../../../static/WORD.png' mode=""></image>
<image v-if="item.type == 'png' || item.type == 'jpg' || item.type == 'jpeg'" src='../../../static/img/picture.png' mode=""></image>
<u-icon v-if="isVideoType(item.type)" name="play-circle-fill" color="#0052D8" size="40"></u-icon>
</view>
<view class="l_title">
<view class="l_title_f1">
{{item.name}}
</view>
<view class="l_title_f2">
2024-11-13 12:09:21
</view>
</view>
</view>
<view class="right" @click="ylwj(item.url,item.type)">
<u-button size="small" type="primary" text="查看"></u-button>
</view>
</view>
</view>
</view>
</template>
<script>
import viewRecordMixin from '@/common/mixins/viewRecordMixin.js'
export default {
mixins: [viewRecordMixin],
data() {
return {
list: ['基础资料', '相关资料'],
current: 0,
info:{}
}
},
computed: {
videoList() {
const videos = ['mp4','mov','avi','wmv','mkv','webm','mpeg'];
return Array.isArray(this.info.fj1) ? this.info.fj1.filter(it => videos.includes((it.type || '').toLowerCase())) : [];
},
filteredFj1() {
const allowed = ['pdf','doc','docx','xls','xlsx','png','jpg','jpeg'];
return Array.isArray(this.info.fj1) ? this.info.fj1.filter(it => allowed.includes((it.type || '').toLowerCase())) : [];
}
},
onLoad() {
var info = JSON.parse(uni.getStorageSync("detail") || '{}')
if (!info || !info.id) {
uni.showToast({ title: '缺少培训信息', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1500)
return
}
this.pxzsxqs(info)
},
methods: {
pxzsxqs(data){
this.API.pxzsxq({ id: data.id }).then(res=>{
if (res && res.data) {
if(res.data.fj1 && res.data.fj1.length > 0){
for(let i = 0;i < res.data.fj1.length;i++)(
res.data.fj1[i].type = res.data.fj1[i].url.substring(res.data.fj1[i].url.lastIndexOf('.') + 1)
)
}
this.info = res.data
this.startViewTracking(this.info.id || data.id, '培训展示', this.info.pxmc, this.info.sbmc)
}
}).catch(err => {
uni.showToast({ title: err.msg || err.message || '无权限查看或加载失败', icon: 'none' })
setTimeout(() => uni.navigateBack(), 1500)
})
},
change(e){
this.current = e
},
ht(){
uni.navigateBack({
delta: 1
});
},
cktp() {
uni.previewImage({
urls: ["http://115.29.210.249/tggPic/content/2021-09/1630475389708.jpg"], //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
current: '', // 当前显示图片的http链接,默认是第一个
})
},
fullUrl(url){
return 'https://hhjj.antissoft.com' + url;
},
// 判断是否为视频类型
isVideoType(type) {
const videoTypes = ['mp4', 'mov', 'avi', 'wmv', 'mkv', 'webm', 'mpeg', 'mpg', 'flv', '3gp'];
return videoTypes.includes((type || '').toLowerCase());
},
// 判断是否为图片类型
isImageType(type) {
const imageTypes = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp'];
return imageTypes.includes((type || '').toLowerCase());
},
// 判断是否为PDF类型
isPdfType(type) {
return (type || '').toLowerCase() === 'pdf';
},
// 统一文件预览方法(在线预览,不支持下载)
ylwj(url, type) {
const fileUrl = 'https://hhjj.antissoft.com' + url;
const fileType = (type || '').toLowerCase();
// 图片预览
if (this.isImageType(fileType)) {
uni.previewImage({
current: 0,
urls: [fileUrl]
});
return;
}
// PDF预览
if (this.isPdfType(fileType)) {
uni.setStorageSync('wjurl', fileUrl);
uni.navigateTo({
url: '/pages/pdf/pdf'
});
return;
}
// 视频预览
if (this.isVideoType(fileType)) {
uni.setStorageSync('videoUrl', fileUrl);
uni.setStorageSync('videoName', '视频');
uni.navigateTo({
url: '/pages/new/zlgl/video-preview'
});
return;
}
// 其他文件类型(Word、Excel等)提示不支持在线预览
uni.showToast({
title: '该文件类型暂不支持在线预览',
icon: 'none',
duration: 2000
});
},
}
}
</script>
<style scoped lang="scss">
.u-subsection--button{
height: 50px;
}
.main {
padding-top: 87px; // 标题栏80px + 间距7px
background-color: #F8F8F8;
min-height: 100vh;
.toptitle{
position: fixed;
top: 0;
left: 0;
right: 0;
width: 100%;
background-color: #0052D8;
display: flex;
height: 80px;
justify-content: center;
align-items: center;
z-index: 200;
.toptitle_left{
padding-top: 20px;
position: absolute;
left: 10px;
z-index: 1000;
}
.toptitle_title{
color: #fff;
font-size: 14px;
padding-top: 20px;
}
}
.title {
padding: 10px;
border-radius: 5px;
margin-bottom: 10px;
background-color: #fff;
}
.box {
border-radius: 5px;
margin-bottom: 10px;
background-color: #fff;
.tips{
display: flex;
align-items: center;
margin-bottom: 10px;
border-bottom: 1px solid #E9E9E9;
padding: 15px 10px;
.tip{
width: 7px;
height: 20px;
background-color: #0052D8;
margin-right: 10px;
}
.tiptitle{
font-size: 17px;
}
}
.box_item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 20px;
margin-bottom: 20px;
// border-bottom: 1px dashed #ccc;
.f1 {
font-size: 12px;
}
.f2{
color:#969696;
font-size: 16px;
}
.f3{
color: #38beff;
border-bottom: 1px solid #38beff;
}
}
}
.box1{
background-color: #fff;
.tips{
display: flex;
align-items: center;
margin-bottom: 10px;
border-bottom: 1px solid #E9E9E9;
padding: 15px 10px;
.tip{
width: 7px;
height: 20px;
background-color: #0052D8;
margin-right: 10px;
}
.tiptitle{
font-size: 17px;
}
}
.box_item1{
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.left{
display: flex;
align-items: center;
.left_image{
margin-right: 15px;
image{
width: 40px;
height: 40px;
}
}
.l_title{
}
}
}
}
}
/* 修复样式块,恢复 .l_title 内部子元素样式 */
.l_title{
.l_title_f1{
font-size: 15px;
margin-bottom: 5px;
width: 50vw;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.l_title_f2{
font-size: 13px;
color: #969696;
}
}
</style>