Authored by 毕凯

Merge branch 'feature/point' into 'master'

params-for-app



See merge request !4
1 { 1 {
2 "name": "yoho-js-sdk", 2 "name": "yoho-js-sdk",
3 - "version": "1.3.0", 3 + "version": "1.3.1",
4 "description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。", 4 "description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。",
5 "keywords": [ 5 "keywords": [
6 "YOHO!", 6 "YOHO!",
@@ -5,21 +5,36 @@ import utils from './utils'; @@ -5,21 +5,36 @@ import utils from './utils';
5 import cookies from './cookies'; 5 import cookies from './cookies';
6 6
7 let abTestFlag = false; // ab测试 7 let abTestFlag = false; // ab测试
  8 +let getPname = function () {
  9 + let pName = '';
  10 +
  11 + if (utils.isMobile.iOS()) {
  12 + pName = 'iFP_SalesPromotion_h5';
  13 + }
  14 +
  15 + if (utils.isMobile.Android()) {
  16 + pName = 'aFP_SalesPromotion_h5';
  17 + }
  18 +
  19 + return pName;
  20 +};
  21 +
8 let _replaceData = function(el, cond, data, wh, fp) { 22 let _replaceData = function(el, cond, data, wh, fp) {
9 if (!data) { 23 if (!data) {
10 return; 24 return;
11 } 25 }
12 26
13 el.find('.brand-name').html(data.brand_name); 27 el.find('.brand-name').html(data.brand_name);
14 - el.find('.product-detail').attr('href', `//m.yohobuy.com/product/${data.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${data.product_skn}}}`); 28 + el.find('.product-detail').attr('href', `//m.yohobuy.com/product/${data.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${data.product_skn},"from_page_name":"${getPname()}","from_page_param":"${location.href.split('?')[0]}"}}`);
15 el.find('.product-detail-img').attr('src', utils.image(data.default_images, wh.w, wh.h, 2, 75)); 29 el.find('.product-detail-img').attr('src', utils.image(data.default_images, wh.w, wh.h, 2, 75));
16 el.find('.product-name').html(data.product_name); 30 el.find('.product-name').html(data.product_name);
17 el.find('.vip-price-val').html(${data.vip_price}`); 31 el.find('.vip-price-val').html(${data.vip_price}`);
18 el.find('.sale-price').html(${data.sales_price}`); 32 el.find('.sale-price').html(${data.sales_price}`);
  33 + el.data('skn', data.product_skn);
19 if (data.sales_price === data.market_price) { 34 if (data.sales_price === data.market_price) {
20 el.find('.market-price').hide(); 35 el.find('.market-price').hide();
21 } else { 36 } else {
22 - el.find('.market-price').html(${data.market_price}`).show(); 37 + el.find('.market-price').html(${data.market_price}`).show();
23 } 38 }
24 39
25 let brandDom = el.find('.product-brand'); 40 let brandDom = el.find('.product-brand');
@@ -41,7 +56,7 @@ let _replaceData = function(el, cond, data, wh, fp) { @@ -41,7 +56,7 @@ let _replaceData = function(el, cond, data, wh, fp) {
41 fp.I_INDEX++; 56 fp.I_INDEX++;
42 brandDom.attr('fp', JSON.stringify(fp)); 57 brandDom.attr('fp', JSON.stringify(fp));
43 } 58 }
44 - } 59 + }
45 60
46 let listDom = el.find('.list-product'); 61 let listDom = el.find('.list-product');
47 if (listDom) { 62 if (listDom) {
@@ -159,7 +174,7 @@ let _jsonp = function(el, param, cond){ @@ -159,7 +174,7 @@ let _jsonp = function(el, param, cond){
159 } 174 }
160 175
161 let $newGoods = el.find('.feature-product-info'); 176 let $newGoods = el.find('.feature-product-info');
162 - 177 +
163 $newGoods.each(function(indx, perProduct) { 178 $newGoods.each(function(indx, perProduct) {
164 let $perProduct = $(perProduct); 179 let $perProduct = $(perProduct);
165 _replaceData($perProduct, cond, _getProductData(res), wh, fp); 180 _replaceData($perProduct, cond, _getProductData(res), wh, fp);
@@ -243,8 +258,8 @@ let _getProduct = function(param) { @@ -243,8 +258,8 @@ let _getProduct = function(param) {
243 let yh_channel = utils.queryString().yh_channel; 258 let yh_channel = utils.queryString().yh_channel;
244 if (cond.abtest) { 259 if (cond.abtest) {
245 abTestFlag = true; 260 abTestFlag = true;
246 - }  
247 - 261 + }
  262 +
248 if (yh_channel) { 263 if (yh_channel) {
249 cond.yh_channel = yh_channel; 264 cond.yh_channel = yh_channel;
250 } 265 }
@@ -288,4 +303,4 @@ export default { @@ -288,4 +303,4 @@ export default {
288 }); 303 });
289 } 304 }
290 } 305 }
291 -};  
  306 +};
@@ -95,6 +95,7 @@ let _bindEvent = function() { @@ -95,6 +95,7 @@ let _bindEvent = function() {
95 95
96 export default { 96 export default {
97 queryString: _queryString, 97 queryString: _queryString,
  98 + isMobile: isMobile,
98 init() { 99 init() {
99 //发送活动页参数 100 //发送活动页参数
100 _sParamByIframe(); 101 _sParamByIframe();
@@ -168,4 +169,4 @@ export default { @@ -168,4 +169,4 @@ export default {
168 $('body').append($cointipTmpl); 169 $('body').append($cointipTmpl);
169 $cointipTmpl.show(); 170 $cointipTmpl.show();
170 } 171 }
171 -};  
  172 +};