data-yas.js
2.35 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
/**
* Created by DELL on 2016.11.9.
*/
var $ = require('yoho-jquery');
function getCookie(name) {
var arr, reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
if (arr === document.cookie.match(reg)) {
return unescape(arr[2]);
} else {
return null;
}
}
// 频道、性别、品类、折扣、人群、颜色、尺码、分类
function _getCommonFilterValue() {
var $section = $('.channel, .sort, .discount, .misort, .color, .size');
var $attrchecked = $section.find('.attr-content .attr.checked');
var filterValue = '';
$attrchecked.each(function() {
var $this = $(this);
var key = $this.parents('.attr-content').prev().html(),
name = $this.attr('name');
filterValue += key + name + ';';
});
return filterValue;
}
// 价格、品牌、高级筛选
function _getOtherFilterValue() {
var filterValue = '';
$('.checked-conditions .attr-content .tag').each(function() {
var type = $(this).attr('itemType'),
name = $(this).attr('name');
switch (type) {
case 'brands':
type = '品牌';
break;
case 'price':
type = '价格';
break;
default:
break;
}
filterValue += type + ':' + name + ';';
});
return filterValue;
}
/** *埋点方法***/
function givePoint(op, parameter) {
var CID = 1;
if (!window._yas || !window._yas.sendCustomInfo) {
return false;
}
if (!getCookie('_Channel')) {
// 男:1,女:2,潮童:3,创意生活:4
switch (getCookie('_Channel')) {
case 'boys':
CID = 1;
break;
case 'girls':
CID = 2;
break;
case 'kids':
CID = 3;
break;
case 'lifestyle':
CID = 4;
break;
default:
CID = 1;
}
}
parameter = $.extend({
C_ID: CID
}, parameter);
console.info(parameter);
window._yas.sendCustomInfo({
op: op,
param: JSON.stringify(parameter)
}, true);
}
function getFilterValue() {
return _getCommonFilterValue() + _getOtherFilterValue();
}
exports.givePoint = givePoint;
exports.getFilterValue = getFilterValue;