intercept-click.js
2.01 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
/**
* 拦截跳转, 在这里给将要打开的页面设置一下 header 样式
* @return {[type]}
*/
const yoho = require('yoho');
/**
* 跳转 App 头部参数
* 文档 http://git.yoho.cn/mobile/AppJSBridge/blob/master/HeaderType.md
* @type {Object}
*/
const titleMap = {
1: {
headerid: '1',
left: {
action: ''
},
title: {
des: '标题1',
action: ''
}
},
2: {
headerid: '2',
left: {
action: ''
},
title: {
des: '标题2',
action: ''
},
right: {
action: ''
}
},
3: {
headerid: '3',
left: {
action: ''
},
title: {
des: '标题3',
action: ''
},
right: {
des: '提交',
action: ''
}
},
4: {
headerid: '4',
ltitle: {
des: '品牌4',
action: ''
},
rtitle: {
des: '品类4',
action: ''
}
},
5: {
headerid: '5',
left: {
action: ''
},
ltitle: {
des: '商品5',
action: ''
},
rtitle: {
des: '品牌5',
action: ''
},
right: {
des: '编辑5',
action: ''
}
},
6: {
headerid: '6',
title: {
des: '资讯6',
action: ''
}
}
};
const matchHeader = (url) => {
let header = '';
if (/product\/new/.test(url)) {
header = titleMap[1];
// header.xxx = '111';// 匹配到头类型以后,可修改里边的内容
return header;
}
return '';
};
module.exports = (url) => {
console.log(url);
if (yoho.isApp) {
let data = {
header: matchHeader(url),
url: url
};
yoho.goNewPage(data);
} else {
location.href = url;
}
};