messageDetail.vue
7.51 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
337
338
339
340
341
342
343
<template>
<view class="detail-box">
<view class="nav-bar">
<view v-if="messageInfo.status == 1" class="back" @click="backArrow">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">优秀话术-{{ messageInfo.sceneLabelName }}</view>
</view>
<view class="weekly-tips">
<view :class="['outstanding-tip-item', messageInfo.status == 1 ? 'single' : 'read']">
<view class="tip-header">
<!-- <view class="tip-rank">优秀话术-{{ messageInfo.className }}</view> -->
<view class="tip-time">{{ messageInfo.time }}</view>
<view v-if="messageInfo.excellentLabelName" class="tip-tags">{{ messageInfo.excellentLabelName }}</view>
</view>
<view class="tip-content">
{{ messageInfo.polishContent }}
</view>
</view>
<view class="detail-footer">
<template v-if="messageInfo.status == 0">
<view class="tips">以上内容请认真阅读,至少读完{{ countTime }}分钟,如未按照要求阅读完内容,今日无法使用pad接待</view>
<view :class="['btn', !countFlag ? '' : 'blue']" @click="handleCompleted">已完成阅读 {{ !countFlag ?
`${countdown}s` :
'' }}</view>
</template>
<template v-if="pageType == 'service' && messageInfo.status == 1">
<view class="btn blue more-script" @click="handleMoreScript">更多话术</view>
</template>
</view>
</view>
</view>
</template>
<script>
let timer = null
let countTimer = 1
import dayjs from 'dayjs'
export default {
name: 'MessageDetail',
data() {
return {
recordDetailList: [],
classCountList: [],
countdown: 5,
countFlag: false,
messageInfo: {},
tagIndex: '',
enterTime: '',
isProcessing: false,
MOCKDATA: {},
countTime: 0,
pageType: ''
}
},
computed: {
onlyOneLength() {
return this.recordDetailList.length == 1
},
},
created() {
// 获取mock配置的时间
this.MOCKDATA = uni.$storage.get('mock_data')
this.countTime = this.MOCKDATA.timer || countTimer
// this.countTime = 0.1
this.countdown = this.countTime * 60 - 1
},
onLoad(options) {
console.log(options)
const { row } = options
// 开始倒计时
this.startCountdown()
// 进入埋点的时间
this.enterTime = dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
this.messageInfo = JSON.parse(row)
this.pageType = options.type
},
beforeDestroy() {
if (timer) {
clearInterval(timer);
}
},
// inject: ['showPage'],
methods: {
async backArrow() {
const idList = [this.messageInfo.scriptId]
// 埋点
await uni.$api.commonApi.extractExcellent({
scriptIdList: idList,
startTime: this.enterTime,
endTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
})
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 100
})
},
// 返回
// back(idList = null) {
// console.log(idList)
// // this.showPage(name, obj)
// // if (idList) uni.$emit('pageList', idList[0]);
// uni.navigateBack({
// delta: 1,
// animationType: 'pop-out',
// animationDuration: 100
// })
// },
async backPage(scriptId = null, ids = null) {
let idList = scriptId
if (!idList) {
idList = [this.messageInfo.scriptId];
}
// 埋点
await uni.$api.commonApi.extractExcellent({
scriptIdList: idList,
startTime: this.enterTime,
endTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
})
// if (ids) {
// this.back(ids)
// } else {
uni.redirectTo({
url: '/pages/common/messageList'
});
// }
// if (type == 'read') this.$emit("backHome")
// else if (type == 'view') this.back('MessageList', {firstIndex: 1})
// this.back('MessageList', {firstIndex: 1, tagIndex: this.tagIndex})
},
// 开始倒计时
startCountdown() {
timer = setInterval(() => {
if (this.countdown > 0) {
this.countdown--;
} else {
this.countFlag = true
clearInterval(timer);
}
}, 1000);
},
// 点击已完成按钮
async handleCompleted() {
if (this.isProcessing) return;
console.log(this.countFlag)
let scriptId = null
if (this.countFlag) {
let idList
idList = [this.messageInfo.id];
scriptId = [this.messageInfo.scriptId]
try {
this.isProcessing = true;
// 接口调用
const res = await uni.$api.commonApi.updateMessageStatus({
idList
})
} catch (error) {
// this.backPage(scriptId, idList)
console.error('更新消息状态时出现错误:', error)
} finally {
this.isProcessing = false; // 处理完成,将标志位设为 false
this.backPage(scriptId)
}
}
},
handleMoreScript() {
uni.redirectTo({
url: '/pages/common/messageList?type=more',
fail: (err) => {
console.error('页面跳转失败:', err);
}
});
}
}
}
</script>
<style scoped lang="scss">
.detail-box {
position: relative;
width: 100vw;
height: 100vh;
background-image: url('@/assets/images/common/page-bg.webp');
background-size: 100%;
box-sizing: border-box;
padding-top: toRpx(160);
}
.nav-bar {
position: fixed;
width: 100%;
height: toRpx(96);
left: 0;
top: toRpx(48);
z-index: 999;
pointer-events: none;
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
pointer-events: auto;
}
.title {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
}
}
.weekly-tips {
position: relative;
margin: 0 toRpx(64) toRpx(80);
background-color: rgba(255, 255, 255, 0.35);
border: toRpx(4) solid #fff;
border-radius: toRpx(48);
height: calc(100% - #{toRpx(80)});
padding-top: toRpx(40);
.tips-title {
display: flex;
font-size: toRpx(36);
font-weight: 500;
padding: 0 toRpx(64) toRpx(40);
.tips-tags {
display: flex;
color: #4673FF;
.tags-separator {
margin: 0 toRpx(10);
}
}
}
.outstanding-tip-list {
height: calc(100% - #{toRpx(348)});
}
.outstanding-tip-item {
width: calc(100% - #{toRpx(128)});
padding: toRpx(24) toRpx(32);
border-radius: toRpx(16);
background-color: #fff;
margin: 0 toRpx(64) toRpx(40);
&.long {
height: 100%;
}
&.single {
height: calc(100% - #{toRpx(40)});
}
&.read {
height: calc(100% - #{toRpx(216)});
}
.tip-header {
display: flex;
align-items: center;
.tip-rank {
color: #333;
font-size: toRpx(32);
font-weight: 500;
line-height: toRpx(44);
margin-right: toRpx(24);
}
.tip-time {
color: rgba(102, 102, 102, 0.6);
font-size: toRpx(28);
line-height: toRpx(44);
}
.tip-tags {
border-radius: toRpx(4);
background: rgba(255, 157, 10, 0.1);
padding: toRpx(8) toRpx(24);
color: #ff9d0a;
font-size: toRpx(24);
font-weight: 500;
margin-left: toRpx(24);
}
}
.tip-content {
margin-top: toRpx(17);
color: #666;
font-size: toRpx(28);
line-height: toRpx(48);
}
}
.detail-footer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
bottom: toRpx(32);
left: 50%;
transform: translateX(-50%);
width: 100%;
}
.tips {
color: #ff9d0a;
font-size: toRpx(32);
margin-bottom: toRpx(32);
}
.btn {
width: toRpx(720);
height: toRpx(80);
border-radius: toRpx(48);
opacity: 0.4;
border: toRpx(2) solid #979797;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
color: #fff;
font-size: toRpx(32);
line-height: toRpx(80);
text-align: center;
opacity: 0.4;
&.blue {
opacity: 1;
}
}
.more-script {
margin-bottom: toRpx(48);
}
}
</style>