Authored by 毕凯

Merge branch 'feature/givePoint'

@@ -10,6 +10,9 @@ var $footer = $('#yoho-footer'), @@ -10,6 +10,9 @@ var $footer = $('#yoho-footer'),
10 $yohoPage = $('.yoho-page'), 10 $yohoPage = $('.yoho-page'),
11 $header = $('.yoho-header'); 11 $header = $('.yoho-header');
12 12
  13 +//为您优选-40位随机数指纹请求id
  14 +var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + '_' + Math.floor(Math.random() * 1000000 + 1000000));
  15 +
13 function cookie(name) { 16 function cookie(name) {
14 var cookies = document.cookie, 17 var cookies = document.cookie,
15 cookieVal, 18 cookieVal,
@@ -272,6 +275,57 @@ function reMarginFooter(fixedElement) { @@ -272,6 +275,57 @@ function reMarginFooter(fixedElement) {
272 } 275 }
273 }()); 276 }());
274 277
  278 +//为您优选埋点 http://redmine.yoho.cn/issues/10117
  279 +function givePoint(parameter) {
  280 + var CID = 1;
  281 +
  282 + if (!window._yas.sendCustomInfo) {
  283 + return false;
  284 + }
  285 +
  286 + //男:1,女:2,潮童:3,创意生活:4
  287 + switch(cookie('_Channel')) {
  288 + case 'boys':
  289 + CID = 1;
  290 + break;
  291 + case 'girls':
  292 + CID = 2;
  293 + break;
  294 + case 'kids':
  295 + CID = 3;
  296 + break;
  297 + case 'lifestyle':
  298 + CID = 4;
  299 + break;
  300 + }
  301 +
  302 + parameter = $.extend({
  303 + 'REC_POSE': '',
  304 + 'REC_ID': RECID,
  305 + 'PRD_ID': '',
  306 + 'PRD_NUM': 0,
  307 + 'C_ID': CID,
  308 + 'ACTION_ID': 0,
  309 + 'page_num': 1
  310 + }, parameter);
  311 +
  312 + console.log({
  313 + 'op': 'YB_CHOOSE_FOR_YOU_Y',
  314 + 'uid': getUid(),
  315 + 'param': parameter
  316 + }, 'yas=WEB==');
  317 +
  318 + if (parameter.REC_POSE === '' || parameter.PRD_ID === '') {
  319 + return true;
  320 + }
  321 +
  322 + window._yas.sendCustomInfo({
  323 + 'op': 'YB_CHOOSE_FOR_YOU_Y',
  324 + 'uid': getUid(),
  325 + 'param': parameter
  326 + }, true);
  327 +}
  328 +
275 /*$(document).ready(function() { 329 /*$(document).ready(function() {
276 setTimeout(function() { 330 setTimeout(function() {
277 var arr = document.querySelectorAll('.buriedpoint').find('a'), 331 var arr = document.querySelectorAll('.buriedpoint').find('a'),
@@ -385,3 +439,5 @@ window.getShoppingKey = getShoppingKey; @@ -385,3 +439,5 @@ window.getShoppingKey = getShoppingKey;
385 window.rePosFooter = rePosFooter; 439 window.rePosFooter = rePosFooter;
386 440
387 window.reMarginFooter = reMarginFooter; 441 window.reMarginFooter = reMarginFooter;
  442 +
  443 +window.givePoint = givePoint;
@@ -19,7 +19,8 @@ module.exports = function(specificGender) { @@ -19,7 +19,8 @@ module.exports = function(specificGender) {
19 page = 0, 19 page = 0,
20 gender = null, 20 gender = null,
21 num, 21 num,
22 - url; 22 + url,
  23 + RECPOSE = '110001';
23 24
24 //The kidsType can be specified by the parameter. Add by @ZhaoBiao 25 //The kidsType can be specified by the parameter. Add by @ZhaoBiao
25 var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false, 26 var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
@@ -48,11 +49,14 @@ module.exports = function(specificGender) { @@ -48,11 +49,14 @@ module.exports = function(specificGender) {
48 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? 49 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
49 '1,3&rec_pos=100009' : '2,3&rec_pos=100009', 50 '1,3&rec_pos=100009' : '2,3&rec_pos=100009',
50 url = '/product/recom/maylike?gender=' + gender; 51 url = '/product/recom/maylike?gender=' + gender;
51 - } else if (logisticType) { //物流页面 52 + RECPOSE = 110009;
52 53
  54 + } else if (logisticType) { //物流页面
53 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? 55 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
54 '1,3&rec_pos=100006' : '2,3&rec_pos=100006', 56 '1,3&rec_pos=100006' : '2,3&rec_pos=100006',
55 url = '/product/recom/maylike?gender=' + gender; 57 url = '/product/recom/maylike?gender=' + gender;
  58 + RECPOSE = 110006;
  59 +
56 } else { 60 } else {
57 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? 61 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
58 '1,3&rec_pos=100001' : '2,3&rec_pos=100002', 62 '1,3&rec_pos=100001' : '2,3&rec_pos=100002',
@@ -64,6 +68,13 @@ module.exports = function(specificGender) { @@ -64,6 +68,13 @@ module.exports = function(specificGender) {
64 url = '/product/recom/newPreference?template_id=' + $.queryString().template_id; 68 url = '/product/recom/newPreference?template_id=' + $.queryString().template_id;
65 } 69 }
66 70
  71 + //首页男生和女生,推荐位ID,埋点
  72 + if (window.location.pathname === '/boys') {
  73 + RECPOSE = 110001;
  74 + } else if (window.location.pathname === '/girls') {
  75 + RECPOSE = 110002;
  76 + }
  77 +
67 $curNav = $navList.children('.focus'); 78 $curNav = $navList.children('.focus');
68 79
69 if (lifestyleType) { 80 if (lifestyleType) {
@@ -114,7 +125,7 @@ module.exports = function(specificGender) { @@ -114,7 +125,7 @@ module.exports = function(specificGender) {
114 page: page + 1 125 page: page + 1
115 }, 126 },
116 success: function(data) { 127 success: function(data) {
117 - 128 + var PRDID = [];
118 if (data === ' ') { 129 if (data === ' ') {
119 searching = false; 130 searching = false;
120 loading.hideLoadingMask(); 131 loading.hideLoadingMask();
@@ -171,6 +182,19 @@ module.exports = function(specificGender) { @@ -171,6 +182,19 @@ module.exports = function(specificGender) {
171 182
172 $title[0].mlellipsis(2); 183 $title[0].mlellipsis(2);
173 }); 184 });
  185 +
  186 + //为您优选埋点 start
  187 + $(data).closest('.good-info').each(function() {
  188 + PRDID.push($(this).data('id'));
  189 + });
  190 + window.givePoint({
  191 + 'REC_POSE': RECPOSE,
  192 + 'PRD_ID': PRDID.join(','),
  193 + 'PRD_NUM': $(data).closest('.good-info').length,
  194 + 'ACTION_ID': 0,
  195 + 'page_num': page + 1
  196 + });
  197 + //为您优选埋点 end
174 }, 198 },
175 error: function() { 199 error: function() {
176 tip.show('网络断开连接了~'); 200 tip.show('网络断开连接了~');
@@ -199,4 +223,18 @@ module.exports = function(specificGender) { @@ -199,4 +223,18 @@ module.exports = function(specificGender) {
199 $(window).scroll(function() { 223 $(window).scroll(function() {
200 window.requestAnimationFrame(scrollHandler); 224 window.requestAnimationFrame(scrollHandler);
201 }); 225 });
  226 +
  227 + //为您优选埋点 http://redmine.yoho.cn/issues/10116
  228 + $('.maybe-like .goods-list').on('click', 'a', function() {
  229 + var index = $(this).closest('.good-info').index() + 1,
  230 + pageNum = 50;
  231 + window.givePoint({
  232 + 'REC_POSE': RECPOSE,
  233 + 'PRD_ID': $(this).closest('.good-info').data('id'),
  234 + 'PRD_NUM': index % pageNum === 0 ? pageNum : index % pageNum,
  235 + 'ACTION_ID': 1,
  236 + 'page_num': Math.ceil(index / pageNum)
  237 + });
  238 + return true;
  239 + });
202 }; 240 };
@@ -12,8 +12,38 @@ var Swiper = require('yoho.iswiper'), @@ -12,8 +12,38 @@ var Swiper = require('yoho.iswiper'),
12 var $recommendForYou = $('.recommend-for-you'); 12 var $recommendForYou = $('.recommend-for-you');
13 13
14 $.get('/product/recommend-for-you/cart').then(function(html) { 14 $.get('/product/recommend-for-you/cart').then(function(html) {
  15 + var PRDID =[];
  16 +
15 $recommendForYou.html(html).show(); 17 $recommendForYou.html(html).show();
16 lazyLoad($('img.lazy')); 18 lazyLoad($('img.lazy'));
  19 +
  20 + //为您优选埋点 http://redmine.yoho.cn/issues/10116
  21 + $recommendForYou.find('.good-info').each(function() {
  22 + PRDID.push($(this).data('id'));
  23 + });
  24 +
  25 + window.givePoint({
  26 + 'REC_POSE': 10003,
  27 + 'PRD_ID': PRDID.join(','),
  28 + 'PRD_NUM': $('.recommend-for-you .good-info').length,
  29 + 'ACTION_ID': 0,
  30 + 'page_num': 1
  31 + });
  32 +
  33 + $recommendForYou.find('.good-info').on('click', 'a', function() {
  34 + var index = $(this).closest('.good-info').index() + 1;
  35 +
  36 + window.givePoint({
  37 + 'REC_POSE': 10003,
  38 + 'PRD_ID': $(this).closest('.good-info').data('id'),
  39 + 'PRD_NUM': index,
  40 + 'ACTION_ID': 1,
  41 + 'page_num': 1
  42 + });
  43 +
  44 + return true;
  45 + });
  46 +
17 }).fail(function() { 47 }).fail(function() {
18 $recommendForYou.hide(); 48 $recommendForYou.hide();
19 }); 49 });
@@ -12,9 +12,38 @@ var Swiper = require('yoho.iswiper'), @@ -12,9 +12,38 @@ var Swiper = require('yoho.iswiper'),
12 var $recommendForYou = $('.recommend-for-you'); 12 var $recommendForYou = $('.recommend-for-you');
13 13
14 $.get('/product/recommend-for-you/userCenter').then(function(html) { 14 $.get('/product/recommend-for-you/userCenter').then(function(html) {
  15 + var PRDID = [];
  16 +
15 $recommendForYou.html(html).show(); 17 $recommendForYou.html(html).show();
16 lazyLoad($('img.lazy')); 18 lazyLoad($('img.lazy'));
17 19
  20 + //为您优选埋点 http://redmine.yoho.cn/issues/10116
  21 + $recommendForYou.find('.good-info').each(function() {
  22 + PRDID.push($(this).data('id'));
  23 + });
  24 +
  25 + window.givePoint({
  26 + 'REC_POSE': 110004,
  27 + 'PRD_ID': PRDID.join(','),
  28 + 'PRD_NUM': $('.recommend-for-you .good-info').length,
  29 + 'ACTION_ID': 0,
  30 + 'page_num': 1
  31 + });
  32 +
  33 + $recommendForYou.find('.good-info').on('click', 'a', function() {
  34 + var index = $(this).closest('.good-info').index() + 1;
  35 +
  36 + window.givePoint({
  37 + 'REC_POSE': 110004,
  38 + 'PRD_ID': $(this).closest('.good-info').data('id'),
  39 + 'PRD_NUM': index,
  40 + 'ACTION_ID': 1,
  41 + 'page_num': 1
  42 + });
  43 +
  44 + return true;
  45 + });
  46 +
18 }).fail(function() { 47 }).fail(function() {
19 $recommendForYou.hide(); 48 $recommendForYou.hide();
20 }); 49 });