Authored by 郭成尧

preference-add-params

... ... @@ -63,6 +63,8 @@ exports.intro = (req, res, next) => {
exports.preference = (req, res, next) => {
preferenceModel({
productskn: req.query.productSkn,
shopId: req.query.shopId,
yhChannel: req.query.yhChannel,
limit: '20' // 后期值需要修改的话得手动改
}).then((result) => {
res.send(result);
... ... @@ -218,7 +220,8 @@ exports.indexSkn = (req, res, next) => {
}
// pagecache重构
// result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
// result.studentPrice = req.__User__.isStudent && result &&
// result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
res.render('detail/detail', {
pageHeader: headerData,
result: result,
... ... @@ -258,7 +261,8 @@ exports.index = (req, res, next) => {
}
// pagecache重构
// result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
// result.studentPrice = req.__User__.isStudent && result &&
// result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
res.render('detail/detail', {
pageHeader: headerData,
result: result,
... ... @@ -301,7 +305,8 @@ exports.indexData = (req, res, next) => {
message: '数据错误'
});
}
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
result.studentPrice = req.__User__.isStudent && result && result.goodsPrice &&
result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
return res.json(result);
}).catch(next);
... ...
... ... @@ -61,8 +61,8 @@ const tool = {
// 品牌信息
if (origin.brand_info) {
let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
if (origin.shop_id) {
let extra = `?productSkn=${origin.product_skn}&shopId=${origin.shop_id}`;
dest.preferenceUrl = `/product/detail/preference${extra}`;
}
... ...
... ... @@ -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++) {
... ...
... ... @@ -29,7 +29,7 @@ function request() {
requesting = true;
if (preferenceUrl) {
$.get(preferenceUrl).then(function(html) {
$.get(preferenceUrl, {yhChannel: window.cookie('_Channel') || 'boys'}).then(function(html) {
if (typeof html !== 'string') {
return;
}
... ...