|
@@ -37,7 +37,7 @@ const tdk = require('../../../utils/getTDK'); |
|
@@ -37,7 +37,7 @@ const tdk = require('../../../utils/getTDK'); |
37
|
const productProcess = require('../../../utils/product-process');
|
37
|
const productProcess = require('../../../utils/product-process');
|
38
|
|
38
|
|
39
|
function _getProductAdditionInfoAsync(data) {
|
39
|
function _getProductAdditionInfoAsync(data) {
|
40
|
- return co(function * () {
|
40
|
+ return co(function* () {
|
41
|
let productId = _.get(data, 'product_id', 0);
|
41
|
let productId = _.get(data, 'product_id', 0);
|
42
|
let brandId = _.get(data, 'brand_info.brand_id', 0);
|
42
|
let brandId = _.get(data, 'brand_info.brand_id', 0);
|
43
|
|
43
|
|
|
@@ -54,7 +54,7 @@ function _getProductAdditionInfoAsync(data) { |
|
@@ -54,7 +54,7 @@ function _getProductAdditionInfoAsync(data) { |
54
|
}
|
54
|
}
|
55
|
|
55
|
|
56
|
function _getProductIntroAsync(productId, productSkn) {
|
56
|
function _getProductIntroAsync(productId, productSkn) {
|
57
|
- return co(function * () {
|
57
|
+ return co(function* () {
|
58
|
let result = yield Promise.props({
|
58
|
let result = yield Promise.props({
|
59
|
sizeInfo: this.productAPI.sizeInfoAsync(productSkn),
|
59
|
sizeInfo: this.productAPI.sizeInfoAsync(productSkn),
|
60
|
productComfort: this.productAPI.getProductComfortAsync(productId),
|
60
|
productComfort: this.productAPI.getProductComfortAsync(productId),
|
|
@@ -71,7 +71,7 @@ function _getProductIntroAsync(productId, productSkn) { |
|
@@ -71,7 +71,7 @@ function _getProductIntroAsync(productId, productSkn) { |
71
|
* bid : brand id
|
71
|
* bid : brand id
|
72
|
*/
|
72
|
*/
|
73
|
function _getProductFavoriteDataAsync(uid, pid) {
|
73
|
function _getProductFavoriteDataAsync(uid, pid) {
|
74
|
- return co(function*() {
|
74
|
+ return co(function* () {
|
75
|
let result = {
|
75
|
let result = {
|
76
|
product: false,
|
76
|
product: false,
|
77
|
brand: false
|
77
|
brand: false
|
|
@@ -241,7 +241,7 @@ function _getSkuDataByProductBaseInfo(data) { |
|
@@ -241,7 +241,7 @@ function _getSkuDataByProductBaseInfo(data) { |
241
|
};
|
241
|
};
|
242
|
}
|
242
|
}
|
243
|
|
243
|
|
244
|
- skuGoods = _.get(data, 'goods_list', []).reduce((goodsDetailList, goods)=> {
|
244
|
+ skuGoods = _.get(data, 'goods_list', []).reduce((goodsDetailList, goods) => {
|
245
|
|
245
|
|
246
|
// 如果status为0,即skc下架时就跳过该商品$value['status'] === 0
|
246
|
// 如果status为0,即skc下架时就跳过该商品$value['status'] === 0
|
247
|
let goodsDetail = {};
|
247
|
let goodsDetail = {};
|
|
@@ -579,7 +579,7 @@ function _sizeInfoBoSort(sizeInfoBo) { |
|
@@ -579,7 +579,7 @@ function _sizeInfoBoSort(sizeInfoBo) { |
579
|
return {};
|
579
|
return {};
|
580
|
}
|
580
|
}
|
581
|
|
581
|
|
582
|
- _.get(sizeInfoBo, 'sizeBoList', []).forEach((sizeBoList, sizek)=> {
|
582
|
+ _.get(sizeInfoBo, 'sizeBoList', []).forEach((sizeBoList, sizek) => {
|
583
|
let sortAttr = {};
|
583
|
let sortAttr = {};
|
584
|
|
584
|
|
585
|
sizeBoList.sortAttributes.forEach(sortAttributes => {
|
585
|
sizeBoList.sortAttributes.forEach(sortAttributes => {
|
|
@@ -589,7 +589,7 @@ function _sizeInfoBoSort(sizeInfoBo) { |
|
@@ -589,7 +589,7 @@ function _sizeInfoBoSort(sizeInfoBo) { |
589
|
sizeInfoBo.sizeBoList[sizek].sortAttributes = sortAttr;
|
589
|
sizeInfoBo.sizeBoList[sizek].sortAttributes = sortAttr;
|
590
|
});
|
590
|
});
|
591
|
|
591
|
|
592
|
- _.get(sizeInfoBo, 'sizeBoList', []).forEach((sizeBoList, sizek)=> {
|
592
|
+ _.get(sizeInfoBo, 'sizeBoList', []).forEach((sizeBoList, sizek) => {
|
593
|
let sortAttr = [];
|
593
|
let sortAttr = [];
|
594
|
|
594
|
|
595
|
sizeInfoBo.sizeAttributeBos.forEach(val => {
|
595
|
sizeInfoBo.sizeAttributeBos.forEach(val => {
|
|
@@ -991,7 +991,7 @@ function _getCoupon(coupons) { |
|
@@ -991,7 +991,7 @@ function _getCoupon(coupons) { |
991
|
|
991
|
|
992
|
let pickProp = Fn.pick(['couponName', 'amount', 'couponId', 'acquireStatus', 'rule4ShortName']);
|
992
|
let pickProp = Fn.pick(['couponName', 'amount', 'couponId', 'acquireStatus', 'rule4ShortName']);
|
993
|
let encodeId = Fn.update('couponId', (cid) => crypto.encryption(null, cid + ''));
|
993
|
let encodeId = Fn.update('couponId', (cid) => crypto.encryption(null, cid + ''));
|
994
|
- let replace = Fn.update('rule4ShortName', (r)=> r.replace(/¥/g, '¥'));
|
994
|
+ let replace = Fn.update('rule4ShortName', (r) => r.replace(/¥/g, '¥'));
|
995
|
|
995
|
|
996
|
return Fn.map(Fn.pipe(pickProp, encodeId, replace))(couponList);
|
996
|
return Fn.map(Fn.pipe(pickProp, encodeId, replace))(couponList);
|
997
|
}
|
997
|
}
|
|
@@ -1020,7 +1020,7 @@ function _isOfflineSell(status) { |
|
@@ -1020,7 +1020,7 @@ function _isOfflineSell(status) { |
1020
|
* @return result Object 格式化数据
|
1020
|
* @return result Object 格式化数据
|
1021
|
*/
|
1021
|
*/
|
1022
|
function _detailDataPkg(origin, uid, vipLevel, cookies) {
|
1022
|
function _detailDataPkg(origin, uid, vipLevel, cookies) {
|
1023
|
- return co(function*() {
|
1023
|
+ return co(function* () {
|
1024
|
if (_.isEmpty(origin) || _.isEmpty(origin.data)) {
|
1024
|
if (_.isEmpty(origin) || _.isEmpty(origin.data)) {
|
1025
|
return {};
|
1025
|
return {};
|
1026
|
}
|
1026
|
}
|
|
@@ -1101,6 +1101,12 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
|
@@ -1101,6 +1101,12 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
1101
|
// 店铺推荐直出(seo需要)
|
1101
|
// 店铺推荐直出(seo需要)
|
1102
|
requestApi.shopRecommend = this.productAPI.getShopRecommendAsync(result.skn);
|
1102
|
requestApi.shopRecommend = this.productAPI.getShopRecommendAsync(result.skn);
|
1103
|
|
1103
|
|
|
|
1104
|
+ // 新品推荐
|
|
|
1105
|
+ requestApi.newProduct = this.productAPI.getNewProduct(result.smallSortId);
|
|
|
1106
|
+
|
|
|
1107
|
+ // 文章推荐
|
|
|
1108
|
+ requestApi.articles = this.productAPI.getGuangArticles(result.skn);
|
|
|
1109
|
+
|
1104
|
let requestData = yield Promise.props(requestApi);
|
1110
|
let requestData = yield Promise.props(requestApi);
|
1105
|
|
1111
|
|
1106
|
let additionalData = requestData.addition;
|
1112
|
let additionalData = requestData.addition;
|
|
@@ -1112,6 +1118,14 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
|
@@ -1112,6 +1118,14 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
1112
|
let recommendKeywords = JSON.parse(requestData.recommendAsync || '[]');
|
1118
|
let recommendKeywords = JSON.parse(requestData.recommendAsync || '[]');
|
1113
|
let shopRecommend = requestData.shopRecommend;
|
1119
|
let shopRecommend = requestData.shopRecommend;
|
1114
|
let alike = requestData.alike;
|
1120
|
let alike = requestData.alike;
|
|
|
1121
|
+ let newProduct = requestData.newProduct;
|
|
|
1122
|
+ let articles = requestData.articles;
|
|
|
1123
|
+
|
|
|
1124
|
+ // 文章推荐
|
|
|
1125
|
+ result.recommendArticles = articles;
|
|
|
1126
|
+
|
|
|
1127
|
+ // 推荐最新商品
|
|
|
1128
|
+ result.recommendNewProducts = newProduct;
|
1115
|
|
1129
|
|
1116
|
// 处理相似商品
|
1130
|
// 处理相似商品
|
1117
|
result.alike = productProcess.processProductList(
|
1131
|
result.alike = productProcess.processProductList(
|
|
@@ -1405,8 +1419,8 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
|
@@ -1405,8 +1419,8 @@ function _detailDataPkg(origin, uid, vipLevel, cookies) { |
1405
|
statGoodsInfo.productName = result.name.replace('\'', '’');
|
1419
|
statGoodsInfo.productName = result.name.replace('\'', '’');
|
1406
|
statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’');
|
1420
|
statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’');
|
1407
|
statGoodsInfo.marketPrice = (result.marketPrice ?
|
1421
|
statGoodsInfo.marketPrice = (result.marketPrice ?
|
1408
|
- result.marketPrice :
|
|
|
1409
|
- result.presalePrice).replace('¥', ''); // 数字
|
1422
|
+ result.marketPrice :
|
|
|
1423
|
+ result.presalePrice).replace('¥', ''); // 数字
|
1410
|
statGoodsInfo.salePrice = (result.salePrice ?
|
1424
|
statGoodsInfo.salePrice = (result.salePrice ?
|
1411
|
result.salePrice :
|
1425
|
result.salePrice :
|
1412
|
(result.marketPrice || result.presalePrice)).replace('¥', ''); // 数字
|
1426
|
(result.marketPrice || result.presalePrice)).replace('¥', ''); // 数字
|
|
@@ -1497,7 +1511,7 @@ function _removeSalePrice(productInfo) { |
|
@@ -1497,7 +1511,7 @@ function _removeSalePrice(productInfo) { |
1497
|
* 获取某一个商品详情主页面
|
1511
|
* 获取某一个商品详情主页面
|
1498
|
*/
|
1512
|
*/
|
1499
|
function showMainAsync(req, data) {
|
1513
|
function showMainAsync(req, data) {
|
1500
|
- return co(function * () {
|
1514
|
+ return co(function* () {
|
1501
|
// 获取商品基本信息
|
1515
|
// 获取商品基本信息
|
1502
|
let productData = yield this.productAPI.getProductAsync(
|
1516
|
let productData = yield this.productAPI.getProductAsync(
|
1503
|
{skn: data.skn}, data.uid, data.isStudent, data.vipLevel
|
1517
|
{skn: data.skn}, data.uid, data.isStudent, data.vipLevel
|
|
@@ -1519,10 +1533,10 @@ function showMainAsync(req, data) { |
|
@@ -1519,10 +1533,10 @@ function showMainAsync(req, data) { |
1519
|
);
|
1533
|
);
|
1520
|
|
1534
|
|
1521
|
let requestData = yield Promise.all([
|
1535
|
let requestData = yield Promise.all([
|
1522
|
- HeaderModel.requestHeaderData(data.channel), // 通用头部数据
|
1536
|
+ HeaderModel.requestHeaderData(data.channel), // 通用头部数据
|
1523
|
_getProductIntroAsync.call(this, productId, productSkn), // 商品详细介绍
|
1537
|
_getProductIntroAsync.call(this, productId, productSkn), // 商品详细介绍
|
1524
|
- curUserProduct.call(this, productData), // 商品详细价格
|
|
|
1525
|
- tdk('skn', data.skn, req) // seo
|
1538
|
+ curUserProduct.call(this, productData), // 商品详细价格
|
|
|
1539
|
+ tdk('skn', data.skn, req) // seo
|
1526
|
]);
|
1540
|
]);
|
1527
|
|
1541
|
|
1528
|
let navigatorHeader = requestData[0];
|
1542
|
let navigatorHeader = requestData[0];
|
|
@@ -1589,7 +1603,7 @@ function showMainAsync(req, data) { |
|
@@ -1589,7 +1603,7 @@ function showMainAsync(req, data) { |
1589
|
* 获取某一个商品详情主页面
|
1603
|
* 获取某一个商品详情主页面
|
1590
|
*/
|
1604
|
*/
|
1591
|
function showMainBackAsync(data) {
|
1605
|
function showMainBackAsync(data) {
|
1592
|
- return co(function * () {
|
1606
|
+ return co(function* () {
|
1593
|
|
1607
|
|
1594
|
// 获取商品基本信息
|
1608
|
// 获取商品基本信息
|
1595
|
let productData = yield this.productAPI.getProductAsync({pid: data.pid});
|
1609
|
let productData = yield this.productAPI.getProductAsync({pid: data.pid});
|
|
@@ -1600,7 +1614,7 @@ function showMainBackAsync(data) { |
|
@@ -1600,7 +1614,7 @@ function showMainBackAsync(data) { |
1600
|
|
1614
|
|
1601
|
|
1615
|
|
1602
|
function recommendAsync(skn, page, limit) {
|
1616
|
function recommendAsync(skn, page, limit) {
|
1603
|
- return co(function * () {
|
1617
|
+ return co(function* () {
|
1604
|
let recommendData = yield this.productAPI.getShopRecommendAsync(skn, page, limit);
|
1618
|
let recommendData = yield this.productAPI.getShopRecommendAsync(skn, page, limit);
|
1605
|
|
1619
|
|
1606
|
if (_.get(recommendData, 'code', 400) !== 200) {
|
1620
|
if (_.get(recommendData, 'code', 400) !== 200) {
|
|
@@ -1705,7 +1719,6 @@ function getPackage(skn) { |
|
@@ -1705,7 +1719,6 @@ function getPackage(skn) { |
1705
|
}).bind(this)();
|
1719
|
}).bind(this)();
|
1706
|
}
|
1720
|
}
|
1707
|
|
1721
|
|
1708
|
-
|
|
|
1709
|
module.exports = class extends global.yoho.BaseModel {
|
1722
|
module.exports = class extends global.yoho.BaseModel {
|
1710
|
constructor(ctx) {
|
1723
|
constructor(ctx) {
|
1711
|
super(ctx);
|
1724
|
super(ctx);
|