extract-url.js
1.43 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
/**
* 提取URL中的参数
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/19
*/
var opt = {};
var paramStr = window.location.search.split('?')[1];
var keyVal = paramStr.split('&');
var i, key, val;
for (i = keyVal.length; i > 0; i--) {
key = keyVal[i - 1].split('=');
val = key[1];
key = key[0];
//初始化默认参数
switch (key) {
case 'gender':
opt.gender = val;
break;
case 'brand':
opt.brand = val;
break;
case 'sort':
opt.sort = val;
break;
case 'msort':
opt.msort = val;
break;
case 'misort':
opt.misort = val;
break;
case 'color':
opt.color = val;
break;
case 'size':
opt.size = val;
break;
case 'price':
opt.price = val;
break;
case 'discount':
opt.discount = val;
break;
case 'query':
opt.query = val;
break;
case 'style':
opt.style = val;
break;
case 'limit':
opt.limit = val;
break;
case 'channel':
opt.channel = val;
break;
case 'p_d':
opt.p_d = val;
break;
case 'dayLimit':
opt.dayLimit = val;
break;
}
}
module.exports = opt;