Merge branch 'feature/detailyas' into 'release/5.4.1'
店铺推荐 YAS 重复加载处理 See merge request !269
Showing
1 changed file
with
66 additions
and
1 deletions
@@ -2,11 +2,12 @@ | @@ -2,11 +2,12 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2016-05-18 11:42:11 | 3 | * @Date: 2016-05-18 11:42:11 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2016-05-30 13:48:17 | 5 | + * @Last Modified time: 2017-02-21 10:03:05 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 'use strict'; | 8 | 'use strict'; |
9 | const _ = require('lodash'); | 9 | const _ = require('lodash'); |
10 | +const $ = require('cheerio'); | ||
10 | const utils = '../../../utils'; | 11 | const utils = '../../../utils'; |
11 | const productNameProcess = require(`${utils}/product-name-process`); | 12 | const productNameProcess = require(`${utils}/product-name-process`); |
12 | 13 | ||
@@ -59,6 +60,70 @@ module.exports = (data) => { | @@ -59,6 +60,70 @@ module.exports = (data) => { | ||
59 | product_skn: data.productskn, | 60 | product_skn: data.productskn, |
60 | limit: data.limit || '20' | 61 | limit: data.limit || '20' |
61 | }).then(result => { | 62 | }).then(result => { |
63 | + result = $.load(result)('#goods-container').append( | ||
64 | + `<script type="text/javascript"> | ||
65 | + (function() { | ||
66 | + var qs = {}; | ||
67 | + var hashes = window.location.search.slice(1).split('&'); | ||
68 | + for (var i = 0; i < hashes.length; i++) { | ||
69 | + var hash = hashes[i].split('='); | ||
70 | + qs[hash[0]] = hash[1]; | ||
71 | + } | ||
72 | + var uid = ''; | ||
73 | + window._ozuid = uid; // 暴露ozuid | ||
74 | + if (window._yas) { | ||
75 | + window._yas(1 * new Date(), '2.0.0', 'yohobuy_m', uid, '', ''); | ||
76 | + } | ||
77 | + | ||
78 | + // 店铺推荐点击商品 埋点 | ||
79 | + var C_ID = qs.yh_channel || 1; | ||
80 | + var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + '_' + Math.floor(Math.random() * 1000000 + 1000000)); | ||
81 | + | ||
82 | + var goodDom = document.getElementsByClassName("good-info"); | ||
83 | + for(var i = 0; i < goodDom.length; i++) { | ||
84 | + goodDom[i].addEventListener('click', function(e) { | ||
85 | + if (!window._yas || !window._yas.sendAppLogs) { | ||
86 | + return; | ||
87 | + } | ||
88 | + | ||
89 | + var PRD_ID = e.currentTarget.getAttribute('data-good-id'); | ||
90 | + var PRD_NUM = e.currentTarget.getAttribute('data-good-index'); | ||
91 | + window._yas.sendAppLogs({ | ||
92 | + appop: 'YB_CHOOSE_FOR_YOU', | ||
93 | + param: JSON.stringify({ | ||
94 | + REC_POSE: 100013, | ||
95 | + REC_ID: RECID, | ||
96 | + PRD_ID: PRD_ID, | ||
97 | + PRD_NUM: PRD_NUM, | ||
98 | + C_ID: C_ID, | ||
99 | + ACTION_ID: 1 | ||
100 | + }) | ||
101 | + }, true); | ||
102 | + }, false); | ||
103 | + } | ||
104 | + | ||
105 | + // 店铺推荐展示 埋点 | ||
106 | + setTimeout(function(){ | ||
107 | + // 店铺推荐展示 埋点 | ||
108 | + if (window._yas && typeof window._yas.sendAppLogs === 'function') { | ||
109 | + var prdIds = document.getElementById('prdIds') || {}; | ||
110 | + var ids = prdIds.getAttribute('value') || ''; | ||
111 | + | ||
112 | + window._yas.sendAppLogs({ | ||
113 | + appop: 'YB_CHOOSE_FOR_YOU', | ||
114 | + param: JSON.stringify({ | ||
115 | + REC_POSE: 100013, | ||
116 | + REC_ID: RECID, | ||
117 | + PRD_ID: ids, | ||
118 | + PRD_NUM: ids.split(',').length, | ||
119 | + C_ID: C_ID, | ||
120 | + ACTION_ID: 0 | ||
121 | + }) | ||
122 | + }, true); | ||
123 | + } | ||
124 | + }, 2000); | ||
125 | + }());</script>` | ||
126 | + ).html(); | ||
62 | return result; | 127 | return result; |
63 | }); | 128 | }); |
64 | }; | 129 | }; |
-
Please register or login to post a comment