|
@@ -30,8 +30,9 @@ const HeaderModel = require('../../../doraemon/models/header'); |
|
@@ -30,8 +30,9 @@ const HeaderModel = require('../../../doraemon/models/header'); |
30
|
|
30
|
|
31
|
const BLANK_STR = ' ';
|
31
|
const BLANK_STR = ' ';
|
32
|
|
32
|
|
33
|
-const multiResourcesUrl = {};
|
|
|
34
|
-const setMultiResourceByProductBaseInfo = (data) => {
|
33
|
+const cachedRequestData = {};
|
|
|
34
|
+
|
|
|
35
|
+const getProductAdditionInfoByProductBaseInfoAsync = (data) => {
|
35
|
return co(function * () {
|
36
|
return co(function * () {
|
36
|
let productId = data.id;
|
37
|
let productId = data.id;
|
37
|
let uid = data.uid ? data.uid : 0;
|
38
|
let uid = data.uid ? data.uid : 0;
|
|
@@ -42,37 +43,38 @@ const setMultiResourceByProductBaseInfo = (data) => { |
|
@@ -42,37 +43,38 @@ const setMultiResourceByProductBaseInfo = (data) => { |
42
|
// 获取相关url
|
43
|
// 获取相关url
|
43
|
|
44
|
|
44
|
let result = yield Promise.all([
|
45
|
let result = yield Promise.all([
|
45
|
- productAPI.getProductBannerAsync(productId, 'web', isOnlyUrl),
|
|
|
46
|
- productAPI.sizeInfoAsync(skn, isOnlyUrl),
|
|
|
47
|
- productAPI.getProductComfortAsync(productId, isOnlyUrl),
|
|
|
48
|
- productAPI.getProductModelCardAsync(productId, isOnlyUrl),
|
|
|
49
|
- productAPI.getProductModelTryAsync(skn, isOnlyUrl),
|
|
|
50
|
- brandService.getBannerInfoAsync(brandId, isOnlyUrl)
|
46
|
+ productAPI.getProductBannerAsync(productId, 'web'),
|
|
|
47
|
+ productAPI.sizeInfoAsync(skn),
|
|
|
48
|
+ productAPI.getProductComfortAsync(productId),
|
|
|
49
|
+ productAPI.getProductModelCardAsync(productId),
|
|
|
50
|
+ productAPI.getProductModelTryAsync(skn),
|
|
|
51
|
+ brandService.getBannerInfoAsync(brandId)
|
51
|
]);
|
52
|
]);
|
52
|
|
53
|
|
53
|
- multiResourcesUrl['ItemData::getProductBanner'] = result[0];
|
|
|
54
|
- multiResourcesUrl['ItemData::sizeInfo'] = result[1];
|
|
|
55
|
- multiResourcesUrl['ItemData::getProductComfort'] = result[2];
|
|
|
56
|
- multiResourcesUrl['ItemData::getProductModelCard'] = result[3];
|
|
|
57
|
- multiResourcesUrl['ItemData::getProductModelTry'] = result[4];
|
|
|
58
|
- multiResourcesUrl['BrandData::getBannerInfo'] = result[5];
|
54
|
+ cachedRequestData['ItemData::getProductBanner'] = result[0];
|
|
|
55
|
+ cachedRequestData['ItemData::sizeInfo'] = result[1];
|
|
|
56
|
+ cachedRequestData['ItemData::getProductComfort'] = result[2];
|
|
|
57
|
+ cachedRequestData['ItemData::getProductModelCard'] = result[3];
|
|
|
58
|
+ cachedRequestData['ItemData::getProductModelTry'] = result[4];
|
|
|
59
|
+ cachedRequestData['BrandData::getBannerInfo'] = result[5];
|
59
|
|
60
|
|
60
|
if (uid) {
|
61
|
if (uid) {
|
61
|
- multiResourcesUrl['FavoriteData::getUidProductFav'] =
|
62
|
+ cachedRequestData['FavoriteData::getUidProductFav'] =
|
62
|
yield favoriteProductService.isFavoriteAsync(uid, productId, isOnlyUrl);
|
63
|
yield favoriteProductService.isFavoriteAsync(uid, productId, isOnlyUrl);
|
63
|
}
|
64
|
}
|
|
|
65
|
+
|
|
|
66
|
+ return null;
|
64
|
})();
|
67
|
})();
|
65
|
};
|
68
|
};
|
66
|
|
69
|
|
67
|
-function getMultiDataByResourceName(resourceName) {
|
|
|
68
|
- return multiResourcesUrl[resourceName] || false;
|
70
|
+function getCacheDataByName(resourceName) {
|
|
|
71
|
+ return cachedRequestData[resourceName] || false;
|
69
|
}
|
72
|
}
|
70
|
|
73
|
|
71
|
-
|
|
|
72
|
/**
|
74
|
/**
|
73
|
* 获取商品的喜欢
|
75
|
* 获取商品的喜欢
|
74
|
*/
|
76
|
*/
|
75
|
-const getProductFavoriteData = (uid, pid, bid) => {
|
77
|
+const getProductFavoriteDataAsync = (uid, pid, bid) => {
|
76
|
return co(function*() {
|
78
|
return co(function*() {
|
77
|
|
79
|
|
78
|
let result = {
|
80
|
let result = {
|
|
@@ -82,7 +84,7 @@ const getProductFavoriteData = (uid, pid, bid) => { |
|
@@ -82,7 +84,7 @@ const getProductFavoriteData = (uid, pid, bid) => { |
82
|
|
84
|
|
83
|
if (uid) {
|
85
|
if (uid) {
|
84
|
if (pid) {
|
86
|
if (pid) {
|
85
|
- let productData = getMultiDataByResourceName('FavoriteData::getUidProductFav');
|
87
|
+ let productData = getCacheDataByName('FavoriteData::getUidProductFav');
|
86
|
|
88
|
|
87
|
if (!productData) {
|
89
|
if (!productData) {
|
88
|
productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
|
90
|
productData = yield favoriteProductService.isFavoriteAsync(uid, pid);
|
|
@@ -177,16 +179,14 @@ const getVipDataByProductBaseInfo = (data, vipLevel, uid) => { |
|
@@ -177,16 +179,14 @@ const getVipDataByProductBaseInfo = (data, vipLevel, uid) => { |
177
|
return vipData;
|
179
|
return vipData;
|
178
|
};
|
180
|
};
|
179
|
|
181
|
|
180
|
-function getProductActivityBannerAsync(pid) {
|
|
|
181
|
-
|
|
|
182
|
- return co(function*() {
|
182
|
+function getProductActivityBanner() {
|
183
|
|
183
|
|
184
|
let result = {};
|
184
|
let result = {};
|
185
|
|
185
|
|
186
|
- let data = getMultiDataByResourceName('ItemData::getProductBanner');
|
186
|
+ let data = getCacheDataByName('ItemData::getProductBanner');
|
187
|
|
187
|
|
188
|
if (!data) {
|
188
|
if (!data) {
|
189
|
- data = yield productAPI.getProductBannerAsync(pid);
|
189
|
+ return result;
|
190
|
}
|
190
|
}
|
191
|
|
191
|
|
192
|
if (data.code && data.code === 200 && data.data) {
|
192
|
if (data.code && data.code === 200 && data.data) {
|
|
@@ -195,15 +195,12 @@ function getProductActivityBannerAsync(pid) { |
|
@@ -195,15 +195,12 @@ function getProductActivityBannerAsync(pid) { |
195
|
}
|
195
|
}
|
196
|
|
196
|
|
197
|
return result;
|
197
|
return result;
|
198
|
- })();
|
|
|
199
|
}
|
198
|
}
|
200
|
|
199
|
|
201
|
const getActivityDataByProductBaseInfo = (data) => {
|
200
|
const getActivityDataByProductBaseInfo = (data) => {
|
202
|
- return co(function *() {
|
|
|
203
|
-
|
|
|
204
|
let result = [];
|
201
|
let result = [];
|
205
|
|
202
|
|
206
|
- let activityBanner = yield getProductActivityBannerAsync(data.id);
|
203
|
+ let activityBanner = getProductActivityBanner();
|
207
|
|
204
|
|
208
|
if (activityBanner) {
|
205
|
if (activityBanner) {
|
209
|
result.push(activityBanner);
|
206
|
result.push(activityBanner);
|
|
@@ -219,7 +216,6 @@ const getActivityDataByProductBaseInfo = (data) => { |
|
@@ -219,7 +216,6 @@ const getActivityDataByProductBaseInfo = (data) => { |
219
|
}
|
216
|
}
|
220
|
|
217
|
|
221
|
return result;
|
218
|
return result;
|
222
|
- })();
|
|
|
223
|
};
|
219
|
};
|
224
|
|
220
|
|
225
|
/**
|
221
|
/**
|
|
@@ -232,7 +228,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
@@ -232,7 +228,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
232
|
let consultComment = {};
|
228
|
let consultComment = {};
|
233
|
|
229
|
|
234
|
consultComment.consultNum = 0;
|
230
|
consultComment.consultNum = 0;
|
235
|
- consultComment.captchaUrl = helpers.urlFormat('/passport/images', {
|
231
|
+ consultComment.captchaUrl = helpers.urlFormat('passport/images', {
|
236
|
t: moment().valueOf()
|
232
|
t: moment().valueOf()
|
237
|
});
|
233
|
});
|
238
|
|
234
|
|
|
@@ -244,7 +240,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
@@ -244,7 +240,7 @@ const getConsultCommentDataByProductInfo = (data) => { |
244
|
consultComment.commentNum = 0;
|
240
|
consultComment.commentNum = 0;
|
245
|
if (data.commentBoWrapper) {
|
241
|
if (data.commentBoWrapper) {
|
246
|
consultComment.comments = [];
|
242
|
consultComment.comments = [];
|
247
|
- consultComment.commentUrl = helpers.urlFormat('/home/commnet');
|
243
|
+ consultComment.commentUrl = helpers.urlFormat('home/commnet');
|
248
|
}
|
244
|
}
|
249
|
|
245
|
|
250
|
return consultComment;
|
246
|
return consultComment;
|
|
@@ -255,9 +251,6 @@ const getConsultCommentDataByProductInfo = (data) => { |
|
@@ -255,9 +251,6 @@ const getConsultCommentDataByProductInfo = (data) => { |
255
|
* 获取品牌数据
|
251
|
* 获取品牌数据
|
256
|
*/
|
252
|
*/
|
257
|
const getBrandDataByProductBaseInfo = (data) => {
|
253
|
const getBrandDataByProductBaseInfo = (data) => {
|
258
|
-
|
|
|
259
|
- return co(function *() {
|
|
|
260
|
-
|
|
|
261
|
if (!data.brand) {
|
254
|
if (!data.brand) {
|
262
|
return {};
|
255
|
return {};
|
263
|
}
|
256
|
}
|
|
@@ -270,10 +263,10 @@ const getBrandDataByProductBaseInfo = (data) => { |
|
@@ -270,10 +263,10 @@ const getBrandDataByProductBaseInfo = (data) => { |
270
|
|
263
|
|
271
|
let bannerInfo = null;
|
264
|
let bannerInfo = null;
|
272
|
|
265
|
|
273
|
- let result = getMultiDataByResourceName('BrandData::getBannerInfo');
|
266
|
+ let result = getCacheDataByName('BrandData::getBannerInfo');
|
274
|
|
267
|
|
275
|
if (!result) {
|
268
|
if (!result) {
|
276
|
- result = yield brandService.getBannerInfoAsync(brandId);
|
269
|
+ return {};
|
277
|
}
|
270
|
}
|
278
|
|
271
|
|
279
|
if (data.brand.brandIco) {
|
272
|
if (data.brand.brandIco) {
|
|
@@ -310,7 +303,6 @@ const getBrandDataByProductBaseInfo = (data) => { |
|
@@ -310,7 +303,6 @@ const getBrandDataByProductBaseInfo = (data) => { |
310
|
homeUrl: homeUrl,
|
303
|
homeUrl: homeUrl,
|
311
|
isCollect: false
|
304
|
isCollect: false
|
312
|
};
|
305
|
};
|
313
|
- })();
|
|
|
314
|
};
|
306
|
};
|
315
|
|
307
|
|
316
|
/**
|
308
|
/**
|
|
@@ -506,7 +498,6 @@ const getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { |
|
@@ -506,7 +498,6 @@ const getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { |
506
|
/**
|
498
|
/**
|
507
|
* 获取分类导航列表
|
499
|
* 获取分类导航列表
|
508
|
*/
|
500
|
*/
|
509
|
-// controller item.php 32;
|
|
|
510
|
function getSortNavAsync(smallSortId, gender) {
|
501
|
function getSortNavAsync(smallSortId, gender) {
|
511
|
return co(function*() {
|
502
|
return co(function*() {
|
512
|
|
503
|
|
|
@@ -562,10 +553,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -562,10 +553,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
562
|
result.maxSortId = origin.maxSortId;
|
553
|
result.maxSortId = origin.maxSortId;
|
563
|
result.smallSortId = origin.smallSortId;
|
554
|
result.smallSortId = origin.smallSortId;
|
564
|
result.promotionId = origin.isPromotion;
|
555
|
result.promotionId = origin.isPromotion;
|
565
|
- result.goCartUrl = helpers.urlFormat('/shopping/cart');
|
|
|
566
|
-
|
|
|
567
|
- // 接口处理数据,设置并发请求数据
|
|
|
568
|
- yield setMultiResourceByProductBaseInfo(origin);
|
556
|
+ result.goCartUrl = helpers.urlFormat('shopping/cart');
|
569
|
|
557
|
|
570
|
let brandId = 0;
|
558
|
let brandId = 0;
|
571
|
|
559
|
|
|
@@ -573,8 +561,12 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -573,8 +561,12 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
573
|
brandId = origin.brand.id;
|
561
|
brandId = origin.brand.id;
|
574
|
}
|
562
|
}
|
575
|
|
563
|
|
576
|
- // 处理收藏喜欢数据
|
|
|
577
|
- let favoriteData = yield getProductFavoriteData(uid, result.productId, brandId);
|
564
|
+ let requestData = yield Promise.all([
|
|
|
565
|
+ getProductAdditionInfoByProductBaseInfoAsync(origin), // 接口处理数据,设置并发请求数据
|
|
|
566
|
+ getProductFavoriteDataAsync(uid, result.productId, brandId) //处理收藏喜欢数据
|
|
|
567
|
+ ]);
|
|
|
568
|
+
|
|
|
569
|
+ let favoriteData = requestData[1];
|
578
|
|
570
|
|
579
|
// 商品标签
|
571
|
// 商品标签
|
580
|
result.tags = getTagsDataByProductInfo(origin);
|
572
|
result.tags = getTagsDataByProductInfo(origin);
|
|
@@ -599,7 +591,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -599,7 +591,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
599
|
result.vipPrice = getVipDataByProductBaseInfo(origin, vipLevel, uid);
|
591
|
result.vipPrice = getVipDataByProductBaseInfo(origin, vipLevel, uid);
|
600
|
|
592
|
|
601
|
// 促销活动banner
|
593
|
// 促销活动banner
|
602
|
- result.activity = yield getActivityDataByProductBaseInfo(origin);
|
594
|
+ result.activity = getActivityDataByProductBaseInfo(origin);
|
603
|
|
595
|
|
604
|
const C_VALUE = {
|
596
|
const C_VALUE = {
|
605
|
type: '返YOHO币',
|
597
|
type: '返YOHO币',
|
|
@@ -632,7 +624,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -632,7 +624,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
632
|
result.brandImg = helpers.image(origin.brand.brandIco, 47, 47);
|
624
|
result.brandImg = helpers.image(origin.brand.brandIco, 47, 47);
|
633
|
result.brandName = origin.brand.brandName;
|
625
|
result.brandName = origin.brand.brandName;
|
634
|
result.brandUrl = helpers.urlFormat('', {}, origin.brand.brandDomain);
|
626
|
result.brandUrl = helpers.urlFormat('', {}, origin.brand.brandDomain);
|
635
|
- banner = yield getBrandDataByProductBaseInfo(origin);
|
627
|
+ banner = getBrandDataByProductBaseInfo(origin);
|
636
|
if (banner.isCollect && favoriteData.brand) {
|
628
|
if (banner.isCollect && favoriteData.brand) {
|
637
|
banner.isCollect = favoriteData.brand;
|
629
|
banner.isCollect = favoriteData.brand;
|
638
|
}
|
630
|
}
|
|
@@ -661,7 +653,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -661,7 +653,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
661
|
|
653
|
|
662
|
let fashTopGoods = getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
|
654
|
let fashTopGoods = getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
|
663
|
|
655
|
|
664
|
-
|
|
|
665
|
result.fashTopGoods = {
|
656
|
result.fashTopGoods = {
|
666
|
getLimitedCode: fashTopGoods.getLimitedCode, // 限购码状态
|
657
|
getLimitedCode: fashTopGoods.getLimitedCode, // 限购码状态
|
667
|
hasLimitedCode: fashTopGoods.hasLimitedCode, // 是否已经获取限购码
|
658
|
hasLimitedCode: fashTopGoods.hasLimitedCode, // 是否已经获取限购码
|
|
@@ -702,7 +693,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -702,7 +693,7 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
702
|
} else if (virtualGoods) {
|
693
|
} else if (virtualGoods) {
|
703
|
// 虚拟商品
|
694
|
// 虚拟商品
|
704
|
result.buyNow = true; // 是否立即购买
|
695
|
result.buyNow = true; // 是否立即购买
|
705
|
- result.buyNowBase = helpers.urlFormat('/ticket', {}, 'shopping');
|
696
|
+ result.buyNowBase = helpers.urlFormat('ticket', {}, 'shopping');
|
706
|
result.virtualGoods = virtualGoods;
|
697
|
result.virtualGoods = virtualGoods;
|
707
|
if (result.salePrice) {
|
698
|
if (result.salePrice) {
|
708
|
result.advancePrice = result.salePrice; // 先行价格
|
699
|
result.advancePrice = result.salePrice; // 先行价格
|
|
@@ -723,7 +714,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -723,7 +714,6 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
723
|
result.shareImg = result.img;
|
714
|
result.shareImg = result.img;
|
724
|
result.shareDesc = result.phrase;
|
715
|
result.shareDesc = result.phrase;
|
725
|
|
716
|
|
726
|
-
|
|
|
727
|
// 统计需要的商品信息
|
717
|
// 统计需要的商品信息
|
728
|
let statGoodsInfo = {};
|
718
|
let statGoodsInfo = {};
|
729
|
|
719
|
|
|
@@ -780,15 +770,14 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
|
@@ -780,15 +770,14 @@ const detailDataPkg = (origin, uid, vipLevel) => { |
780
|
/**
|
770
|
/**
|
781
|
* 获取商品的舒适度
|
771
|
* 获取商品的舒适度
|
782
|
*/
|
772
|
*/
|
783
|
-function getProductComfortAsync(productId) {
|
|
|
784
|
- return co(function*() {
|
773
|
+function getProductComfort() {
|
785
|
|
774
|
|
786
|
let result = [];
|
775
|
let result = [];
|
787
|
|
776
|
|
788
|
- let comfort = getMultiDataByResourceName('ItemData::getProductComfort');
|
777
|
+ let comfort = getCacheDataByName('ItemData::getProductComfort');
|
789
|
|
778
|
|
790
|
if (!comfort) {
|
779
|
if (!comfort) {
|
791
|
- comfort = yield favoriteBrandService.getProductComfortAsync(productId);
|
780
|
+ return result;
|
792
|
}
|
781
|
}
|
793
|
|
782
|
|
794
|
if (comfort.data) {
|
783
|
if (comfort.data) {
|
|
@@ -822,13 +811,10 @@ function getProductComfortAsync(productId) { |
|
@@ -822,13 +811,10 @@ function getProductComfortAsync(productId) { |
822
|
}
|
811
|
}
|
823
|
|
812
|
|
824
|
return result;
|
813
|
return result;
|
825
|
- })();
|
|
|
826
|
}
|
814
|
}
|
827
|
|
815
|
|
828
|
|
816
|
|
829
|
-function getDescriptionDataBySizeInfoAsync(sizeInfo) {
|
|
|
830
|
- return co(function *() {
|
|
|
831
|
-
|
817
|
+function getDescriptionDataBySizeInfo(sizeInfo) {
|
832
|
let description = {};
|
818
|
let description = {};
|
833
|
|
819
|
|
834
|
if (sizeInfo.productDescBo.erpProductId) {
|
820
|
if (sizeInfo.productDescBo.erpProductId) {
|
|
@@ -871,11 +857,10 @@ function getDescriptionDataBySizeInfoAsync(sizeInfo) { |
|
@@ -871,11 +857,10 @@ function getDescriptionDataBySizeInfoAsync(sizeInfo) { |
871
|
});
|
857
|
});
|
872
|
}
|
858
|
}
|
873
|
|
859
|
|
874
|
- description.confort = yield getProductComfortAsync(sizeInfo.productBo.id);
|
860
|
+ description.confort = getProductComfort();
|
875
|
}
|
861
|
}
|
876
|
|
862
|
|
877
|
return description;
|
863
|
return description;
|
878
|
- })();
|
|
|
879
|
}
|
864
|
}
|
880
|
|
865
|
|
881
|
/**
|
866
|
/**
|
|
@@ -1012,15 +997,14 @@ function getSizeDataBySizeInfo(sizeInfo) { |
|
@@ -1012,15 +997,14 @@ function getSizeDataBySizeInfo(sizeInfo) { |
1012
|
* 获取商品模特卡
|
997
|
* 获取商品模特卡
|
1013
|
* @param productId
|
998
|
* @param productId
|
1014
|
*/
|
999
|
*/
|
1015
|
-function getProductModelCardAsync(productId) {
|
|
|
1016
|
- return co(function*() {
|
1000
|
+function getProductModelCard() {
|
1017
|
|
1001
|
|
1018
|
let result = [];
|
1002
|
let result = [];
|
1019
|
|
1003
|
|
1020
|
- let data = getMultiDataByResourceName('ItemData::getProductModelCard');
|
1004
|
+ let data = getCacheDataByName('ItemData::getProductModelCard');
|
1021
|
|
1005
|
|
1022
|
if (!data) {
|
1006
|
if (!data) {
|
1023
|
- data = yield productAPI.getProductModelCardAsync(productId);
|
1007
|
+ return result;
|
1024
|
}
|
1008
|
}
|
1025
|
|
1009
|
|
1026
|
if (data.code && data.code === 200) {
|
1010
|
if (data.code && data.code === 200) {
|
|
@@ -1034,7 +1018,6 @@ function getProductModelCardAsync(productId) { |
|
@@ -1034,7 +1018,6 @@ function getProductModelCardAsync(productId) { |
1034
|
}
|
1018
|
}
|
1035
|
|
1019
|
|
1036
|
return result;
|
1020
|
return result;
|
1037
|
- })();
|
|
|
1038
|
}
|
1021
|
}
|
1039
|
|
1022
|
|
1040
|
/**
|
1023
|
/**
|
|
@@ -1155,14 +1138,13 @@ function getDetailDataBySizeInfo(sizeInfo) { |
|
@@ -1155,14 +1138,13 @@ function getDetailDataBySizeInfo(sizeInfo) { |
1155
|
* 获取模特试穿
|
1138
|
* 获取模特试穿
|
1156
|
* @param productSkn
|
1139
|
* @param productSkn
|
1157
|
*/
|
1140
|
*/
|
1158
|
-function getProductModelTryAsync(productSkn) {
|
|
|
1159
|
- return co(function*() {
|
1141
|
+function getProductModelTry() {
|
1160
|
let modelTry = {};
|
1142
|
let modelTry = {};
|
1161
|
|
1143
|
|
1162
|
- let result = getMultiDataByResourceName('ItemData::getProductModelTry');
|
1144
|
+ let result = getCacheDataByName('ItemData::getProductModelTry');
|
1163
|
|
1145
|
|
1164
|
if (!result) {
|
1146
|
if (!result) {
|
1165
|
- result = yield productAPI.getProductModelTryAsync(productSkn);
|
1147
|
+ return modelTry;
|
1166
|
}
|
1148
|
}
|
1167
|
|
1149
|
|
1168
|
if (result.code && result.code === 200 && result.data) {
|
1150
|
if (result.code && result.code === 200 && result.data) {
|
|
@@ -1195,7 +1177,6 @@ function getProductModelTryAsync(productSkn) { |
|
@@ -1195,7 +1177,6 @@ function getProductModelTryAsync(productSkn) { |
1195
|
|
1177
|
|
1196
|
}
|
1178
|
}
|
1197
|
return modelTry;
|
1179
|
return modelTry;
|
1198
|
- })();
|
|
|
1199
|
}
|
1180
|
}
|
1200
|
|
1181
|
|
1201
|
/**
|
1182
|
/**
|
|
@@ -1270,35 +1251,34 @@ function getSizeAttrByMaxSortId(maxSortId, sizeList) { |
|
@@ -1270,35 +1251,34 @@ function getSizeAttrByMaxSortId(maxSortId, sizeList) { |
1270
|
* @param int $maxSortId
|
1251
|
* @param int $maxSortId
|
1271
|
* @return array
|
1252
|
* @return array
|
1272
|
*/
|
1253
|
*/
|
1273
|
-const getSizeInfoAsync = (productSkn, maxSortId)=> {
|
|
|
1274
|
- return co(function*() {
|
1254
|
+const getSizeInfo = (productSkn, maxSortId)=> {
|
1275
|
|
1255
|
|
1276
|
let result = {};
|
1256
|
let result = {};
|
1277
|
|
1257
|
|
1278
|
if (productSkn) {
|
1258
|
if (productSkn) {
|
1279
|
// 并发资源中是否存在数据
|
1259
|
// 并发资源中是否存在数据
|
1280
|
- let sizeInfo = getMultiDataByResourceName('ItemData::sizeInfo');
|
|
|
1281
|
-
|
|
|
1282
|
- if (!sizeInfo) {
|
|
|
1283
|
- // 获取尺码
|
|
|
1284
|
- sizeInfo = yield productAPI.sizeInfoAsync(productSkn);
|
|
|
1285
|
- }
|
1260
|
+ let sizeInfo = getCacheDataByName('ItemData::sizeInfo');
|
1286
|
|
1261
|
|
1287
|
if (!sizeInfo) {
|
1262
|
if (!sizeInfo) {
|
1288
|
return result;
|
1263
|
return result;
|
1289
|
}
|
1264
|
}
|
1290
|
|
1265
|
|
1291
|
- let productId = sizeInfo.productBo.id;
|
|
|
1292
|
-
|
|
|
1293
|
// 描述数据
|
1266
|
// 描述数据
|
1294
|
- result.description = yield getDescriptionDataBySizeInfoAsync(sizeInfo);
|
1267
|
+ result.description = getDescriptionDataBySizeInfo(sizeInfo);
|
|
|
1268
|
+
|
|
|
1269
|
+ // 模特卡
|
|
|
1270
|
+ result.modelCards = getProductModelCard();
|
|
|
1271
|
+
|
|
|
1272
|
+ // 试穿模特
|
|
|
1273
|
+ let fittingReport = getProductModelTry();
|
|
|
1274
|
+
|
|
|
1275
|
+ if (!_.isEmpty(fittingReport)) {
|
|
|
1276
|
+ result.fittingReport = fittingReport;
|
|
|
1277
|
+ }
|
1295
|
|
1278
|
|
1296
|
// 尺寸数据
|
1279
|
// 尺寸数据
|
1297
|
result.size = getSizeDataBySizeInfo(sizeInfo);
|
1280
|
result.size = getSizeDataBySizeInfo(sizeInfo);
|
1298
|
|
1281
|
|
1299
|
- // 模特卡
|
|
|
1300
|
- result.modelCards = yield getProductModelCardAsync(productId);
|
|
|
1301
|
-
|
|
|
1302
|
// 模特数据
|
1282
|
// 模特数据
|
1303
|
result.reference = getReferenceDataBySizeInfo(sizeInfo);
|
1283
|
result.reference = getReferenceDataBySizeInfo(sizeInfo);
|
1304
|
|
1284
|
|
|
@@ -1308,20 +1288,12 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> { |
|
@@ -1308,20 +1288,12 @@ const getSizeInfoAsync = (productSkn, maxSortId)=> { |
1308
|
// 商品详情页介绍
|
1288
|
// 商品详情页介绍
|
1309
|
result.details = getDetailDataBySizeInfo(sizeInfo);
|
1289
|
result.details = getDetailDataBySizeInfo(sizeInfo);
|
1310
|
|
1290
|
|
1311
|
- // 试穿模特
|
|
|
1312
|
- let fittingReport = yield getProductModelTryAsync(productSkn);
|
|
|
1313
|
-
|
|
|
1314
|
- if (!_.isEmpty(fittingReport)) {
|
|
|
1315
|
- result.fittingReport = fittingReport;
|
|
|
1316
|
- }
|
|
|
1317
|
-
|
|
|
1318
|
// 获取尺寸说明
|
1291
|
// 获取尺寸说明
|
1319
|
result.sizeTitleJson =
|
1292
|
result.sizeTitleJson =
|
1320
|
sizeInfo.sizeInfoBo ? JSON.stringify(getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';
|
1293
|
sizeInfo.sizeInfoBo ? JSON.stringify(getSizeAttrByMaxSortId(maxSortId, sizeInfo.sizeInfoBo)) : '';
|
1321
|
}
|
1294
|
}
|
1322
|
|
1295
|
|
1323
|
return result;
|
1296
|
return result;
|
1324
|
- })();
|
|
|
1325
|
};
|
1297
|
};
|
1326
|
|
1298
|
|
1327
|
/**
|
1299
|
/**
|
|
@@ -1346,21 +1318,32 @@ module.exports.showMainAsync = (data) => { |
|
@@ -1346,21 +1318,32 @@ module.exports.showMainAsync = (data) => { |
1346
|
|
1318
|
|
1347
|
return co(function * () {
|
1319
|
return co(function * () {
|
1348
|
|
1320
|
|
1349
|
- // 获取商品信息
|
|
|
1350
|
- let productInfo = yield productAPI.getProductInfo(data.id);
|
1321
|
+ let result = {};
|
1351
|
|
1322
|
|
1352
|
- productInfo = yield detailDataPkg(productInfo, data.uid, data.vipLevel);
|
1323
|
+ let currentUserProductInfo = _.curry(detailDataPkg)(_, data.uid, data.vipLevel);
|
|
|
1324
|
+
|
|
|
1325
|
+ // 获取商品信息
|
|
|
1326
|
+ let productInfo = yield productAPI.getProductInfo(data.id).then(currentUserProductInfo);
|
1353
|
|
1327
|
|
1354
|
// 获取商品尺寸相关
|
1328
|
// 获取商品尺寸相关
|
1355
|
- let sizeInfo = yield getSizeInfoAsync(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
1329
|
+ let requestData = yield Promise.all([
|
|
|
1330
|
+ getSortNavAsync(productInfo.goodsInfo.smallSortId, data.gender),
|
|
|
1331
|
+ HeaderModel.requestHeaderData()
|
|
|
1332
|
+ ]);
|
1356
|
|
1333
|
|
1357
|
- let navs = yield getSortNavAsync(productInfo.goodsInfo.smallSortId, data.gender);
|
1334
|
+ let sizeInfo = getSizeInfo(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
|
1358
|
|
1335
|
|
1359
|
- let result = {
|
|
|
1360
|
- productDetailPage: true,
|
|
|
1361
|
- detail: Object.assign(productInfo, sizeInfo),
|
|
|
1362
|
- statGoodsInfo: Object.assign({fullSortName: navs.map(x => x.name).join('-')}, productInfo.statGoodsInfo)
|
|
|
1363
|
- };
|
1336
|
+ let navs = requestData[0];
|
|
|
1337
|
+
|
|
|
1338
|
+ result.headerData = requestData[1];
|
|
|
1339
|
+
|
|
|
1340
|
+ result.productDetailPage = true;
|
|
|
1341
|
+ result.detail = Object.assign(productInfo, sizeInfo);
|
|
|
1342
|
+ result.statGoodsInfo = Object.assign({
|
|
|
1343
|
+ fullSortName: navs.map(x => x.name).join('-')
|
|
|
1344
|
+ },
|
|
|
1345
|
+ productInfo.statGoodsInfo
|
|
|
1346
|
+ );
|
1364
|
|
1347
|
|
1365
|
// 导航
|
1348
|
// 导航
|
1366
|
result.detail.pathNav = _.concat(
|
1349
|
result.detail.pathNav = _.concat(
|
|
@@ -1370,8 +1353,6 @@ module.exports.showMainAsync = (data) => { |
|
@@ -1370,8 +1353,6 @@ module.exports.showMainAsync = (data) => { |
1370
|
);
|
1353
|
);
|
1371
|
|
1354
|
|
1372
|
result.detail.lastWalk = 5;
|
1355
|
result.detail.lastWalk = 5;
|
1373
|
- result.headerData = yield HeaderModel.requestHeaderData();
|
|
|
1374
|
-
|
|
|
1375
|
return result;
|
1356
|
return result;
|
1376
|
})();
|
1357
|
})();
|
1377
|
};
|
1358
|
};
|