sopApi.js
3.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
import api from '~/utils/request/request'
import {
getScene,
sopTrackPage,
sopTrackPageType
} from '~/utils/constantData'
const getDuration = page_show_time => (Date.now() - page_show_time) / 1e3
const reportClick = ({
thisPage,
options
}) => {
thisPage.options = {
...options,
...thisPage.options
}
reportSopCustomer(thisPage, 'PAGE_CLICK')
}
const reportHide = ({
thisPage
}) => {
reportSopCustomer(thisPage, 'PAGE_STOP')
}
const reportSopCustomer = async (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (sopTrackPage.includes(route)) {
if (!sopTrackPage.includes(wx.$router.getPageInstance().route)) return
if (options && options.scene) {
const data = await getScene(options.scene)
thisPage.options = data
reportSopFun(thisPage, event_type)
} else reportSopFun(thisPage, event_type)
}
}
const reportSopFun = async (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (!options.sopId) return
const userInfo = wx.$storage.get('srcm_shopmall_user_info') || wx.$storage.get("userInfo") || {},
pageType = sopTrackPageType[route] || '',
activityId = pageType == 4 ? options.couponId || '' : options.id || '', //商城券取couponId
merchantId = options.merchantId || '',
unionId = userInfo.unionId || wx.$storage.get('wx_user_info').unionId,
sopId = options.sopId || '',
extra = {
pageType,
activityId,
unionId,
merchantId,
sopId,
}
if (event_type == 'PAGE_STOP') extra.time = getDuration(thisPage.page_show_time)
const buryingPointList = [{
customer_phone: userInfo.phone,
add_way: 'SOP',
sopId,
// id_number: '',
// org_user_id: '',
// wechat_id: '',
wechat_union_id: unionId,
org_id: merchantId,
system_source: 'scrm',
platform: 'MimiProgram',
event_type,
event_time: new Date().format('yyyy-MM-dd hh:mm:ss'),
extra: JSON.stringify(extra)
}]
api.post({
method: 'marketing.api.sop.buryingPoint',
projectName: 'marketing',
buryingPointList
}, true)
}
module.exports = {
/**
* sop客户埋点上报
*/
reportSopCustomer,
reportClick,
reportHide,
/** sop用户行为记录(埋点调用)
*/
customerbehavior(data) {
return api.post({
method: 'scrm.api.sop.task.customerbehavior.add',
flag: 1,
...data
})
},
customerbehaviorByEventId(data) {
return api.post({
method: 'scrm.api.sop.event.customerbehavior.add',
...data
})
},
//sop概览
getSopOverview(data) {
return api.post({
method: 'scrm.api.marketing.sop.overview',
projectName: 'stoassistant',
...data
})
},
// sop任务客户列表
getSopTaskCustomer(data) {
return api.post({
method: 'scrm.api.sop.task.customer.page',
projectName: 'stoassistant',
...data
})
},
// sop客户智能档案
getSopArchives(data) {
return api.post({
method: 'scrm.api.sop.task.customer.archives',
projectName: 'stoassistant',
...data
})
},
// sop任务列表
getSopList(data) {
return api.post({
method: 'scrm.api.marketing.sop.list',
projectName: 'stoassistant',
...data
},
true)
},
// sop客户-更改旅程阶段
updateStage(data) {
return api.post({
method: 'scrm.api.sop.task.customer.stage.update',
projectName: 'stoassistant',
...data
})
},
}