anchor.js
2.02 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
import { parse } from '../../../vendors/query-stringify';
import { tapGoBind } from '../../../common/login';
import event from '../../../common/event';
import tool from '../../../common/tool';
Component({
properties: {
url: {
type: String,
value: ''
},
tid: {
type: String,
value: ''
},
tName: {
type: String,
value: ''
},
tIndex: {
type: Number,
value: 1
},
tFindex: {
type: Number,
value: 1
},
isFloor: {
type: Number,
value: 0
}
},
data: {
needLogin: false
},
ready: function () {
if (!this.data.url) {
return false;
}
const url = this.data.url;
const search = url.split('?')[1] || '';
const qs = parse(search);
if (qs.needLogin && Number(qs.needLogin) === 1) {
const app = getApp() || {};
if (!app.getUid || !app.getUid()) {
this.setData({ needLogin: true })
} else {
this.setData({ needLogin: false })
}
}
},
methods: {
jumpTo: function() {
if (!this.data.url) {
return false;
}
const url = this.data.url;
const search = url.split('?')[1] || '';
const qs = parse(search);
if (qs.toolName && tool[qs.toolName]) {
return tool[qs.toolName](qs);
}
if (this.data.isFloor) {
let reportParams = {
F_ID: this.data.tid || '0',
F_NAME: this.data.tName || '',
F_URL: this.data.url || '',
F_INDEX: this.data.tFindex || 1,
I_INDEX: (this.data.tIndex + 1) || 1,
};
event.emit('anchor-click', reportParams);
}
return global.router.goUrl(this.data.url);
},
}
});