Authored by 郭成尧

商品尺码信息分离

@@ -488,256 +488,15 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => { @@ -488,256 +488,15 @@ const detailDataPkg = (origin, uid, vipLevel, ua) => {
488 dest.isCollect = true; 488 dest.isCollect = true;
489 } 489 }
490 490
491 - // 底部简介的URL链接  
492 - dest.introUrl = helpers.url('/product/intro_' + origin.erpProductId + '/' + origin.cnAlphabet + '.html', null, ''); 491 + // 底部简介的URL链接 待处理
  492 + // dest.introUrl = helpers.url('/product/intro_' + origin.erpProductId +
  493 + // '/' + origin.cnAlphabet + '.html', null, '');
  494 + dest.introUrl = 'http://localhost:6001/product/intro/51257148';
493 dest.id = origin.id; 495 dest.id = origin.id;
494 496
495 return dest; 497 return dest;
496 }; 498 };
497 499
498 -/**  
499 - * 商品尺码信息处理  
500 - * @param {[type]} productSkn [description]  
501 - * @param {[type]} uid [description]  
502 - * @param {[type]} udid [description]  
503 - * @return {[type]} [description]  
504 - */  
505 -const getSizeInfo = (sizeInfo) => {  
506 - var dest = {},  
507 - temp = {};  
508 -  
509 - dest.goodsDescription = {};  
510 -  
511 - if (_.isEmpty(sizeInfo.productDescBo.erpProductId)) {  
512 - let sex = '通用';  
513 -  
514 - switch (sizeInfo.productDescBo.gender) {  
515 - case 1:  
516 - sex = '男款';  
517 - break;  
518 - case 2:  
519 - sex = '女款';  
520 - break;  
521 - default:  
522 - break;  
523 - }  
524 -  
525 - dest.goodsDescription.title = '商品信息';  
526 - dest.goodsDescription.enTitle = 'DESCRIPTION';  
527 - dest.goodsDescription.detail = {};  
528 - dest.goodsDescription.detail.list = {};  
529 - dest.goodsDescription.detail.list[0].param =  
530 - '编号:' + sizeInfo.productDescBo.erpProductId;  
531 - dest.goodsDescription.detail.list[1].param =  
532 - '颜色:' + sizeInfo.productDescBo.colorName;  
533 - dest.goodsDescription.detail.list[2].param =  
534 - '性别:' + sex;  
535 - }  
536 -  
537 - if (_.isEmpty(sizeInfo.productDescBo.standardBos)) {  
538 - _.forEach(sizeInfo.productDescBo.standardBos, function(value) {  
539 - dest.goodsDescription.detail.list[3].param = value.standardName + ':' +  
540 - value.standardVal;  
541 - });  
542 - }  
543 -  
544 - if (_.isEmpty(sizeInfo.phrase)) {  
545 - dest.goodsDescription.desc = sizeInfo.phrase;  
546 - }  
547 -  
548 - // 尺码信息  
549 - if (!_.isEmpty(sizeInfo.sizeInfoBo)) {  
550 - dest.sizeInfo = {};  
551 - dest.sizeInfo.title = '尺码信息';  
552 - dest.sizeInfo.enTitle = 'SIZE INFO';  
553 - dest.sizeInfo.detail = [];  
554 - dest.sizeInfo.detail.list = [];  
555 -  
556 - // 参考尺码  
557 - let boyReference = !_.isEmpty(sizeInfo.productExtra.boyReference);  
558 - let girlReference = !_.isEmpty(sizeInfo.productExtra.girlReference);  
559 - let gender = !_.isEmpty(sizeInfo.productDescBo.gender) ? sizeInfo.productDescBo.gender : 3;  
560 - let referenceName = '参考尺码';  
561 -  
562 - if ((gender === 1 && boyReference) || (gender === 2 && girlReference)) {  
563 - referenceName = '参考尺码';  
564 - } else if (gender === 3 && boyReference) {  
565 - referenceName = '参考尺码(男)';  
566 - } else if (gender === 3 && girlReference) {  
567 - referenceName = '参考尺码(女)';  
568 - }  
569 -  
570 - let referenceList = {};  
571 -  
572 - // 判断是否显示参考尺码  
573 - let showReference = (boyReference &&  
574 - !_.isEmpty(sizeInfo.sizeInfoBo.sizeBoList[0].boyReferSize)) || (girlReference &&  
575 - !_.isEmpty(sizeInfo.sizeInfoBo.sizeBoList[0].girlReferSize));  
576 -  
577 - if (showReference) {  
578 - referenceList[0] = {};  
579 - referenceList[0].param = referenceName;  
580 - }  
581 -  
582 - if (!_.isEmpty(sizeInfo.sizeInfoBo.sizeAttributeBos)) {  
583 - let sizeNameList = {};  
584 -  
585 - sizeNameList[0] = {};  
586 - sizeNameList[0].param = '吊牌尺码';  
587 -  
588 - let sizeBoGroup = {};  
589 -  
590 - _.forEach(sizeInfo.sizeInfoBo.sizeAttributeBos, function(attr) {  
591 - sizeBoGroup[attr.id[0]] = {};  
592 - sizeBoGroup[attr.id[0]].param = _.isEmpty(attr.attributeName) ?  
593 - ' ' : attr.attributeName;  
594 - });  
595 -  
596 -  
597 - _.forEach(sizeInfo.sizeInfoBo.sizeBoList, function(value) {  
598 - // let item = {};  
599 -  
600 - sizeNameList[0] = {};  
601 - sizeNameList[0].param = value.sizeName;  
602 -  
603 - if (boyReference && (gender === 1 || gender === 3)) {  
604 - temp = {};  
605 - temp.param = _.isEmpty(value.boyReferSize.referenceName) ?  
606 - ' ' : value.boyReferSize.referenceName;  
607 - sizeNameList.push(temp);  
608 - } else if (girlReference && (gender === 2 || gender === 3)) {  
609 - temp = {};  
610 - temp.param = _.isEmpty(value.girlReferSize.referenceName) ?  
611 - ' ' : value.girlReferSize.referenceName;  
612 - sizeNameList.push(temp);  
613 - } else {  
614 - showReference = false;  
615 - }  
616 -  
617 - _.forEach(value.sortAttributes, function(attr) {  
618 - temp = {};  
619 - temp.param = _.isEmpty(attr.sizeValue) ? ' ' : attr.sizeValue;  
620 - sizeBoGroup[attr.id] = [];  
621 - sizeBoGroup[attr.id].push(temp);  
622 - });  
623 - });  
624 -  
625 - // 根据模板页面的显示,按表格一列一列来显示  
626 - dest.sizeInfo.detail.list[0] = [];  
627 - dest.sizeInfo.detail.list[0].params = sizeNameList;  
628 - if (showReference) {  
629 - dest.sizeInfo.detail.list[1].params = referenceList;  
630 - }  
631 - _.forEach(sizeBoGroup, function(value) {  
632 - temp = {};  
633 - temp.params = value;  
634 - dest.sizeInfo.detail.list.push(temp);  
635 - });  
636 - } else {  
637 - temp = {};  
638 - temp[0].param = '';  
639 - dest.sizeInfo.detail.list[0].params.push(temp);  
640 - }  
641 - }  
642 -  
643 - // 测量方式  
644 - if (!_.isEmpty(sizeInfo.sizeImage)) {  
645 - dest.measurementMethod = {};  
646 -  
647 - dest.measurementMethod.title = '测量方式';  
648 - dest.measurementMethod.enTitle = 'MEASUREMENT METHOD';  
649 - dest.measurementMethod.img = sizeInfo.sizeImage;  
650 - }  
651 -  
652 - // 模特试穿, 竖着输出排列显示  
653 - if (!_.isEmpty(sizeInfo.modelBos)) {  
654 - dest.reference = {};  
655 - dest.reference.title = '模特试穿';  
656 - dest.reference.enTitle = 'REFERENCE';  
657 - dest.reference.detail = {};  
658 - dest.reference.detail.list = {};  
659 -  
660 - // 控制是否显示备注  
661 - // let showRemark = false;  
662 - let remarkList = {};  
663 -  
664 - remarkList[0] = {};  
665 - remarkList[0].param = '备注';  
666 -  
667 - for (let i = 0; i < 7; i++) {  
668 - dest.reference.detail.list[i] = {};  
669 - dest.reference.detail.list[i].params = {};  
670 - dest.reference.detail.list[0].params[0] = {};  
671 - }  
672 - dest.reference.detail.list[0].params[0].param = '';  
673 - dest.reference.detail.list[1].params[0].param = '模特';  
674 - dest.reference.detail.list[2].params[0].param = '身高';  
675 - dest.reference.detail.list[3].params[0].param = '体重';  
676 - dest.reference.detail.list[4].params[0].param = '三围';  
677 - dest.reference.detail.list[5].params[0].param = '吊牌尺码';  
678 - dest.reference.detail.list[6].params[0].param = '试穿描述';  
679 -  
680 - // _.forEach(sizeInfo.modelBos, function(value) {  
681 - // // 待处理  
682 - // });  
683 -  
684 - // 显示模特备注  
685 - // if (showRemark) {  
686 -  
687 - // }  
688 -  
689 - }  
690 -  
691 - // 商品材质  
692 - if (!_.isEmpty(sizeInfo.productMaterialList)) {  
693 - dest.materials = {};  
694 - dest.materials.title = '商品材质';  
695 - dest.materials.enTitle = 'MATERIALS';  
696 - dest.materials.list = [];  
697 -  
698 - _.forEach(sizeInfo.productMaterialList, function(value) {  
699 - temp = {};  
700 - temp.img = value.imageUrl;  
701 - temp.desc = value.remark;  
702 - dest.materials.list.push();  
703 - });  
704 - }  
705 -  
706 - // 洗涤提示  
707 - if (!_.isEmpty(sizeInfo.washTipsBoList)) {  
708 - dest.washTips = {};  
709 - dest.washTips.list = [];  
710 - _.forEach(sizeInfo.washTipsBoList, function(value) {  
711 - dest.washTips.list.push(value);  
712 - });  
713 - }  
714 -  
715 - // 详情配图  
716 -  
717 - if (!_.isEmpty(sizeInfo.productIntroBo.productIntro)) {  
718 - let productIntro = '';  
719 -  
720 - if (!_.isEmpty(sizeInfo.productDescBo.phrase)) {  
721 - productIntro = productIntro + sizeInfo.productDescBo.phrase +  
722 - '<br />';  
723 - }  
724 - productIntro = productIntro + sizeInfo.productIntroBo.productIntro;  
725 - if (!_.isEmpty(productIntro) && productIntro !== '') {  
726 - dest.productDetail = {};  
727 - dest.productDetail.title = '商品详情';  
728 - dest.productDetail.enTitle = 'DETAILS';  
729 -  
730 - // 待开发  
731 - }  
732 -  
733 - // 清空变量,释放内存  
734 - sizeInfo = {};  
735 - }  
736 -  
737 - return dest;  
738 -};  
739 -  
740 -  
741 module.exports = (data) => { 500 module.exports = (data) => {
742 var finalResult; 501 var finalResult;
743 502
@@ -749,35 +508,14 @@ module.exports = (data) => { @@ -749,35 +508,14 @@ module.exports = (data) => {
749 })).then(result => { 508 })).then(result => {
750 finalResult = detailDataPkg(result, data.uid, data.vipLevel, data.ua); 509 finalResult = detailDataPkg(result, data.uid, data.vipLevel, data.ua);
751 510
752 - let urls = [];  
753 -  
754 - let url = [];  
755 -  
756 - url.url = '';  
757 - url.data = sign.apiSign({ 511 + return api.get('', sign.apiSign({
758 method: 'app.shop.queryShopsByBrandId', 512 method: 'app.shop.queryShopsByBrandId',
759 brand_id: result.brand.id 513 brand_id: result.brand.id
760 - });  
761 -  
762 - urls.push(url);  
763 -  
764 - url = {};  
765 -  
766 - url.url = '';  
767 - url.data = sign.apiSign({  
768 - method: 'h5.product.intro',  
769 - productskn: result.productPriceBo.productSkn,  
770 - udid: 'f528764d624db129b32c21fbca0cb8d6'  
771 - });  
772 -  
773 - urls.push(url);  
774 -  
775 - return api.multiGet(urls).then(shops => {  
776 - // log.info(shops);  
777 - if (shops[0].code === 200) {  
778 - finalResult.enterStore = getShopsInfo(shops[0].data); 514 + })).then(shops => {
  515 + if (shops.code === 200) {
  516 + finalResult.enterStore = getShopsInfo(shops.data);
779 } 517 }
780 - finalResult.sizeInfo = getSizeInfo(shops[1]); 518 +
781 return finalResult; 519 return finalResult;
782 }); 520 });
783 }); 521 });
@@ -12,7 +12,11 @@ const cRoot = './controllers'; @@ -12,7 +12,11 @@ const cRoot = './controllers';
12 // 商品详情controller 12 // 商品详情controller
13 const detail = require(`${cRoot}/detail`); 13 const detail = require(`${cRoot}/detail`);
14 14
  15 +// 商品介紹controller
  16 +const intro = require(`${cRoot}/intro`);
  17 +
15 // routers 18 // routers
16 router.get('/detail/:id/:gid', detail.index); 19 router.get('/detail/:id/:gid', detail.index);
  20 +router.get('/intro/:productskn', intro.index);
17 21
18 module.exports = router; 22 module.exports = router;