aiInspectionDetail.js
3.93 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
// packageEquity/pages/aiInspectionDetail/aiInspectionDetail.js
import carLifeApi from '../../carEquityApi'
Page({
/**
* 页面的初始数据
*/
data: {
overviewList: [{
title: '话术评分',
key: 'score'
},
{
title: '预计营销结果',
key: 'estimatedResult',
fontSize: 'var(--fontSize28)'
},
{
title: '开始录音时间',
key: 'startTime'
},
{
title: '对话时长',
key: '_duration'
}
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.$router.getData(res => {
if (!res.estimatedResult) res.estimatedResult = '未知'
if (res.startTime) res.startTime = res.startTime.match(/\b\d{2}:\d{2}:\d{2}\b/)[0]
if (res.duration) res._duration = this.formatTime(res.duration)
this.setData({
detailInfo: res
})
this.getInspectionDetail(res.id)
})
},
setCopyData(e) {
console.log(e)
// let {
// content
// } = e.currentTarget.dataset
const { detailInfo } = this.data,
receptionStatus = {
1: '成交',
0: '战败'
}[detailInfo.receptionStatus],
{ customerName, startTime, duration, fileUrl, createdDate } = detailInfo
// 客户姓名 - 接待开始时间 - 接待时长 - 员工标记的接待结果 - 接待录音mp3地址
let text = [customerName, wx.$util.tsFormatTime(createdDate, 'Y年M月D日'), startTime, this.formatTime(duration), receptionStatus, fileUrl].join(' - ')
wx.$util.setCopyData(text)
// wx.$util.showToast('复制成功')
},
async getInspectionDetail(batchId) {
try {
wx.$util.showLoading()
const {
code,
data: {
list
},
message
} = await carLifeApi.getInspectionDetail({
batchId,
pageSize: 99999
})
if (code == 0 && list) {
let titleList = Array.from(new Set([...list.map(e => e.firstClassify)]))
const classifyList = titleList.map(i => {
let arr = [],
rawScore = 0,
score = 0
list.map(e => {
if (i == e.firstClassify) {
arr.push(e)
rawScore += e.rawScore
score += e.score
}
e.suggestions = e.suggestions.replace(/<\/br>/g, '\n')
e.hitText = e.hitText && e.hitText.replace(/<\/br>/g, '\n')
})
return {
list: arr,
title: i,
rawScore,
score,
}
})
console.log(classifyList)
this.setData({
list: classifyList
})
wx.hideLoading()
} else throw message
} catch (error) {
wx.hideLoading()
wx.$util.showToast(error)
}
},
formatTime(seconds) {
seconds = Math.floor(seconds / 1000)
let formattedTime = ''
if (seconds < 60) return seconds + '秒'
else {
let hours = Math.floor(seconds / 3600),
minutes = Math.floor((seconds % 3600) / 60),
remainingSeconds = seconds % 60
if (hours > 0) formattedTime += hours + '小时'
if (minutes > 0 || hours > 0) formattedTime += minutes + '分'
if (remainingSeconds > 0) formattedTime += remainingSeconds + '秒'
return formattedTime
}
},
jump(e) {
const {
item
} = e.currentTarget.dataset
wx.$router.go('aiInspectionReception', item)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})