Authored by 陈峰

Merge branch 'feature/prefrence' into 'release/5.4.1'

商品详情页店铺推荐增加两个参数



See merge request !288
@@ -63,6 +63,8 @@ exports.intro = (req, res, next) => { @@ -63,6 +63,8 @@ exports.intro = (req, res, next) => {
63 exports.preference = (req, res, next) => { 63 exports.preference = (req, res, next) => {
64 preferenceModel({ 64 preferenceModel({
65 productskn: req.query.productSkn, 65 productskn: req.query.productSkn,
  66 + shopId: req.query.shopId,
  67 + yhChannel: req.query.yhChannel,
66 limit: '20' // 后期值需要修改的话得手动改 68 limit: '20' // 后期值需要修改的话得手动改
67 }).then((result) => { 69 }).then((result) => {
68 res.send(result); 70 res.send(result);
@@ -218,7 +220,8 @@ exports.indexSkn = (req, res, next) => { @@ -218,7 +220,8 @@ exports.indexSkn = (req, res, next) => {
218 } 220 }
219 221
220 // pagecache重构 222 // pagecache重构
221 - // result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false; 223 + // result.studentPrice = req.__User__.isStudent && result &&
  224 + // result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
222 res.render('detail/detail', { 225 res.render('detail/detail', {
223 pageHeader: headerData, 226 pageHeader: headerData,
224 result: result, 227 result: result,
@@ -258,7 +261,8 @@ exports.index = (req, res, next) => { @@ -258,7 +261,8 @@ exports.index = (req, res, next) => {
258 } 261 }
259 262
260 // pagecache重构 263 // pagecache重构
261 - // result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false; 264 + // result.studentPrice = req.__User__.isStudent && result &&
  265 + // result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
262 res.render('detail/detail', { 266 res.render('detail/detail', {
263 pageHeader: headerData, 267 pageHeader: headerData,
264 result: result, 268 result: result,
@@ -301,7 +305,8 @@ exports.indexData = (req, res, next) => { @@ -301,7 +305,8 @@ exports.indexData = (req, res, next) => {
301 message: '数据错误' 305 message: '数据错误'
302 }); 306 });
303 } 307 }
304 - result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false; 308 + result.studentPrice = req.__User__.isStudent && result && result.goodsPrice &&
  309 + result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
305 return res.json(result); 310 return res.json(result);
306 }).catch(next); 311 }).catch(next);
307 312
@@ -61,8 +61,8 @@ const tool = { @@ -61,8 +61,8 @@ const tool = {
61 61
62 62
63 // 品牌信息 63 // 品牌信息
64 - if (origin.brand_info) {  
65 - let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`; 64 + if (origin.shop_id) {
  65 + let extra = `?productSkn=${origin.product_skn}&shopId=${origin.shop_id}`;
66 66
67 dest.preferenceUrl = `/product/detail/preference${extra}`; 67 dest.preferenceUrl = `/product/detail/preference${extra}`;
68 } 68 }
@@ -2,17 +2,12 @@ @@ -2,17 +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: 2017-02-21 10:29:03 5 + * @Last Modified time: 2017-02-23 10:53:15
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
9 -const _ = require('lodash');  
10 const $ = require('cheerio'); 9 const $ = require('cheerio');
11 -const utils = '../../../utils';  
12 -const productNameProcess = require(`${utils}/product-name-process`);  
13 -  
14 const api = global.yoho.API; 10 const api = global.yoho.API;
15 -const helpers = global.yoho.helpers;  
16 11
17 const yhchannelMap = { 12 const yhchannelMap = {
18 boys: '1', 13 boys: '1',
@@ -21,44 +16,13 @@ const yhchannelMap = { @@ -21,44 +16,13 @@ const yhchannelMap = {
21 lifestyle: '4' 16 lifestyle: '4'
22 }; 17 };
23 18
24 -const _formatProduct = (data) => {  
25 - let list = [];  
26 -  
27 - _.forEach(data, function(value) {  
28 - if (!value.product_skn || !value.goods_list || !value.goods_list.length) {  
29 - return;  
30 - }  
31 - value.goodsId = value.goods_list[0].goods_id;  
32 -  
33 - if (value.cn_alphabet) {  
34 - value.cn_alphabet = productNameProcess(value.cn_alphabet);  
35 - }  
36 -  
37 - let goods = {  
38 - salePrice: value.sales_price ? value.sales_price : '',  
39 - price: value.market_price ? value.market_price : '',  
40 - url: helpers.urlFormat(`/product/pro_${value.product_id}_${value.goodsId}/${value.cn_alphabet}.html`),  
41 - thumb: value.default_images,  
42 - name: value.product_name  
43 -  
44 - };  
45 -  
46 - // 市场价和售价一样,则不显示市场价  
47 - if (goods.salePrice === goods.price) {  
48 - goods.price = false;  
49 - }  
50 -  
51 - list.push(goods);  
52 - });  
53 -  
54 - return list;  
55 -};  
56 -  
57 module.exports = (data) => { 19 module.exports = (data) => {
58 return api.get('', { 20 return api.get('', {
59 method: 'app.product.preference', 21 method: 'app.product.preference',
60 product_skn: data.productskn, 22 product_skn: data.productskn,
61 - limit: data.limit || '20' 23 + limit: data.limit || '20',
  24 + shopId: data.shopId,
  25 + yh_channel: yhchannelMap[data.yhChannel]
62 }).then(result => { 26 }).then(result => {
63 result = $.load(result)('#goods-container').append( 27 result = $.load(result)('#goods-container').append(
64 `<script type="text/javascript"> 28 `<script type="text/javascript">
@@ -72,7 +36,8 @@ module.exports = (data) => { @@ -72,7 +36,8 @@ module.exports = (data) => {
72 36
73 // 店铺推荐点击商品 埋点 37 // 店铺推荐点击商品 埋点
74 var C_ID = qs.yh_channel || 1; 38 var C_ID = qs.yh_channel || 1;
75 - var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + '_' + Math.floor(Math.random() * 1000000 + 1000000)); 39 + var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
  40 + '_' + Math.floor(Math.random() * 1000000 + 1000000));
76 41
77 var goodDom = document.getElementsByClassName("good-info"); 42 var goodDom = document.getElementsByClassName("good-info");
78 for(var i = 0; i < goodDom.length; i++) { 43 for(var i = 0; i < goodDom.length; i++) {
@@ -29,7 +29,7 @@ function request() { @@ -29,7 +29,7 @@ function request() {
29 requesting = true; 29 requesting = true;
30 30
31 if (preferenceUrl) { 31 if (preferenceUrl) {
32 - $.get(preferenceUrl).then(function(html) { 32 + $.get(preferenceUrl, {yhChannel: window.cookie('_Channel') || 'boys'}).then(function(html) {
33 if (typeof html !== 'string') { 33 if (typeof html !== 'string') {
34 return; 34 return;
35 } 35 }