...
|
...
|
@@ -2,17 +2,12 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-05-18 11:42:11
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-02-21 10:29:03
|
|
|
* @Last Modified time: 2017-02-23 10:53:15
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
const $ = require('cheerio');
|
|
|
const utils = '../../../utils';
|
|
|
const productNameProcess = require(`${utils}/product-name-process`);
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const yhchannelMap = {
|
|
|
boys: '1',
|
...
|
...
|
@@ -21,44 +16,13 @@ const yhchannelMap = { |
|
|
lifestyle: '4'
|
|
|
};
|
|
|
|
|
|
const _formatProduct = (data) => {
|
|
|
let list = [];
|
|
|
|
|
|
_.forEach(data, function(value) {
|
|
|
if (!value.product_skn || !value.goods_list || !value.goods_list.length) {
|
|
|
return;
|
|
|
}
|
|
|
value.goodsId = value.goods_list[0].goods_id;
|
|
|
|
|
|
if (value.cn_alphabet) {
|
|
|
value.cn_alphabet = productNameProcess(value.cn_alphabet);
|
|
|
}
|
|
|
|
|
|
let goods = {
|
|
|
salePrice: value.sales_price ? value.sales_price : '',
|
|
|
price: value.market_price ? value.market_price : '',
|
|
|
url: helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`),
|
|
|
thumb: value.default_images,
|
|
|
name: value.product_name
|
|
|
|
|
|
};
|
|
|
|
|
|
// 市场价和售价一样,则不显示市场价
|
|
|
if (goods.salePrice === goods.price) {
|
|
|
goods.price = false;
|
|
|
}
|
|
|
|
|
|
list.push(goods);
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
};
|
|
|
|
|
|
module.exports = (data) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.product.preference',
|
|
|
product_skn: data.productskn,
|
|
|
limit: data.limit || '20'
|
|
|
limit: data.limit || '20',
|
|
|
shopId: data.shopId,
|
|
|
yh_channel: yhchannelMap[data.yhChannel]
|
|
|
}).then(result => {
|
|
|
result = $.load(result)('#goods-container').append(
|
|
|
`<script type="text/javascript">
|
...
|
...
|
@@ -72,7 +36,8 @@ module.exports = (data) => { |
|
|
|
|
|
// 店铺推荐点击商品 埋点
|
|
|
var C_ID = qs.yh_channel || 1;
|
|
|
var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + '_' + Math.floor(Math.random() * 1000000 + 1000000));
|
|
|
var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
|
|
|
'_' + Math.floor(Math.random() * 1000000 + 1000000));
|
|
|
|
|
|
var goodDom = document.getElementsByClassName("good-info");
|
|
|
for(var i = 0; i < goodDom.length; i++) {
|
...
|
...
|
|