index.js
4.16 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
// pages/reception/index.js
import dayjs from 'dayjs'
Page({
/**
* 页面的初始数据
*/
data: {
list: [],
tips: '今日无待处理复盘,请继续保持!'
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {},
async getAiagent(params) {
let {
bussinessType,
staffUuid,
phone,
channelType,
modelType
} = params, {
reviewDate
} = this.options
const [data] = await wx.p.api.receptionApi.getAiagent({
ownerShipType: 1,
accountPhone: phone,
agentCode: 'AI8'
})
if (data) {
let {
agentUrl,
domainName,
taskStatus
} = data,
brand = {
1: '问界',
2: '比亚迪',
3: '其他'
} [channelType],
AIAvatar = 'https://img01.glsx.com.cn/weapp/resource/miniprogram/common/avatar_ai.png', //左侧头像
AIUrl = `${agentUrl}?avatar_ai=${AIAvatar}&no_header=1&businessType=${bussinessType}&one_id=${staffUuid}&platformType=1&domain=${domainName}&brandType=${modelType || 1001}`
if(!reviewDate) reviewDate = dayjs().subtract(1, 'day')
AIUrl += `&phone=${phone}&brand=${brand}&date=${dayjs(reviewDate).format('YYYY-MM-DD')}`
if (taskStatus) AIUrl += `&practice_status=${taskStatus}`
this.setData({
AIUrl
})
} else wx.p.wxApi.showToast('获取智能体失败')
},
async getReceptionList(params) {
try {
wx.showLoading({
mask: true
})
console.log()
if (!params.userId) throw '缺少必要参数:userId'
const data = await wx.p.api.receptionApi.getReceptionList(params)
if(!data) throw '获取复盘失败,请稍后再试!'
let total = data.reduce((sum, e) => {
const length = e?.sopTaskDetailTagList?.length || 0
return sum + Number(length)
}, 0)
data.map(e => {
e?.sopTaskDetailTagList?.map(i => {
let {
weakness,
suggestion
} = i
i.weakness = weakness ? weakness.replace(/\n/g, '<br>') : '-'
i.suggestion = suggestion ? suggestion.replace(/\n/g, '<br>') : '-'
})
})
this.setData({
total,
list: data,
loadComplete: true,
tips: total ? `今日有 ${total} 条待复盘记录,请尽快处理哦~` : '今日无待处理复盘,请继续保持!'
})
if (data && data.length && !this.data.AIUrl) this.getAiagent(data[0])
wx.hideLoading()
console.log(data)
} catch (error) {
console.log(error)
wx.hideLoading()
if (error) wx.p.wxApi.showToast(error)
this.setData({
loadComplete: true,
})
}
},
toDetail() {
const {
openId
} = this.data.userInfo
wx.p.api.receptionApi.addCustomerDynamicRecord({
customerOpenId: openId,
goodsId: 1,
goodsType: 3
})
wx.p.router.go('/packageReception/pages/detail/detail', this.options)
},
jumpAI(e) {
const {
openId
} = this.data.userInfo
wx.p.api.receptionApi.addCustomerDynamicRecord({
customerOpenId: openId,
goodsId: 1,
goodsType: 2
})
let {
item
} = e.currentTarget.dataset, {
AIUrl
} = this.data
AIUrl += `&presuppositionProblem=${item.tagName}`
wx.p.router.jumpH5(AIUrl, true)
console.log(e)
},
navbarReady(e) {
let {
height
} = e.detail
this.setData({
layoutStyle: `padding-top:${height}px`
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getReceptionList(this.options)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
}
})