|
|
/**
|
|
|
* 商品详情models
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2016/5/6
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
const comment = require('./consult-comment');
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const SINGLE_TICKETS_SKN = 51335912; // 展览票
|
|
|
|
|
|
/**
|
|
|
* 获取用户数据信息
|
|
|
* @param {[string]} uid
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const _getUserProfile = (uid) => {
|
|
|
if (!uid) {
|
|
|
return Promise.resolve({
|
|
|
code: 200,
|
|
|
data: {}
|
|
|
});
|
|
|
}
|
|
|
return api.get('', {
|
|
|
method: 'app.passport.profile',
|
|
|
uid: uid
|
|
|
}, {
|
|
|
cache: true
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 处理品牌关联店铺信息
|
|
|
* @param {array}
|
|
|
* @return {array}
|
|
|
*/
|
|
|
const _processShopsInfo = (data) => {
|
|
|
let enterStore = [];
|
|
|
|
|
|
_.forEach(data, function(value) {
|
|
|
let shopInfo = {
|
|
|
img: value.brand_ico,
|
|
|
storeName: value.brand_name
|
|
|
};
|
|
|
|
|
|
if (value.shop_id) {
|
|
|
shopInfo.url = helpers.urlFormat('/product/index/brand', {
|
|
|
shop_id: value.shop_id
|
|
|
});
|
|
|
} else {
|
|
|
shopInfo.url = helpers.urlFormat('', null, value.brand_domain);
|
|
|
}
|
|
|
|
|
|
enterStore.push(shopInfo);
|
|
|
});
|
|
|
return enterStore;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
|
|
|
* @param {array} 需要处理的数据
|
|
|
* @param {int} 限购商品的关联状态
|
|
|
* @param {Boolean} 限购商品是否已开售
|
|
|
* @return {array}
|
|
|
*/
|
|
|
const _procShowStatus = (data, showStatus, isBeginSale) => {
|
|
|
switch (showStatus) {
|
|
|
case 1: // 开售前/后,立即分享获得限购码(用户未领取限购码)
|
|
|
// 显示获取限购码按钮
|
|
|
data.canGetLimitCode = true;
|
|
|
|
|
|
if (isBeginSale) { // 开售后
|
|
|
data.cartInfo.noLimitCode = true;
|
|
|
} else {
|
|
|
data.cartInfo.limitNotForSale = true;
|
|
|
}
|
|
|
break;
|
|
|
case 2: // 开售后,限购码已抢光(用户未领取限购码)
|
|
|
data.codeEmpty = true;
|
|
|
data.cartInfo.noLimitCode = true;
|
|
|
break;
|
|
|
case 3: // 开售后,商品已经售罄
|
|
|
data.noLimitGoodsBtn = true;
|
|
|
data.cartInfo.soldOut = true;
|
|
|
break;
|
|
|
case 4: // 开售后,立即购买(用户已领取限购码)
|
|
|
data.gotCode = true;
|
|
|
data.cartInfo.canNotBuy = true;
|
|
|
break;
|
|
|
case 5: // 开售前,限购码已被抢光(用户未领取限购码)
|
|
|
data.codeEmpty = true;
|
|
|
data.cartInfo.limitNotForSale = true;
|
|
|
break;
|
|
|
case 6: // 开售前,即将开售(用户已领取限购码)
|
|
|
data.gotCode = true;
|
|
|
data.cartInfo.limitNotForSale = true;
|
|
|
break;
|
|
|
case 7: // 开售后,用户已经用获得的限购码购买过商品
|
|
|
data.gotCode = true;
|
|
|
data.cartInfo.noLimitCode = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 根据设备类型获得限购商品跳转app的url
|
|
|
* @param {string} productCode 限购商品码
|
|
|
* @param {string} skn 限购商品skn
|
|
|
* @return {string} 限购商品跳转url
|
|
|
*/
|
|
|
const _getLimitCodeUrl = (productCode, skn, ua) => {
|
|
|
let url = 'yohoapp://yoho.app/openwith?limit_product_code=' + productCode +
|
|
|
'&product_skn=' + skn;
|
|
|
|
|
|
let isIphone = String(ua).indexOf('iPhone') >= 0;
|
|
|
let isIpad = ua.indexOf('iPad') >= 0;
|
|
|
|
|
|
if (isIphone || isIpad) {
|
|
|
let params = {};
|
|
|
|
|
|
params.lp = productCode;
|
|
|
url = 'yohobuy://' + helpers.urlFormat('/limitpurchase', params);
|
|
|
}
|
|
|
return url;
|
|
|
};
|
|
|
|
|
|
const _detailDataPkg = (origin, uid, vipLevel, ua) => {
|
|
|
let dest = {}, // 结果输出
|
|
|
thumbImageList = [],
|
|
|
colorGroup = {},
|
|
|
sizeGroup = [],
|
|
|
totalStorageNum = 0;
|
|
|
|
|
|
// 商品名称
|
|
|
if (!origin.productName) {
|
|
|
dest.feedbacks = {};
|
|
|
return dest;
|
|
|
}
|
|
|
|
|
|
dest.goodsName = origin.productName;
|
|
|
|
|
|
// 是否是虚拟商品
|
|
|
dest.virtualGoods = (origin.attribute * 1 === 3);
|
|
|
|
|
|
// 用户未登录时
|
|
|
if (!uid) {
|
|
|
dest.loginUrl = helpers.urlFormat('/signin.html', {
|
|
|
refer: helpers.urlFormat('/product/show_' + origin.productSkn + '.html')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品促销短语
|
|
|
origin.salesPhrase && (dest.goodsSubtitle = origin.salesPhrase);
|
|
|
|
|
|
// 促销信息 TODO: 换新接口
|
|
|
if (origin.promotionBoList) {
|
|
|
let discountList = [];
|
|
|
|
|
|
_.forEach(origin.promotionBoList, function(value) {
|
|
|
discountList.push({
|
|
|
text: `【${value.promotionType}】${value.promotionTitle}`
|
|
|
});
|
|
|
});
|
|
|
|
|
|
discountList.length && (dest.goodsDiscount = {
|
|
|
list: discountList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品标签
|
|
|
if (origin.tags) {
|
|
|
let productTags = {};
|
|
|
|
|
|
_.forEach(origin.tags, function(value) {
|
|
|
productTags[value] = true;
|
|
|
});
|
|
|
|
|
|
dest.tags = productTags;
|
|
|
}
|
|
|
|
|
|
// 商品价格
|
|
|
let goodsPrice = {
|
|
|
currentPrice: origin.formatSalesPrice === '0' ? origin.formatMarketPrice : origin.formatSalesPrice
|
|
|
};
|
|
|
|
|
|
if (origin.formatSalesPrice !== '0' && origin.formatMarketPrice !== origin.formatSalesPrice) {
|
|
|
goodsPrice.previousPrice = origin.formatMarketPrice;
|
|
|
}
|
|
|
|
|
|
dest.goodsPrice = goodsPrice;
|
|
|
|
|
|
// 商品返回 YOHO 币
|
|
|
origin.yohoCoinNum && (dest.commodityReturn = origin.yohoCoinNum);
|
|
|
|
|
|
// VIP 商品价格
|
|
|
if (origin.vip) {
|
|
|
let vipList = [];
|
|
|
let levelList = {
|
|
|
银卡: 1,
|
|
|
金卡: 2,
|
|
|
白金: 3
|
|
|
};
|
|
|
|
|
|
_.forEach(origin.vip, function(value) {
|
|
|
vipList.push({
|
|
|
level: levelList[value.caption],
|
|
|
text: value.price,
|
|
|
currentLevel: (levelList[value.caption] === parseInt(vipLevel, 10))
|
|
|
});
|
|
|
});
|
|
|
|
|
|
vipList.length && (dest.vipLevel = {
|
|
|
list: vipList
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
origin.expectArrivalTime && (dest.periodOfMarket = `${origin.expectArrivalTime}月`);
|
|
|
|
|
|
// 商品咨询
|
|
|
dest.feedbacks = {
|
|
|
consults: [],
|
|
|
consultsNum: 0
|
|
|
};
|
|
|
|
|
|
let consultParams = {
|
|
|
product_id: origin.productId
|
|
|
};
|
|
|
|
|
|
if (_.has(dest, 'feedbacks.consultsNum')) {
|
|
|
consultParams.total = dest.feedbacks.consultsNum;
|
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', consultParams);
|
|
|
} else {
|
|
|
dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams);
|
|
|
}
|
|
|
|
|
|
// 商品评价
|
|
|
dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', {
|
|
|
product_id: origin.productId,
|
|
|
});
|
|
|
|
|
|
// 品牌信息
|
|
|
if (origin.brand) {
|
|
|
let extra = `?productSkn=${origin.productSkn}&brandId=${origin.brandInfo.brandId}`;
|
|
|
|
|
|
dest.preferenceUrl = `/product/detail/preference${extra}`;
|
|
|
}
|
|
|
|
|
|
dest.productSkn = origin.productSkn;
|
|
|
|
|
|
// 商品信息
|
|
|
if (origin.goodsList) {
|
|
|
let goodsGroup = [],
|
|
|
sizeName = '',
|
|
|
colorList = [],
|
|
|
sizeList = {},
|
|
|
allSizeList = {},
|
|
|
colorStorageGroup = {},
|
|
|
colorStorageNum = 0;
|
|
|
|
|
|
_.forEach(origin.goodsList, function(value) {
|
|
|
if (value.status === 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
colorStorageNum = 0;
|
|
|
|
|
|
// 商品分组
|
|
|
if (value.imagesList) {
|
|
|
_.forEach(value.imagesList, function(good) {
|
|
|
goodsGroup.push({
|
|
|
goodsId: value.goodsId,
|
|
|
img: good.imageUrl
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品的尺码列表
|
|
|
colorStorageGroup[value.productSkc] = {};
|
|
|
if (value.sizeList) {
|
|
|
sizeList[value.productSkc] = [];
|
|
|
_.forEach(value.sizeList, function(size) {
|
|
|
sizeList[value.productSkc].push({
|
|
|
id: size.sizeId,
|
|
|
skuId: size.productSku,
|
|
|
goodsId: value.goodsId,
|
|
|
colorId: value.colorId,
|
|
|
name: size.sizeName,
|
|
|
sizeNum: size.storageNumber
|
|
|
});
|
|
|
|
|
|
sizeName = size.sizeName;
|
|
|
|
|
|
// 所有尺码列表,赋值用于前端展示默认尺码的时候
|
|
|
// 判断出没有库存则显示灰色
|
|
|
let build = {
|
|
|
id: size.sizeId,
|
|
|
storage: size.storageNumber
|
|
|
};
|
|
|
|
|
|
allSizeList[sizeName] = (allSizeList[sizeName] === null ||
|
|
|
typeof allSizeList[sizeName] === 'undefined') ? build : allSizeList[sizeName];
|
|
|
colorStorageNum += parseInt(size.storageNumber, 10);
|
|
|
colorStorageGroup[value.productSkc][sizeName] = parseInt(size.storageNumber, 10);
|
|
|
});
|
|
|
|
|
|
// 颜色分组
|
|
|
colorList.push({
|
|
|
id: value.colorId,
|
|
|
skcId: value.productSkc,
|
|
|
name: value.colorName,
|
|
|
colorNum: colorStorageNum
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 缩略图
|
|
|
thumbImageList.push({
|
|
|
img: value.colorImage
|
|
|
});
|
|
|
|
|
|
// 商品库存总数
|
|
|
totalStorageNum += _.toNumber(colorStorageNum);
|
|
|
});
|
|
|
|
|
|
// 遍历所有尺码,构建颜色显示数据
|
|
|
let i = 1;
|
|
|
|
|
|
sizeGroup[0] = {
|
|
|
size: []
|
|
|
};
|
|
|
_.forEach(allSizeList, (value, key) => {
|
|
|
// 默认尺码
|
|
|
sizeGroup[0].size.push({
|
|
|
name: key,
|
|
|
sizeNum: _.toNumber(value.storage) > 0 ? true : false,
|
|
|
id: value.id
|
|
|
});
|
|
|
|
|
|
colorGroup[i] = {
|
|
|
color: []
|
|
|
};
|
|
|
|
|
|
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
|
|
|
_.forEach(colorList, (colorArr) => {
|
|
|
let tempColorArr = _.cloneDeep(colorArr);
|
|
|
|
|
|
if (colorStorageGroup[tempColorArr.skcId] &&
|
|
|
colorStorageGroup[tempColorArr.skcId][key]) {
|
|
|
tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key];
|
|
|
} else {
|
|
|
tempColorArr.colorNum = 0;
|
|
|
}
|
|
|
colorGroup[i].color.push(Object.assign({}, tempColorArr));
|
|
|
});
|
|
|
colorGroup[i].id = value.id;
|
|
|
|
|
|
++i;
|
|
|
});
|
|
|
|
|
|
colorGroup[0] = {
|
|
|
color: []
|
|
|
};
|
|
|
|
|
|
// 遍历所有颜色, 构建尺码显示数据
|
|
|
i = 1;
|
|
|
_.forEach(colorList, function(value) {
|
|
|
// 各个尺码的颜色, 每行显示一个颜色的对应尺码
|
|
|
sizeGroup[i] = {
|
|
|
size: sizeList[value.skcId],
|
|
|
colorId: value.skcId
|
|
|
};
|
|
|
|
|
|
// 默认颜色
|
|
|
colorGroup[0].color.push(value);
|
|
|
++i;
|
|
|
});
|
|
|
|
|
|
|
|
|
// 商品图:多个
|
|
|
if (goodsGroup.length > 1) {
|
|
|
let bannerList = [];
|
|
|
|
|
|
_.forEach(goodsGroup, function(value) {
|
|
|
bannerList.push({
|
|
|
img: value.img
|
|
|
});
|
|
|
});
|
|
|
|
|
|
dest.bannerTop = {
|
|
|
list: bannerList
|
|
|
};
|
|
|
} else if (goodsGroup[0]) {
|
|
|
dest.bannerTop = {
|
|
|
img: goodsGroup[0].img
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 悬浮的购物车信息
|
|
|
dest.cartInfo = {
|
|
|
cartUrl: helpers.urlFormat('/cart/index/index'),
|
|
|
numInCart: 0,
|
|
|
goodsInstore: origin.storageSum
|
|
|
};
|
|
|
let soldOut = (origin.storageSum === 0) || (totalStorageNum === 0); // status
|
|
|
let notForSale = origin.attribute === 2;
|
|
|
|
|
|
// 显示加入购物车链接
|
|
|
if (!soldOut && !notForSale) {
|
|
|
_.orderBy(colorGroup);
|
|
|
|
|
|
Object.assign(dest.cartInfo, {
|
|
|
productId: origin.productId,
|
|
|
thumbs: thumbImageList,
|
|
|
name: dest.goodsName ? dest.goodsName : '',
|
|
|
price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
|
|
|
salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '',
|
|
|
totalNum: totalStorageNum,
|
|
|
colors: _.toArray(colorGroup),
|
|
|
sizes: sizeGroup
|
|
|
});
|
|
|
|
|
|
// 限购商品
|
|
|
if (origin.isLimitBuy) {
|
|
|
// 是否开售
|
|
|
let isBeginSale = (origin.saleStatus === 1);
|
|
|
|
|
|
// 限购商品有关的展示状态
|
|
|
let showStatus = 1;
|
|
|
|
|
|
origin.showStatus && (showStatus = parseInt(origin.showStatus, 10));
|
|
|
|
|
|
// 处理限购商品有关的按钮状态
|
|
|
dest = _procShowStatus(dest, showStatus, isBeginSale);
|
|
|
|
|
|
dest.cartInfo.limitProductCode = origin.limitProductCode;
|
|
|
dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.productSkn, ua);
|
|
|
dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure');
|
|
|
} else {
|
|
|
dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.productId + '_' +
|
|
|
origin.goodsList.goodsId + '.html');
|
|
|
}
|
|
|
} else if (notForSale) {
|
|
|
dest.cartInfo.notForSale = true;
|
|
|
} else if (soldOut) {
|
|
|
dest.cartInfo.soldOut = true;
|
|
|
}
|
|
|
|
|
|
// 是否收藏
|
|
|
dest.isCollect = false;
|
|
|
if (origin.isCollect === 'Y') {
|
|
|
dest.isCollect = true;
|
|
|
dest.cartInfo.isCollect = true;
|
|
|
}
|
|
|
|
|
|
// 底部简介URL链接
|
|
|
dest.introUrl = '/product/detail/intro/' + origin.productSkn;
|
|
|
dest.id = origin.productId;
|
|
|
|
|
|
// 虚拟商品(门票)
|
|
|
if (origin.attribute * 1 === 3) {
|
|
|
dest.tickets = true;
|
|
|
dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm');
|
|
|
|
|
|
// 展览票
|
|
|
if (origin.productSkn * 1 === SINGLE_TICKETS_SKN) {
|
|
|
dest.single = true;
|
|
|
} else {
|
|
|
// 套票
|
|
|
dest.package = true;
|
|
|
}
|
|
|
|
|
|
// 购票限制
|
|
|
dest.cartInfo.limit = 4;
|
|
|
|
|
|
// 清空活动
|
|
|
dest.goodsDiscount = [];
|
|
|
|
|
|
// 来自登录页,自动弹出选择框
|
|
|
// if (isset($_GET['product_type']) && $_GET['product_type'] == 'ticket') {
|
|
|
// $result['showPannel'] = true;
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
let _getShopsInfo = (brandId) => {
|
|
|
if (!brandId) {
|
|
|
return Promise.resolve([]);
|
|
|
}
|
|
|
return api.get('', {
|
|
|
method: 'app.shop.queryShopsByBrandId',
|
|
|
brand_id: _.toString(brandId)
|
|
|
}, {
|
|
|
cache: true
|
|
|
}).then(shops => {
|
|
|
if (shops && shops.code === 200) {
|
|
|
return _processShopsInfo(shops.data);
|
|
|
}
|
|
|
|
|
|
return [];
|
|
|
});
|
|
|
};
|
|
|
|
|
|
let _getPromotionInfo = (skn) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.product.promotion',
|
|
|
product_skn: _.toString(skn)
|
|
|
}, {
|
|
|
code: 200,
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
return result && result.data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取默认咨询列表
|
|
|
*/
|
|
|
const _getCommonConsult = () => {
|
|
|
let params = {
|
|
|
method: 'app.consult.common'
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
let data = {};
|
|
|
|
|
|
if (result.data) {
|
|
|
data = result.data;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取秒杀列表
|
|
|
*/
|
|
|
const getSeckillData = (param) => {
|
|
|
let params = {
|
|
|
method: 'app.seckill.data',
|
|
|
product_skn: param.productskn
|
|
|
};
|
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
})
|
|
|
|
|
|
// mock
|
|
|
.catch()
|
|
|
.then(result => {
|
|
|
let data = {};
|
|
|
|
|
|
if (result.data) {
|
|
|
data = result.data;
|
|
|
} else {
|
|
|
data.status = 0;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
let getProductData = (data) => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
let params = {
|
|
|
method: 'app.product.data'
|
|
|
};
|
|
|
|
|
|
if (data.id) { // 通过 productId 获取商品详情
|
|
|
Object.assign(params, {
|
|
|
product_id: _.toString(data.id)
|
|
|
});
|
|
|
} else if (data.productSkn) { // 通过 productSkn 获取商品详情
|
|
|
Object.assign(params, {
|
|
|
product_skn: _.toString(data.productSkn)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (data.uid) {
|
|
|
params.uid = data.uid;
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
params.is_student = data.isStudent ? 1 : 0;
|
|
|
params.current_vip_level = data.vipLevel;
|
|
|
|
|
|
return api.get('', params, {
|
|
|
code: 200
|
|
|
}).then(global.yoho.camelCase).then(result => {
|
|
|
if (result.code === 500 || !result.data) {
|
|
|
return {};
|
|
|
}
|
|
|
result = result.data;
|
|
|
|
|
|
return Promise.all([
|
|
|
_getShopsInfo(_.get(result, 'brandInfo.brandId', 0)),
|
|
|
_getPromotionInfo(result.productSkn),
|
|
|
comment.getCommentInfo({
|
|
|
productId: result.productId
|
|
|
}),
|
|
|
_getCommonConsult(),
|
|
|
comment.getConsults(result.productId, 1, 2)
|
|
|
]).then((info) => {
|
|
|
result.promotionBoList = info[1];
|
|
|
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
|
|
|
finalResult.enterStore = info[0];
|
|
|
finalResult.isStudent = data.isStudent;
|
|
|
Object.assign(finalResult.feedbacks, info[2]);
|
|
|
Object.assign(finalResult, {isSecKill: result.isSecKill});
|
|
|
|
|
|
/* 预售商品不能购买 */
|
|
|
if (_.get(result, 'isDepositAdvance', '') === 'Y') {
|
|
|
finalResult.cartInfo.isDepositAdvance = true;
|
|
|
}
|
|
|
|
|
|
/* 如果有咨询,显示咨询,否则显示常见问题 */
|
|
|
|
|
|
if (info[4].total) {
|
|
|
finalResult.feedbacks.consultsNum = parseInt(info[4].total, 10);
|
|
|
|
|
|
Object.assign(finalResult.feedbacks, {
|
|
|
commonConsults: false,
|
|
|
consultsNum: parseInt(info[4].total, 10),
|
|
|
consults: _.take(info[4].list, 2)
|
|
|
});
|
|
|
} else if (!_.isEmpty(info[3]) && !_.get(info[2], 'feedbacks.consultsNum', 0)) {
|
|
|
Object.assign(finalResult.feedbacks, {
|
|
|
commonConsults: true,
|
|
|
consultsNum: true,
|
|
|
consults: _.take(info[3], 2)
|
|
|
});
|
|
|
}
|
|
|
finalResult.limit = info[2];
|
|
|
return finalResult;
|
|
|
});
|
|
|
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* [根据商品SKN获取商品的简要信息]
|
|
|
* @param {[array]} skns [skns]
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
let _productInfoBySkns = (skns) => {
|
|
|
// 调用搜索接口
|
|
|
let param = {
|
|
|
method: 'app.search.li',
|
|
|
query: skns.join(' '),
|
|
|
limit: skns.length,
|
|
|
order: 's_t_desc'
|
|
|
};
|
|
|
|
|
|
return api.get('', param, {
|
|
|
cache: true
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getProductData,
|
|
|
getUserProfile: _getUserProfile,
|
|
|
getSeckillData,
|
|
|
productInfoBySkns: _productInfoBySkns
|
|
|
}; |
...
|
...
|
|