systemTrack.js
1.37 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
import dayjs from 'dayjs'
export default {
data () {
return {
systemInfo: {},
timer: null,
id: null
}
},
onLoad (options) {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
const { row } = options
const _row = JSON.parse(row)
console.log(_row)
this.systemInfo = _row
if (_row.actualSendTime) this.systemInfo.time = dayjs(new Date(_row.actualSendTime)).format("YYYY-MM-DD HH:mm:ss")
if (_row.moduleType != 8) { // 策略企业通知不需要埋点
this.addTrack(_row)
this.timer = setInterval(() => {
this.leaveTrack(this.id)
}, 3000)
}
},
methods: {
// 进入埋点事件
addTrack(row) {
try {
const {phone} = uni.$storage.get("userInfo")
const entryData = {
taskId: row.id,
phoneNumber: phone
}
uni.$api.commonApi.addSystemInfo(entryData).then(res => {
if (res) {
this.leaveTrack(res)
this.id = res
}
})
} catch (error) {
console.error('进入埋点发生错误', error);
}
},
// 离开埋点事件
async leaveTrack(id) {
if (!id) return
await uni.$api.commonApi.leaveSystemInfo({id})
}
},
onUnload () {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}
}