Authored by 陈峰

merge

... ... @@ -270,6 +270,7 @@ exports.index = (req, res, next) => {
if (!req.params[0] || !req.params[1]) {
return next();
}
// let uid = req.user.uid || 0; // pagecache重构
let headerData = headerModel.setNav({
navTitle: '商品详情'
... ... @@ -278,12 +279,14 @@ exports.index = (req, res, next) => {
detailModel.getProductData({
id: req.params[0],
goodsId: req.params[1],
// uid: uid,
ua: req.get('user-agent') || ''
}).then((result) => {
if (_.isEmpty(result)) {
return next();
}
// pagecache重构
// result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
res.render('detail/detail', {
... ... @@ -295,6 +298,7 @@ exports.index = (req, res, next) => {
});
}).catch(next);
};
/**
* 商品信息异步数据
* @param {[type]} req [description]
... ... @@ -323,4 +327,4 @@ exports.indexData = (req, res, next)=> {
return res.json(result);
}).catch(next);
}
};
... ...
... ... @@ -921,7 +921,7 @@ const _getLimitCodeUrl = (productCode, skn, ua) => {
// };
let _getShopsInfo = (brandId) => {
if(!brandId) {
if (!brandId) {
return Promise.resolve([]);
}
return api.get('', {
... ... @@ -1046,7 +1046,7 @@ const _getCommonConsult = () => {
// });
// });
// };
//
//
/**
* [商品获取数据] pagecache重构
*/
... ... @@ -1065,11 +1065,12 @@ let getProductData = (data) => {
product_skn: _.toString(data.productSkn)
});
}
//pagecache重构
// if (data.uid) {
// pagecache重构
// if (data.uid) {
// params.uid = data.uid;
// }
//pagecache重构
// pagecache重构
// return _getUserProfile(params.uid).then((user) => {
// data.vipLevel = (user.data && user.data.vip_info && user.data.vip_info.cur_level) || '0';
// data.isStudent = (user.data && user.data.vip_info && user.data.vip_info.is_student) ? true : false;
... ... @@ -1086,6 +1087,7 @@ let getProductData = (data) => {
result.goods_id = data.goodsId;
return Promise.all([
_getShopsInfo(result.brand_info.brand_id),
// _getPromotionInfo(result.product_skn),
comment.getCommentInfo({
productId: result.product_id
... ... @@ -1121,8 +1123,10 @@ let getProductData = (data) => {
});
});
// });
};
/**
* [商品数据格式化] pagecache重构
*/
... ... @@ -1152,7 +1156,7 @@ const _detailDataPkg = (origin, ua) => {
// });
// }
// 商品促销短语
// 商品促销短语
origin.sales_phrase && (dest.goodsSubtitle = origin.sales_phrase);
// 促销信息 TODO: 换新接口 pagecache重构
... ... @@ -1255,15 +1259,16 @@ const _detailDataPkg = (origin, ua) => {
// 商品信息
if (origin.goods_list.length) {
let goodsGroup = [];
//pagecache重构
// pagecache重构
// sizeName = '',
// colorList = [],
// sizeList = {},
// allSizeList = {},
// colorStorageGroup = {},
// colorStorageNum = 0;
//pagecache重构
_.forEach(origin.goods_list, function(value) {
// pagecache重构
_.forEach(origin.goods_list, function(value) {
if (value.status === 0) {
return;
}
... ... @@ -1407,7 +1412,8 @@ const _detailDataPkg = (origin, ua) => {
numInCart: 0,
goodsInstore: origin.storage_sum
};
//pagecache重构
// pagecache重构
// let soldOut = (origin.storage_sum === 0) || (totalStorageNum === 0); // status
// let notForSale = origin.attribute === 2;
... ... @@ -1464,10 +1470,11 @@ const _detailDataPkg = (origin, ua) => {
dest.id = origin.product_id;
dest.goodsId = origin.goods_id;
return dest;
};
/**
* [商品信息的异步数据获取]
*/
... ... @@ -1486,7 +1493,7 @@ let getProductAsyncData = (data) => {
product_skn: _.toString(data.productSkn)
});
}
if (data.uid) {
if (data.uid) {
params.uid = data.uid;
}
return _getUserProfile(params.uid).then((user) => {
... ... @@ -1513,7 +1520,8 @@ let getProductAsyncData = (data) => {
});
});
}
};
/**
* [商品信息格式化异步接口]
*/
... ... @@ -1523,6 +1531,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
colorGroup = {},
sizeGroup = [],
totalStorageNum = 0;
// 用户未登录时
if (!uid) {
dest.loginUrl = helpers.urlFormat('/signin.html', {
... ... @@ -1530,7 +1539,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
});
}
//商品促销短语
// 商品促销短语
origin.sales_phrase && (dest.goodsSubtitle = origin.sales_phrase);
// 促销信息 TODO: 换新接口
... ... @@ -1547,6 +1556,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
list: discountList
});
}
// 商品价格
let goodsPrice = {
currentPrice: origin.format_sales_price === '0' ? origin.format_market_price : origin.format_sales_price
... ... @@ -1583,7 +1593,8 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
});
}
//商品信息
// 商品信息
if (origin.goods_list.length) {
let goodsGroup = [],
sizeName = '',
... ... @@ -1719,6 +1730,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
numInCart: 0,
goodsInstore: origin.storage_sum
};
// 显示加入购物车链接
if (!soldOut && !notForSale) {
_.orderBy(colorGroup);
... ... @@ -1765,6 +1777,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
dest.isCollect = true;
dest.cartInfo.isCollect = true;
}
// 虚拟商品(门票)
if (origin.attribute * 1 === 3) {
dest.tickets = true;
... ... @@ -1792,7 +1805,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
dest.id = origin.product_id;
dest.goodsId = origin.goods_id;
return dest;
}
};
module.exports = {
getProductData,
getProductAsyncData,
... ...
... ... @@ -24,6 +24,7 @@ require('./detail/page-render')(function() {
var dialog = require('../plugin/dialog');
require('../common');
// add extra marign-bottom for footer to show the yoho copyright
function showFooter() {
var $cartBar = $('.cart-bar');
... ...
... ... @@ -2,7 +2,7 @@
var $ = require('yoho-jquery'),
dbClass = 'data-bind';
module.exports = function (callback) {
module.exports = function(callback) {
var productId = $('#productId').val();
var goodsId = $('#goodsId').val();
if (productId && goodsId) {
... ... @@ -19,7 +19,7 @@ module.exports = function (callback) {
}
});
}
}
};
function render(data) {
if (data.goodsPrice) {
$('.goods-price>.current-price').text(data.goodsPrice.currentPrice);
... ... @@ -49,12 +49,12 @@ function render(data) {
itemLi.addClass('current-level');
}
itemLi.find('.vip-price').text(item.text);
$('.vip-level').append(itemLi)
$('.vip-level').append(itemLi);
}
$('.vip-level').removeClass(dbClass);
}
if (data.goodsDiscount && data.goodsDiscount.list && data.goodsDiscount.list.length) {
var shortText = $('#goodsDiscount>.short-text').remove();
var liText = $('#goodsDiscount>.discount-folder>.folder-item').remove();
for (var i = 0; i < data.goodsDiscount.list.length; i++) {
... ... @@ -67,7 +67,7 @@ function render(data) {
itemText.text(discount.text).appendTo('#goodsDiscount>.discount-folder');
}
}
}
}
$('#goodsDiscount').removeClass('data-bind');
}
if (data.cartInfo) {
... ... @@ -94,7 +94,7 @@ function render(data) {
$('#noLimitCode').removeClass(dbClass);
}
$('.cart-bar').removeClass('data-bind');
$('#limitCodeUrl').val(data.cartInfo.limitCodeUrl)
$('#limitCodeUrl').val(data.cartInfo.limitCodeUrl);
$('#limitProductPay').val(data.cartInfo.limitProductPay);
if (data.cartInfo.limitProductCode) {
$('#limitProductCode').val(data.cartInfo.limitProductCode).removeClass(dbClass);
... ... @@ -109,5 +109,5 @@ function render(data) {
if (data.loginUrl) {
$('#loginUrl').val(data.loginUrl).removeClass(dbClass);
}
$('.'+dbClass).remove();
}
\ No newline at end of file
$('.' + dbClass).remove();
}
... ...