dataDetail.vue
5.4 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
<template>
<div>
<nav-bar class="navbar">
<div slot="left" @click="goBack" class="back">
<img src="../../assets/img/back.png" alt="" />
</div>
<div slot="right" class="back" @click="faved">
<img v-if="detail.is_favorite==1" src="../../assets/img/faved1.png" alt="" />
<img v-else src="../../assets/img/iconly-线性轮廓化Light-outline-Star@2x.png" alt="" />
</div>
</nav-bar>
<div class="classDetail">
<div class="classDetail_title">{{ detail.name }}</div>
<video v-if="detail.video" controls
id="videodetail"
:src="detail.video"
autoplay ref="video"
></video>
<div class="classDetail_content" v-html="detail.content"></div>
</div>
<div class="fileone" v-for="(item,index) in detail.new_file" :key="index">
<div class="display-flex">
<img v-if="item.type=='xlsx'||item.type=='xls'" src="../../assets/img/xlsx.png" alt="">
<img v-if="item.type=='pdf'" src="../../assets/img/Frame@2x (13).png" alt="">
<img v-if="item.type=='docx'||item.type=='doc'" src="../../assets/img/word.png" alt="">
<img v-if="item.type=='ppt'||item.type=='pptx'" src="../../assets/img/ppt.png" alt="">
<div>{{item.name}}</div>
</div>
<!-- <div @click="tourl1(item.url)">预览office</div> -->
<div class="looker" @click="tourl(item.url,item.type)">预览</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {
ifdo: true,
string: '',
name: '',
images: '',
id: '',
detail: ''
}
},
created () {
this.id = this.$route.query.id
this.details()
},
methods: {
tourl (href, type) {
if (type === 'pdf') {
this.$router.push({
path: '/openPdf',
query: {
src: href
}
})
// window.open(href)
} else {
window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(href))
}
},
tourl1 (url) {
window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(url))
},
goBack () {
this.$router.go(-1)
},
async faved () {
const params = {
type: 1,
favorite_id: this.id
}
const res = await this.api.deletelist(params)
if (res.code === 1) {
this.$toast(res.msg)
this.details()
}
},
// 文本课程详情
async details () {
const params = {
id: this.id
}
const reslist = await this.api.datadetail(params)
if (reslist.code === 1) {
const result = reslist.data.detail
result.new_file.forEach(item => {
const index = item.url.lastIndexOf('.')
const ext = item.url.substr(index + 1)
item.type = ext
})
this.detail = result
this.$refs.video.play()
} else {
this.$toast(reslist.msg)
}
}
},
mounted () {
setTimeout(() => {
this.ifdo = false
}, this.time)
}
}
</script>
<style lang="scss" scoped>
.navbar{
position: fixed;
top: 0;
background: #fff;
z-index: 9;
}
.classDetail video{
width: 100%;
height: 4.2rem;
}
.back{
width: 0.5rem;
font-size: 0.48rem;
}
.back img{
width: 0.48rem;
height: 0.48rem;
}
.classDetail{
width: 100%;
height: auto;
padding: 0 0.32rem;
box-sizing: border-box;
margin:1rem 0 0.48rem;
}
.classDetail_title{
color: rgba(50,50,51,1);
font-size: 0.34rem;
font-weight: 600;
font-family: "PingFang SC";
text-align: left;
line-height: 0.52rem;
letter-spacing: 0.01rem;
margin-bottom: 0.32rem;
}
.classDetail_content{
color: rgba(50,50,51,1);
font-size: 0.28rem;
font-weight: 400;
font-family: "PingFang SC";
text-align: left;
line-height: 0.48rem;
}
::v-deep img {
width: 100% !important;
}
.classDetail_button{
position: fixed;
bottom: 0.32rem;
left: 50%;
transform: translate(-50%,0);
}
.classDetail_button{
width: 6.86rem;
height: 0.88rem;
opacity: 1;
background: rgba(37.19,124.31,255,1);
line-height: 0.88rem;
color: #fff;
font-size:0.32rem;
text-align: center;
}
.opacity{
opacity: 0.5;
}
.fileone{
width: 90%;
margin: 0 auto 0.32rem;
padding: 0.32rem;
box-sizing: border-box;
height: 1.8rem;
border-radius: 0.08rem;
background: rgba(255,255,255,1);
border: 0.01rem solid #eee;
color: rgba(50,50,51,1);
font-size: 0.28rem;
font-weight: 400;
}
.fileone img{
width: 0.48rem !important;
height: 0.48rem;
margin-right: 0.16rem;
}
.looker{
width: 1.18rem;
height: 0.56rem;
border-radius: 0.08rem;
background: rgb(205, 223, 248);
color:#257CFF;
text-align: center;
line-height: 0.56rem;
font-size: 0.24rem;
font-weight: 500;
float: right;
}
</style>