reportTrackApi.js
1.62 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
import { sopApi, bigdatautilApi } from '~/api/api'
import { getUserInfo } from '~/utils/cache/userInfo'
/**SOP埋点 */
export function customerBehavior() {
let { taskId } = wx.getLaunchOptionsSync().query
if (!taskId) return
let { openId, phone } = getUserInfo()
sopApi.customerBehavior({
customerPhone: phone,
behaviorType: 1,
taskId,
openId
})
}
/**埋点上报 */
export function reportData(params, check, receive, isRecommended) {
let data = {
add_way: '104'
}
let user = wx.p.storage.get('srcm_shopmall_user_info')
if (user) {
user = JSON.parse(user)
}
if (params.activity_id) {
data.activity_id = params.activity_id
}
if (params.merchantId) {
data.merchant_id = params.merchantId
}
if (params.phone || user.phone) {
data.customer_phone = params.phone || user.phone
}
if (check) {
data.check_time = new Date().format('yyyy-MM-dd hh:mm:ss')
data.check_status = 1
}
if (receive) {
data.receive_status = 1
data.receive_time = new Date().format('yyyy-MM-dd hh:mm:ss')
}
if (user.unionId) {
data.union_id = user.unionId
}
if (user.openId) {
data.open_id = user.openId
}
if (isRecommended) {
data.item_type = params.item_type
data.action_type = params.action_type
data.business_type = 1
data.create_time = new Date().format('yyyy-MM-dd hh:mm:ss')
data.staff_uuid = params.shareStaffUuid
data.item_id = params.item_id
if (params.order_id) {
data.order_id = params.order_id
}
}
// let json = encodeURIComponent(JSON.stringify(data))
let json = JSON.stringify(data)
bigdatautilApi.reportCustomer({ json })
}