Showing
1 changed file
with
420 additions
and
0 deletions
@@ -138,6 +138,426 @@ const _getLimitCodeUrl = (productCode, skn, ua) => { | @@ -138,6 +138,426 @@ const _getLimitCodeUrl = (productCode, skn, ua) => { | ||
138 | * @param origin Object 原始数据 | 138 | * @param origin Object 原始数据 |
139 | * @return dest Object 格式化数据 | 139 | * @return dest Object 格式化数据 |
140 | */ | 140 | */ |
141 | +//老接口h5的代码 | ||
142 | +// const _detailDataPkg = (origin, uid, vipLevel, ua) => { | ||
143 | +// let dest = {}, // 结果输出 | ||
144 | +// thumbImageList = [], | ||
145 | +// colorGroup = {}, | ||
146 | +// sizeGroup = [], | ||
147 | +// totalStorageNum = 0; | ||
148 | + | ||
149 | +// // 商品名称 | ||
150 | +// if (origin.productName === null || typeof origin.productName === 'undefined') { | ||
151 | +// return dest; | ||
152 | +// } | ||
153 | + | ||
154 | +// dest.goodsName = origin.productName; | ||
155 | + | ||
156 | +// // 是否是虚拟商品 | ||
157 | +// dest.virtualGoods = origin.attribute * 1 === 3 ? true : false; | ||
158 | + | ||
159 | +// // 用户未登录时 | ||
160 | +// if (!uid) { | ||
161 | +// let params = {}; | ||
162 | + | ||
163 | +// params.refer = helpers.urlFormat('/product/show_' + origin.erpProductId + '.html'); | ||
164 | +// dest.loginUrl = helpers.urlFormat('/signin.html', params); | ||
165 | +// } | ||
166 | + | ||
167 | +// // 商品促销短语 | ||
168 | +// if (origin.salesPhrase) { | ||
169 | +// dest.goodsSubtitle = origin.salesPhrase; | ||
170 | +// } | ||
171 | + | ||
172 | +// // 促销信息 TODO: 换新接口 | ||
173 | +// if (origin.promotionBoList) { | ||
174 | +// let discountList = []; | ||
175 | + | ||
176 | +// _.forEach(origin.promotionBoList, function(value) { | ||
177 | +// discountList.push({ | ||
178 | +// text: `【${value.promotionType}】${value.promotionTitle}` | ||
179 | +// }); | ||
180 | +// }); | ||
181 | + | ||
182 | +// if (discountList.length) { | ||
183 | +// dest.goodsDiscount = { | ||
184 | +// list: discountList | ||
185 | +// }; | ||
186 | +// } | ||
187 | +// } | ||
188 | + | ||
189 | +// // 商品标签 | ||
190 | +// if (origin.productTagBoList) { | ||
191 | +// let productTags = {}; | ||
192 | + | ||
193 | +// _.forEach(origin.productTagBoList, function(value) { | ||
194 | +// switch (value.tagLabel) { | ||
195 | +// case 'is_soon_sold_out': | ||
196 | +// productTags.is_soon_sold_out = true; | ||
197 | +// break; | ||
198 | +// case 'is_new': | ||
199 | +// productTags.is_new = true; | ||
200 | +// break; | ||
201 | +// case 'is_discount': | ||
202 | +// productTags.is_discount = true; | ||
203 | +// break; | ||
204 | +// case 'is_limited': | ||
205 | +// productTags.is_limited = true; | ||
206 | +// break; | ||
207 | +// case 'is_yohood': | ||
208 | +// productTags.is_yohood = true; | ||
209 | +// break; | ||
210 | +// case 'is_advance': | ||
211 | +// productTags.is_advance = true; | ||
212 | +// break; | ||
213 | +// default: | ||
214 | +// break; | ||
215 | +// } | ||
216 | +// }); | ||
217 | + | ||
218 | +// dest.tags = productTags; | ||
219 | +// } | ||
220 | + | ||
221 | +// // 商品价格 | ||
222 | +// if (origin.productPriceBo) { | ||
223 | +// let originPrice = origin.productPriceBo; | ||
224 | +// let goodsPrice = { | ||
225 | +// currentPrice: originPrice.formatSalesPrice | ||
226 | +// }; | ||
227 | + | ||
228 | +// if (originPrice.formatMarketPrice !== originPrice.formatSalesPrice) { | ||
229 | +// goodsPrice.previousPrice = originPrice.formatMarketPrice; | ||
230 | +// } | ||
231 | + | ||
232 | +// dest.goodsPrice = goodsPrice; | ||
233 | + | ||
234 | +// // 商品返回 有货币 | ||
235 | +// if (originPrice.yohoCoinNum) { | ||
236 | +// dest.commodityReturn = originPrice.yohoCoinNum; | ||
237 | +// } | ||
238 | +// } | ||
239 | + | ||
240 | +// // VIP 商品价格 | ||
241 | +// if (origin.productPriceBo.vipPrices) { | ||
242 | +// let vipList = []; | ||
243 | + | ||
244 | +// _.forEach(origin.productPriceBo.vipPrices, function(value) { | ||
245 | +// vipList.push({ | ||
246 | +// level: value.vipLevel, | ||
247 | +// text: value.vipPrice, | ||
248 | +// currentLevel: (value.vipLevel === vipLevel) | ||
249 | +// }); | ||
250 | +// }); | ||
251 | + | ||
252 | +// if (vipList.length) { | ||
253 | +// dest.vipLevel = { | ||
254 | +// list: vipList | ||
255 | +// }; | ||
256 | +// } | ||
257 | + | ||
258 | +// } | ||
259 | + | ||
260 | +// // 上市期 | ||
261 | +// if (origin.expectArrivalTime) { | ||
262 | +// dest.periodOfMarket = `${origin.expectArrivalTime}月`; | ||
263 | +// } | ||
264 | + | ||
265 | +// // 商品咨询 | ||
266 | +// dest.feedbacks = { | ||
267 | +// consults: [], | ||
268 | +// consultsNum: 0 | ||
269 | +// }; | ||
270 | + | ||
271 | +// let consultParams = { | ||
272 | +// product_id: origin.id | ||
273 | +// }; | ||
274 | + | ||
275 | +// if (_.has(dest, 'feedbacks.consultsNum')) { | ||
276 | +// consultParams.total = dest.feedbacks.consultsNum; | ||
277 | +// dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consults', consultParams); | ||
278 | +// } else { | ||
279 | +// dest.feedbacks.consultsUrl = helpers.urlFormat('/product/detail/consultform', consultParams); | ||
280 | +// } | ||
281 | + | ||
282 | + | ||
283 | +// // 商品评价 | ||
284 | +// dest.feedbacks.commentsNum = 0; | ||
285 | +// if (origin.commentBoWrapper) { | ||
286 | +// dest.feedbacks.commentsNum = origin.commentBoWrapper.commentTotal; | ||
287 | + | ||
288 | +// let commentList = []; | ||
289 | + | ||
290 | +// _.forEach(origin.commentBoWrapper.commentBoList, function(value) { | ||
291 | +// commentList.push({ | ||
292 | +// userName: value.nickName, | ||
293 | +// desc: `${value.colorName}/${value.sizeName}`, | ||
294 | +// content: value.content ? value.content : '', | ||
295 | +// time: value.createTime | ||
296 | +// }); | ||
297 | +// }); | ||
298 | + | ||
299 | +// dest.feedbacks.comments = commentList; | ||
300 | + | ||
301 | +// dest.feedbacks.commentsUrl = helpers.urlFormat('/product/detail/comments', { | ||
302 | +// product_id: origin.id, | ||
303 | +// total: dest.feedbacks.commentsNum | ||
304 | +// }); | ||
305 | +// } | ||
306 | + | ||
307 | +// // 品牌信息 | ||
308 | +// if (origin.brand) { | ||
309 | +// let extra = `?productSkn=${origin.erpProductId}&brandId=${origin.brand.id}`; | ||
310 | + | ||
311 | +// dest.preferenceUrl = `/product/detail/preference${extra}`; | ||
312 | +// } | ||
313 | + | ||
314 | +// dest.productSkn = origin.erpProductId; | ||
315 | + | ||
316 | +// // 商品信息 | ||
317 | +// if (origin.goodsList) { | ||
318 | +// let goodsGroup = [], | ||
319 | +// sizeName = '', | ||
320 | +// colorList = [], | ||
321 | +// sizeList = {}, | ||
322 | +// allSizeList = {}, | ||
323 | +// colorStorageGroup = {}, | ||
324 | +// colorStorageNum = 0; | ||
325 | + | ||
326 | +// _.forEach(origin.goodsList, function(value) { | ||
327 | +// if (value.status === 0) { | ||
328 | +// return; | ||
329 | +// } | ||
330 | + | ||
331 | +// colorStorageNum = 0; | ||
332 | + | ||
333 | +// // 商品分组 | ||
334 | +// if (value.goodsImagesList) { | ||
335 | +// _.forEach(value.goodsImagesList, function(good) { | ||
336 | +// goodsGroup.push({ | ||
337 | +// goodsId: good.goodsId, | ||
338 | +// img: good.imageUrl | ||
339 | +// }); | ||
340 | +// }); | ||
341 | +// } | ||
342 | + | ||
343 | +// // 商品的尺码列表 | ||
344 | +// colorStorageGroup[value.productSkc] = {}; | ||
345 | +// if (value.goodsSizeBoList) { | ||
346 | +// sizeList[value.productSkc] = []; | ||
347 | +// _.forEach(value.goodsSizeBoList, function(size) { | ||
348 | +// sizeList[value.productSkc].push({ | ||
349 | +// id: size.id, | ||
350 | +// skuId: size.goodsSizeSkuId, | ||
351 | +// goodsId: size.goodsId, | ||
352 | +// colorId: size.colorId, | ||
353 | +// name: size.sizeName, | ||
354 | +// sizeNum: size.goodsSizeStorageNum | ||
355 | +// }); | ||
356 | + | ||
357 | +// sizeName = size.sizeName; | ||
358 | + | ||
359 | +// // 所有尺码列表,赋值用于前端展示默认尺码的时候 | ||
360 | +// // 判断出没有库存则显示灰色 | ||
361 | +// let build = { | ||
362 | +// id: size.id, | ||
363 | +// storage: size.goodsSizeStorageNum | ||
364 | +// }; | ||
365 | + | ||
366 | +// allSizeList[sizeName] = (allSizeList[sizeName] === null || | ||
367 | +// typeof allSizeList[sizeName] === 'undefined') ? build : | ||
368 | +// allSizeList[sizeName]; | ||
369 | + | ||
370 | +// colorStorageNum += parseInt(size.goodsSizeStorageNum, 10); | ||
371 | +// colorStorageGroup[value.productSkc][sizeName] = parseInt(size.goodsSizeStorageNum, 10); | ||
372 | +// }); | ||
373 | + | ||
374 | +// // 颜色分组 | ||
375 | +// colorList.push({ | ||
376 | +// id: value.colorId, | ||
377 | +// skcId: value.productSkc, | ||
378 | +// name: value.colorName, | ||
379 | +// goodsName: value.goodsName, | ||
380 | +// colorNum: colorStorageNum | ||
381 | +// }); | ||
382 | +// } | ||
383 | + | ||
384 | +// // 缩略图 | ||
385 | +// thumbImageList.push({ | ||
386 | +// img: value.colorImage | ||
387 | +// }); | ||
388 | + | ||
389 | +// // 商品库存总数 | ||
390 | +// totalStorageNum += _.toNumber(colorStorageNum); | ||
391 | +// }); | ||
392 | + | ||
393 | +// // 遍历所有尺码,构建颜色显示数据 | ||
394 | +// let i = 1; | ||
395 | + | ||
396 | +// sizeGroup[0] = { | ||
397 | +// size: [] | ||
398 | +// }; | ||
399 | + | ||
400 | +// _.forEach(allSizeList, (value, key) => { | ||
401 | + | ||
402 | +// // 默认尺码 | ||
403 | +// sizeGroup[0].size.push({ | ||
404 | +// name: key, | ||
405 | +// sizeNum: _.toNumber(value.storage) > 0 ? true : false, | ||
406 | +// id: value.id | ||
407 | +// }); | ||
408 | + | ||
409 | +// colorGroup[i] = { | ||
410 | +// color: [] | ||
411 | +// }; | ||
412 | + | ||
413 | +// // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | ||
414 | +// _.forEach(colorList, (colorArr) => { | ||
415 | +// let tempColorArr = _.cloneDeep(colorArr); | ||
416 | + | ||
417 | +// if (colorStorageGroup[tempColorArr.skcId] && | ||
418 | +// colorStorageGroup[tempColorArr.skcId][key]) { | ||
419 | +// tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key]; | ||
420 | +// } else { | ||
421 | +// tempColorArr.colorNum = 0; | ||
422 | +// } | ||
423 | +// colorGroup[i].color.push(Object.assign({}, tempColorArr)); | ||
424 | +// }); | ||
425 | +// colorGroup[i].id = value.id; | ||
426 | + | ||
427 | +// ++i; | ||
428 | +// }); | ||
429 | + | ||
430 | +// colorGroup[0] = { | ||
431 | +// color: [] | ||
432 | +// }; | ||
433 | + | ||
434 | +// // 遍历所有颜色, 构建尺码显示数据 | ||
435 | +// i = 1; | ||
436 | +// _.forEach(colorList, function(value) { | ||
437 | +// // 各个尺码的颜色, 每行显示一个颜色的对应尺码 | ||
438 | +// sizeGroup[i] = { | ||
439 | +// size: sizeList[value.skcId], | ||
440 | +// colorId: value.skcId | ||
441 | +// }; | ||
442 | + | ||
443 | +// // 默认颜色 | ||
444 | +// colorGroup[0].color.push(value); | ||
445 | +// ++i; | ||
446 | +// }); | ||
447 | + | ||
448 | + | ||
449 | +// // 商品图:多个 | ||
450 | +// if (goodsGroup.length > 1) { | ||
451 | +// let bannerList = []; | ||
452 | + | ||
453 | +// _.forEach(goodsGroup, function(value) { | ||
454 | +// bannerList.push({ | ||
455 | +// img: value.img | ||
456 | +// }); | ||
457 | +// }); | ||
458 | + | ||
459 | +// dest.bannerTop = { | ||
460 | +// list: bannerList | ||
461 | +// }; | ||
462 | +// } else if (goodsGroup[0] !== null && typeof goodsGroup[0] !== 'undefined') { | ||
463 | +// dest.bannerTop = { | ||
464 | +// img: goodsGroup[0].img | ||
465 | +// }; | ||
466 | +// } | ||
467 | +// } | ||
468 | + | ||
469 | +// // 悬浮的购物车信息 | ||
470 | +// dest.cartInfo = { | ||
471 | +// cartUrl: helpers.urlFormat('/cart/index/index'), | ||
472 | +// numInCart: 0, | ||
473 | +// goodsInstore: origin.storage | ||
474 | +// }; | ||
475 | + | ||
476 | +// let soldOut = (origin.storage === 0) || (origin.status === 0 || totalStorageNum === 0); | ||
477 | +// let notForSale = origin.attribute === 2; | ||
478 | + | ||
479 | +// // 显示加入购物车链接 | ||
480 | +// if (!soldOut && !notForSale) { | ||
481 | +// _.orderBy(colorGroup); | ||
482 | + | ||
483 | +// Object.assign(dest.cartInfo, { | ||
484 | +// productId: origin.id, | ||
485 | +// thumbs: thumbImageList, | ||
486 | +// name: dest.goodsName ? dest.goodsName : '', | ||
487 | +// price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '', | ||
488 | +// salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '', | ||
489 | +// totalNum: totalStorageNum, | ||
490 | +// colors: _.toArray(colorGroup), | ||
491 | +// sizes: sizeGroup | ||
492 | +// }); | ||
493 | + | ||
494 | +// // 限购商品 | ||
495 | +// if (origin.isLimitBuy === 'Y') { | ||
496 | +// // 是否开售 | ||
497 | +// let isBeginSale = (origin.saleStatus !== null && typeof origin.saleStatus !== 'undefined' && | ||
498 | +// origin.saleStatus === 1); | ||
499 | + | ||
500 | +// // 限购商品有关的展示状态 | ||
501 | +// let showStatus = 1; | ||
502 | + | ||
503 | +// if (origin.showStatus !== null && typeof origin.showStatus !== 'undefined') { | ||
504 | +// showStatus = parseInt(origin.showStatus, 10); | ||
505 | +// } | ||
506 | + | ||
507 | +// // 处理限购商品有关的按钮状态 | ||
508 | +// dest = _procShowStatus(dest, showStatus, isBeginSale); | ||
509 | + | ||
510 | +// dest.cartInfo.limitProductCode = origin.limitProductCode; | ||
511 | +// dest.cartInfo.limitCodeUrl = _getLimitCodeUrl(origin.limitProductCode, origin.erpProductId, ua); | ||
512 | +// dest.cartInfo.limitProductPay = helpers.urlFormat('/cart/index/orderEnsure'); | ||
513 | +// } else { | ||
514 | +// dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.id + '_' + | ||
515 | +// origin.goodsList.id + '.html'); | ||
516 | +// } | ||
517 | +// } else if (notForSale) { | ||
518 | +// dest.cartInfo.notForSale = true; | ||
519 | +// } else if (soldOut) { | ||
520 | +// dest.cartInfo.soldOut = true; | ||
521 | +// } | ||
522 | + | ||
523 | +// // 是否收藏 | ||
524 | +// dest.isCollect = false; | ||
525 | +// if (origin.isCollect !== null && typeof origin.isCollect !== 'undefined' && origin.isCollect === 'Y') { | ||
526 | +// dest.isCollect = true; | ||
527 | +// dest.cartInfo.isCollect = true; | ||
528 | +// } | ||
529 | + | ||
530 | +// // 底部简介URL链接 | ||
531 | +// dest.introUrl = '/product/detail/intro/' + origin.erpProductId; | ||
532 | +// dest.id = origin.id; | ||
533 | + | ||
534 | +// // 虚拟商品(门票) | ||
535 | +// if (origin.attribute * 1 === 3) { | ||
536 | +// dest.tickets = true; | ||
537 | +// dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm'); | ||
538 | + | ||
539 | +// // 展览票 | ||
540 | +// if (origin.erpProductId * 1 === SINGLE_TICKETS_SKN) { | ||
541 | +// dest.single = true; | ||
542 | +// } else { | ||
543 | +// // 套票 | ||
544 | +// dest.package = true; | ||
545 | +// } | ||
546 | + | ||
547 | +// // 购票限制 | ||
548 | +// dest.cartInfo.limit = 4; | ||
549 | + | ||
550 | +// // 清空活动 | ||
551 | +// dest.goodsDiscount = []; | ||
552 | + | ||
553 | +// // 来自登录页,自动弹出选择框 | ||
554 | +// // if (isset($_GET['product_type']) && $_GET['product_type'] == 'ticket') { | ||
555 | +// // $result['showPannel'] = true; | ||
556 | +// // } | ||
557 | +// } | ||
558 | + | ||
559 | +// return dest; | ||
560 | +// }; | ||
141 | const _detailDataPkg = (origin, uid, vipLevel, ua) => { | 561 | const _detailDataPkg = (origin, uid, vipLevel, ua) => { |
142 | let dest = {}, // 结果输出 | 562 | let dest = {}, // 结果输出 |
143 | thumbImageList = [], | 563 | thumbImageList = [], |
-
Please register or login to post a comment