|
@@ -10,10 +10,28 @@ var dataLazyLoad = require('../plugins/lazy-load')(document); |
|
@@ -10,10 +10,28 @@ var dataLazyLoad = require('../plugins/lazy-load')(document); |
10
|
var $ = require('yoho-jquery');
|
10
|
var $ = require('yoho-jquery');
|
11
|
var recommendTpl = require('hbs/product/good-slide.hbs');
|
11
|
var recommendTpl = require('hbs/product/good-slide.hbs');
|
12
|
var $recommendSlide = $('[data-role="recommend-slide"]');
|
12
|
var $recommendSlide = $('[data-role="recommend-slide"]');
|
|
|
13
|
+var yas = require('../common/data-yas');
|
|
|
14
|
+
|
|
|
15
|
+var $goodsIdArr = [];
|
13
|
|
16
|
|
14
|
require('../plugins/slider');
|
17
|
require('../plugins/slider');
|
15
|
require('../common/center-slider');
|
18
|
require('../common/center-slider');
|
16
|
|
19
|
|
|
|
20
|
+function randomString(len) {
|
|
|
21
|
+ var $chars = 'ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-';
|
|
|
22
|
+
|
|
|
23
|
+ var maxPos = $chars.length,
|
|
|
24
|
+ pwd = '',
|
|
|
25
|
+ i;
|
|
|
26
|
+
|
|
|
27
|
+ for (i = 0; i < len; i++) {
|
|
|
28
|
+ pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
|
|
|
29
|
+ }
|
|
|
30
|
+
|
|
|
31
|
+ return pwd;
|
|
|
32
|
+}
|
|
|
33
|
+
|
|
|
34
|
+
|
17
|
function getSearchRecommend() {
|
35
|
function getSearchRecommend() {
|
18
|
|
36
|
|
19
|
$.ajax({
|
37
|
$.ajax({
|
|
@@ -44,6 +62,12 @@ function getSearchRecommend() { |
|
@@ -44,6 +62,12 @@ function getSearchRecommend() { |
44
|
shownum: 5,
|
62
|
shownum: 5,
|
45
|
isCircle: true
|
63
|
isCircle: true
|
46
|
});
|
64
|
});
|
|
|
65
|
+
|
|
|
66
|
+ $('.recommend-slider .img-item').each(function() {
|
|
|
67
|
+ $goodsIdArr.push($(this).data('id'));
|
|
|
68
|
+ });
|
|
|
69
|
+
|
|
|
70
|
+ initPageYas();
|
47
|
}
|
71
|
}
|
48
|
}
|
72
|
}
|
49
|
|
73
|
|
|
@@ -52,6 +76,40 @@ function getSearchRecommend() { |
|
@@ -52,6 +76,40 @@ function getSearchRecommend() { |
52
|
|
76
|
|
53
|
window.getSearchRecommend = getSearchRecommend;
|
77
|
window.getSearchRecommend = getSearchRecommend;
|
54
|
|
78
|
|
|
|
79
|
+/*
|
|
|
80
|
+ * 页面加载完
|
|
|
81
|
+ */
|
|
|
82
|
+function initPageYas() {
|
|
|
83
|
+ var loadYas = {
|
|
|
84
|
+ REC_POSE: 100101,
|
|
|
85
|
+ REC_ID: randomString(40),
|
|
|
86
|
+ PRD_ID: $goodsIdArr.join(','),
|
|
|
87
|
+ PRD_NUM: $goodsIdArr.length,
|
|
|
88
|
+ ACTION_ID: 0,
|
|
|
89
|
+ PAGE_NUM: 1
|
|
|
90
|
+ };
|
|
|
91
|
+ // 关键词搜索结果页展示时
|
|
|
92
|
+ yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
|
|
|
93
|
+}
|
|
|
94
|
+
|
|
|
95
|
+// 点击你可能喜欢的商品埋点
|
|
|
96
|
+$('.recommend-slider').on('click', '.img-item', function() {
|
|
|
97
|
+ var $this = $(this);
|
|
|
98
|
+ var proId = $this.data('id');
|
|
|
99
|
+
|
|
|
100
|
+ var loadYas = {
|
|
|
101
|
+ REC_POSE: 100101,
|
|
|
102
|
+ REC_ID: randomString(40),
|
|
|
103
|
+ PRD_ID: proId,
|
|
|
104
|
+ PRD_NUM: $goodsIdArr.indexOf(proId) + 1,
|
|
|
105
|
+ ACTION_ID: 1,
|
|
|
106
|
+ PAGE_NUM: 1
|
|
|
107
|
+ };
|
|
|
108
|
+
|
|
|
109
|
+ // 关键词搜索结果页展示时
|
|
|
110
|
+ yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
|
|
|
111
|
+});
|
|
|
112
|
+
|
55
|
// 数据懒加载
|
113
|
// 数据懒加载
|
56
|
dataLazyLoad.init({cls: '.lazy-load-object-2', threshold: 700});
|
114
|
dataLazyLoad.init({cls: '.lazy-load-object-2', threshold: 700});
|
57
|
|
115
|
|