Merge branch 'feature/cart' of git.yoho.cn:fe/yohobuywap-node into feature/cart
Showing
5 changed files
with
384 additions
and
538 deletions
@@ -321,7 +321,7 @@ const modify = (req, res, next) => { | @@ -321,7 +321,7 @@ const modify = (req, res, next) => { | ||
321 | data ? res.json(data) : res.status(400).json({ | 321 | data ? res.json(data) : res.status(400).json({ |
322 | message: '操作失败' | 322 | message: '操作失败' |
323 | }); | 323 | }); |
324 | - }); | 324 | + }).catch(next); |
325 | }; | 325 | }; |
326 | 326 | ||
327 | /** | 327 | /** |
@@ -351,7 +351,7 @@ const modifyPriceGift = (req, res, next) => { | @@ -351,7 +351,7 @@ const modifyPriceGift = (req, res, next) => { | ||
351 | data ? res.json(data) : res.status(400).json({ | 351 | data ? res.json(data) : res.status(400).json({ |
352 | message: '操作失败' | 352 | message: '操作失败' |
353 | }); | 353 | }); |
354 | - }); | 354 | + }).catch(next); |
355 | }; | 355 | }; |
356 | 356 | ||
357 | /** | 357 | /** |
@@ -457,7 +457,7 @@ const giftinfo = (req, res, next) => { | @@ -457,7 +457,7 @@ const giftinfo = (req, res, next) => { | ||
457 | }) : res.status(400).json({ | 457 | }) : res.status(400).json({ |
458 | message: '操作失败' | 458 | message: '操作失败' |
459 | }); | 459 | }); |
460 | - }); | 460 | + }).catch(next); |
461 | }; | 461 | }; |
462 | 462 | ||
463 | module.exports = { | 463 | module.exports = { |
@@ -588,11 +588,7 @@ let getProductAsyncData = (data) => { | @@ -588,11 +588,7 @@ let getProductAsyncData = (data) => { | ||
588 | * [商品信息格式化异步接口] | 588 | * [商品信息格式化异步接口] |
589 | */ | 589 | */ |
590 | let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | 590 | let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { |
591 | - let dest = {}, // 结果输出 | ||
592 | - thumbImageList = [], | ||
593 | - colorGroup = {}, | ||
594 | - sizeGroup = [], | ||
595 | - totalStorageNum = 0; | 591 | + let dest = {}; // 结果输出 |
596 | 592 | ||
597 | // 用户未登录时 | 593 | // 用户未登录时 |
598 | if (!uid) { | 594 | if (!uid) { |
@@ -679,141 +675,8 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | @@ -679,141 +675,8 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | ||
679 | } | 675 | } |
680 | 676 | ||
681 | // 商品信息 | 677 | // 商品信息 |
682 | - if (origin.goods_list.length) { | ||
683 | - let goodsGroup = [], | ||
684 | - sizeName = '', | ||
685 | - colorList = [], | ||
686 | - sizeList = {}, | ||
687 | - allSizeList = {}, | ||
688 | - colorStorageGroup = {}, | ||
689 | - colorStorageNum = 0; | ||
690 | - | ||
691 | - _.forEach(origin.goods_list, function(value) { | ||
692 | - // 未上架也显示 | ||
693 | - // if (value.status === 0) { | ||
694 | - // return; | ||
695 | - // } | ||
696 | - | ||
697 | - colorStorageNum = 0; | ||
698 | - | ||
699 | - // 商品分组 | ||
700 | - if (value.images_list) { | ||
701 | - _.forEach(value.images_list, function(good) { | ||
702 | - goodsGroup.push({ | ||
703 | - goodsId: value.goods_id, | ||
704 | - img: good.image_url | ||
705 | - }); | ||
706 | - }); | ||
707 | - } | ||
708 | - | ||
709 | - // 商品的尺码列表 | ||
710 | - colorStorageGroup[value.product_skc] = {}; | ||
711 | - if (value.size_list) { | ||
712 | - sizeList[value.product_skc] = []; | ||
713 | - _.forEach(value.size_list, function(size) { | ||
714 | - sizeList[value.product_skc].push({ | ||
715 | - id: size.size_id, | ||
716 | - skuId: size.product_sku, | ||
717 | - goodsId: value.goods_id, | ||
718 | - colorId: value.color_id, | ||
719 | - name: size.size_name, | ||
720 | - sizeNum: size.storage_number, | ||
721 | - sizeInfo: size.size_info ? size.size_info : '' | ||
722 | - }); | ||
723 | - | ||
724 | - sizeName = size.size_name; | ||
725 | - | ||
726 | - // 所有尺码列表,赋值用于前端展示默认尺码的时候 | ||
727 | - // 判断出没有库存则显示灰色 | ||
728 | - let build = { | ||
729 | - id: size.size_id, | ||
730 | - storage: size.storage_number, | ||
731 | - sizeInfo: size.size_info ? size.size_info : '' | ||
732 | - }; | ||
733 | - | ||
734 | - allSizeList[sizeName] = (allSizeList[sizeName] === null || | ||
735 | - typeof allSizeList[sizeName] === 'undefined') ? build : allSizeList[sizeName]; | ||
736 | - colorStorageNum += parseInt(size.storage_number, 10); | ||
737 | - colorStorageGroup[value.product_skc][sizeName] = parseInt(size.storage_number, 10); | ||
738 | - }); | ||
739 | - | ||
740 | - | ||
741 | - // 颜色分组 | ||
742 | - colorList.push({ | ||
743 | - id: value.color_id, | ||
744 | - skcId: value.product_skc, | ||
745 | - name: value.factory_goods_name || value.color_name, | ||
746 | - colorNum: colorStorageNum | ||
747 | - }); | ||
748 | - } | ||
749 | - | ||
750 | - // 缩略图 | ||
751 | - thumbImageList.push({ | ||
752 | - img: helpers.image(value.color_image, 300, 395) | ||
753 | - }); | ||
754 | - | ||
755 | - // 商品库存总数 | ||
756 | - totalStorageNum += _.toNumber(colorStorageNum); | ||
757 | - }); | ||
758 | - | ||
759 | - // 遍历所有尺码,构建颜色显示数据 | ||
760 | - let i = 1; | ||
761 | - | ||
762 | - sizeGroup[0] = { | ||
763 | - size: [] | ||
764 | - }; | ||
765 | - _.forEach(allSizeList, (value, key) => { | ||
766 | - | ||
767 | - // 默认尺码 | ||
768 | - sizeGroup[0].size.push({ | ||
769 | - name: key, | ||
770 | - sizeNum: _.toNumber(value.storage) > 0 ? true : false, | ||
771 | - id: value.id, | ||
772 | - sizeInfo: value.sizeInfo | ||
773 | - }); | ||
774 | - | ||
775 | - colorGroup[i] = { | ||
776 | - color: [] | ||
777 | - }; | ||
778 | - | ||
779 | - // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | ||
780 | - _.forEach(colorList, (colorArr) => { | ||
781 | - let tempColorArr = _.cloneDeep(colorArr); | ||
782 | - | ||
783 | - if (colorStorageGroup[tempColorArr.skcId] && | ||
784 | - colorStorageGroup[tempColorArr.skcId][key]) { | ||
785 | - tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key]; | ||
786 | - } else { | ||
787 | - tempColorArr.colorNum = 0; | ||
788 | - } | ||
789 | - colorGroup[i].color.push(Object.assign({}, tempColorArr)); | ||
790 | - }); | ||
791 | - colorGroup[i].id = value.id; | ||
792 | - | ||
793 | - ++i; | ||
794 | - }); | ||
795 | - | ||
796 | - colorGroup[0] = { | ||
797 | - color: [] | ||
798 | - }; | ||
799 | - | ||
800 | - // 遍历所有颜色, 构建尺码显示数据 | ||
801 | - i = 1; | ||
802 | - _.forEach(colorList, function(value) { | ||
803 | - | ||
804 | - // 各个尺码的颜色, 每行显示一个颜色的对应尺码 | ||
805 | - sizeGroup[i] = { | ||
806 | - size: sizeList[value.skcId], | ||
807 | - colorId: value.skcId | ||
808 | - }; | ||
809 | - | ||
810 | - // 默认颜色 | ||
811 | - colorGroup[0].color.push(value); | ||
812 | - ++i; | ||
813 | - }); | ||
814 | - | ||
815 | - } | ||
816 | - let soldOut = (origin.storage_sum === 0) || (totalStorageNum === 0); // status | 678 | + let cartInfo = productProcess.processSizeInfo(origin); |
679 | + let soldOut = (origin.storage_sum === 0) || (cartInfo.totalStorageNum === 0); // status | ||
817 | let notForSale = origin.attribute === 2; | 680 | let notForSale = origin.attribute === 2; |
818 | let preSale = (origin.status === 0 && origin.advance_shelve_time > 0); | 681 | let preSale = (origin.status === 0 && origin.advance_shelve_time > 0); |
819 | 682 | ||
@@ -827,16 +690,9 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | @@ -827,16 +690,9 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | ||
827 | 690 | ||
828 | // 显示加入购物车链接 | 691 | // 显示加入购物车链接 |
829 | if (!soldOut && !notForSale && !preSale || origin.isLimitBuy) { | 692 | if (!soldOut && !notForSale && !preSale || origin.isLimitBuy) { |
830 | - _.orderBy(colorGroup); | ||
831 | - Object.assign(dest.cartInfo, { | ||
832 | - productId: origin.product_id, | ||
833 | - thumbs: thumbImageList, | ||
834 | - name: dest.goodsName || '', | 693 | + Object.assign(dest.cartInfo, cartInfo, { |
835 | price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '', | 694 | price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '', |
836 | salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '', | 695 | salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '', |
837 | - totalNum: totalStorageNum, | ||
838 | - colors: _.toArray(colorGroup), | ||
839 | - sizes: sizeGroup | ||
840 | }); | 696 | }); |
841 | 697 | ||
842 | // 限购商品 | 698 | // 限购商品 |
@@ -889,33 +745,33 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | @@ -889,33 +745,33 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => { | ||
889 | dest.cartInfo.preSale = true; | 745 | dest.cartInfo.preSale = true; |
890 | } | 746 | } |
891 | return resolve(dest); | 747 | return resolve(dest); |
892 | - }).then(dest => { | 748 | + }).then(result => { |
893 | // 虚拟商品(门票) | 749 | // 虚拟商品(门票) |
894 | if (origin.attribute * 1 === 3) { | 750 | if (origin.attribute * 1 === 3) { |
895 | - dest.tickets = true; | ||
896 | - dest.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm'); | 751 | + result.tickets = true; |
752 | + result.ticketsConfirm = helpers.urlFormat('/cart/index/ticketsConfirm'); | ||
897 | 753 | ||
898 | // 展览票 | 754 | // 展览票 |
899 | if (origin.product_skn * 1 === SINGLE_TICKETS_SKN) { | 755 | if (origin.product_skn * 1 === SINGLE_TICKETS_SKN) { |
900 | - dest.single = true; | 756 | + result.single = true; |
901 | } else { | 757 | } else { |
902 | // 套票 | 758 | // 套票 |
903 | - dest.package = true; | 759 | + result.package = true; |
904 | } | 760 | } |
905 | 761 | ||
906 | // 购票限制 | 762 | // 购票限制 |
907 | - dest.cartInfo.limit = 4; | 763 | + result.cartInfo.limit = 4; |
908 | 764 | ||
909 | // 清空活动 | 765 | // 清空活动 |
910 | - dest.goodsDiscount = []; | 766 | + result.goodsDiscount = []; |
911 | } | 767 | } |
912 | - dest.id = origin.product_id; | ||
913 | - dest.goodsId = origin.goods_id; | ||
914 | - if (dest.isSecKill === 'Y' && dest.cartInfo.totalNum > 0) { | ||
915 | - dest.totalNum = 1; | 768 | + result.id = origin.product_id; |
769 | + result.goodsId = origin.goods_id; | ||
770 | + if (result.isSecKill === 'Y' && result.cartInfo.totalNum > 0) { | ||
771 | + result.totalNum = 1; | ||
916 | } | 772 | } |
917 | - return dest; | ||
918 | - }) | 773 | + return result; |
774 | + }); | ||
919 | }; | 775 | }; |
920 | 776 | ||
921 | 777 |
@@ -11,7 +11,6 @@ | @@ -11,7 +11,6 @@ | ||
11 | overflow: hidden; | 11 | overflow: hidden; |
12 | text-align: center; | 12 | text-align: center; |
13 | } | 13 | } |
14 | - | ||
15 | .search-input { | 14 | .search-input { |
16 | position: relative; | 15 | position: relative; |
17 | padding: 14px 30px; | 16 | padding: 14px 30px; |
@@ -39,19 +38,10 @@ | @@ -39,19 +38,10 @@ | ||
39 | border: none; | 38 | border: none; |
40 | } | 39 | } |
41 | 40 | ||
42 | - .btn-intro, | ||
43 | - .btn-col { | 41 | + .clear-input { |
44 | position: absolute; | 42 | position: absolute; |
45 | - display: block; | ||
46 | - width: 124px; | ||
47 | - height: 48px; | ||
48 | - line-height: 48px; | ||
49 | - font-size: 12PX; | ||
50 | - text-align: center; | ||
51 | - border: 1px solid #fff; | ||
52 | - color: #fff; | ||
53 | - top: 50%; | ||
54 | - margin-top: -24px; | 43 | + top: 10px; |
44 | + right: 100px; | ||
55 | } | 45 | } |
56 | 46 | ||
57 | .search { | 47 | .search { |
@@ -85,183 +75,175 @@ | @@ -85,183 +75,175 @@ | ||
85 | overflow: hidden; | 75 | overflow: hidden; |
86 | } | 76 | } |
87 | 77 | ||
88 | - .btn-col { | ||
89 | - right: 30px; | ||
90 | - | ||
91 | - .iconfont { | ||
92 | - font-size: 12PX; | ||
93 | - } | ||
94 | - | ||
95 | - .brand-name { | ||
96 | - width: 40%; | ||
97 | - overflow: hidden; | ||
98 | - text-overflow: ellipsis; | ||
99 | - white-space: nowrap; | ||
100 | - position: absolute; | ||
101 | - } | ||
102 | - | ||
103 | - .brand-thumb { | ||
104 | - display: block; | ||
105 | - float: left; | ||
106 | - width: 150px; | ||
107 | - height: 80px; | ||
108 | - margin: 0; | ||
109 | - } | 78 | + span { |
79 | + font-size: 28px; | ||
80 | + overflow: hidden; | ||
81 | + text-overflow: ellipsis; | ||
82 | + white-space: nowrap; | ||
83 | + } | ||
110 | 84 | ||
111 | - .entry { | ||
112 | - color: #999; | ||
113 | - font-size: 28px; | ||
114 | - float: right; | ||
115 | - } | 85 | + .brand-name { |
86 | + width: 40%; | ||
87 | + overflow: hidden; | ||
88 | + text-overflow: ellipsis; | ||
89 | + white-space: nowrap; | ||
90 | + position: absolute; | ||
116 | } | 91 | } |
117 | 92 | ||
118 | - .brand-header { | ||
119 | - position: relative; | ||
120 | - height: 150px; | 93 | + .brand-thumb { |
94 | + display: block; | ||
95 | + float: left; | ||
96 | + width: 150px; | ||
97 | + height: 80px; | ||
98 | + margin: 0; | ||
99 | + } | ||
121 | 100 | ||
122 | - > img { | ||
123 | - display: block; | ||
124 | - height: 100%; | ||
125 | - width: 100%; | ||
126 | - } | 101 | + .entry { |
102 | + color: #999; | ||
103 | + font-size: 28px; | ||
104 | + float: right; | ||
127 | } | 105 | } |
106 | + } | ||
128 | 107 | ||
129 | - .btn-intro, | ||
130 | - .btn-col { | ||
131 | - position: absolute; | 108 | + .brand-header { |
109 | + position: relative; | ||
110 | + height: 150px; | ||
111 | + | ||
112 | + > img { | ||
132 | display: block; | 113 | display: block; |
133 | - width: 124px; | ||
134 | - height: 48px; | ||
135 | - line-height: 48px; | ||
136 | - text-align: center; | ||
137 | - border: 1px solid #fff; | ||
138 | - color: #fff; | ||
139 | - top: 50%; | ||
140 | - margin-top: -24px; | 114 | + height: 100%; |
115 | + width: 100%; | ||
141 | } | 116 | } |
117 | + } | ||
142 | 118 | ||
143 | - .btn-intro { | ||
144 | - right: 180px; | ||
145 | - } | 119 | + .btn-intro, |
120 | + .btn-col { | ||
121 | + position: absolute; | ||
122 | + display: block; | ||
123 | + width: 124px; | ||
124 | + height: 48px; | ||
125 | + line-height: 48px; | ||
126 | + font-size: 12PX; | ||
127 | + text-align: center; | ||
128 | + border: 1px solid #fff; | ||
129 | + color: #fff; | ||
130 | + top: 50%; | ||
131 | + margin-top: -24px; | ||
132 | + } | ||
146 | 133 | ||
147 | - .btn-col { | ||
148 | - right: 30px; | 134 | + .btn-intro { |
135 | + right: 180px; | ||
136 | + } | ||
149 | 137 | ||
150 | - .iconfont { | ||
151 | - font-size: 24px; | ||
152 | - } | 138 | + .btn-col { |
139 | + right: 30px; | ||
153 | 140 | ||
154 | - &.coled { | ||
155 | - opacity: 0.5; | ||
156 | - } | 141 | + .iconfont { |
142 | + font-size: 12PX; | ||
143 | + } | ||
157 | 144 | ||
158 | - .txt:after { | ||
159 | - content: "收藏"; | ||
160 | - } | 145 | + &.coled { |
146 | + opacity: 0.5; | ||
147 | + } | ||
161 | 148 | ||
162 | - &.coled .txt:after { | ||
163 | - content: "已收藏"; | ||
164 | - } | 149 | + .txt:after { |
150 | + content: "收藏"; | ||
165 | } | 151 | } |
166 | 152 | ||
167 | - .brand-intro-box { | ||
168 | - position: fixed; | ||
169 | - top: 0; | ||
170 | - left: 0; | ||
171 | - right: 0; | ||
172 | - bottom: 0; | ||
173 | - background: rgba(0, 0, 0, 0.3); | ||
174 | - padding: 88px 0; | ||
175 | - z-index: 10; | ||
176 | - overflow: auto; | ||
177 | - | ||
178 | - .brand-intro { | ||
179 | - position: relative; | ||
180 | - box-sizing: border-box; | ||
181 | - width: 85%; | ||
182 | - margin: 0 7.5%; | ||
183 | - background: #fff; | ||
184 | - padding: 20px 8%; | ||
185 | - } | 153 | + &.coled .txt:after { |
154 | + content: "已收藏"; | ||
155 | + } | ||
156 | + } | ||
186 | 157 | ||
187 | - h2 { | ||
188 | - text-align: center; | ||
189 | - font-size: 34px; | ||
190 | - line-height: 80px; | ||
191 | - } | 158 | + .brand-intro-box { |
159 | + position: fixed; | ||
160 | + top: 0; | ||
161 | + left: 0; | ||
162 | + right: 0; | ||
163 | + bottom: 0; | ||
164 | + background: rgba(0, 0, 0, 0.3); | ||
165 | + padding: 88px 0; | ||
166 | + z-index: 10; | ||
167 | + overflow: auto; | ||
168 | + | ||
169 | + .brand-intro { | ||
170 | + position: relative; | ||
171 | + box-sizing: border-box; | ||
172 | + width: 85%; | ||
173 | + margin: 0 7.5%; | ||
174 | + background: #fff; | ||
175 | + padding: 20px 8%; | ||
176 | + } | ||
192 | 177 | ||
193 | - .list-nav { | ||
194 | - border-top: 2px solid #fff; | ||
195 | - border-bottom: 1px solid #e6e6e6; | ||
196 | - | ||
197 | - > li { | ||
198 | - float: left; | ||
199 | - width: 25%; | ||
200 | - height: 33PX; | ||
201 | - line-height: 33PX; | ||
202 | - text-align: center; | ||
203 | - font-size: 14PX; | ||
204 | - } | 178 | + h2 { |
179 | + text-align: center; | ||
180 | + font-size: 34px; | ||
181 | + line-height: 80px; | ||
182 | + } | ||
205 | 183 | ||
206 | - .fo { | ||
207 | - font-size: 36px; | ||
208 | - height: 80px; | ||
209 | - line-height: 80px; | ||
210 | - text-align: center; | 184 | + .con { |
185 | + font-size: 24px; | ||
186 | + line-height: 32px; | ||
187 | + padding: 40px 0; | ||
188 | + border-top: 1px solid #e6e6e6; | ||
189 | + border-bottom: 1px solid #e6e6e6; | ||
190 | + overflow-x: hidden; | ||
191 | + } | ||
211 | 192 | ||
212 | - > span { | ||
213 | - font-size: 44px; | ||
214 | - } | ||
215 | - } | 193 | + .fo { |
194 | + font-size: 36px; | ||
195 | + height: 80px; | ||
196 | + line-height: 80px; | ||
197 | + text-align: center; | ||
216 | 198 | ||
217 | - .close-intro { | ||
218 | - position: absolute; | ||
219 | - top: 12px; | ||
220 | - right: 12px; | ||
221 | - } | 199 | + > span { |
200 | + font-size: 44px; | ||
222 | } | 201 | } |
202 | + } | ||
223 | 203 | ||
224 | - .list-nav { | ||
225 | - border-top: 2px solid #fff; | ||
226 | - border-bottom: 1px solid #e6e6e6; | ||
227 | - | ||
228 | - > li { | ||
229 | - float: left; | ||
230 | - width: 25%; | ||
231 | - height: 66px; | ||
232 | - line-height: 66px; | ||
233 | - text-align: center; | ||
234 | - font-size: 28px; | ||
235 | - } | 204 | + .close-intro { |
205 | + position: absolute; | ||
206 | + top: 12px; | ||
207 | + right: 12px; | ||
208 | + } | ||
209 | + } | ||
236 | 210 | ||
237 | - .bytouch { | ||
238 | - background: #eee; | ||
239 | - } | 211 | + .list-nav { |
212 | + border-top: 2px solid #fff; | ||
213 | + border-bottom: 1px solid #e6e6e6; | ||
240 | 214 | ||
241 | - a { | ||
242 | - display: block; | ||
243 | - box-sizing: border-box; | ||
244 | - width: 100%; | ||
245 | - height: 100%; | ||
246 | - color: #999; | ||
247 | - } | 215 | + > li { |
216 | + float: left; | ||
217 | + width: 25%; | ||
218 | + height: 33PX; | ||
219 | + line-height: 33PX; | ||
220 | + text-align: center; | ||
221 | + font-size: 14PX; | ||
222 | + } | ||
248 | 223 | ||
249 | - .nav-txt { | ||
250 | - display: inline-block; | ||
251 | - height: 100%; | ||
252 | - box-sizing: border-box; | ||
253 | - } | 224 | + .bytouch { |
225 | + background: #eee; | ||
226 | + } | ||
254 | 227 | ||
255 | - .new .iconfont { | ||
256 | - transform: scale(0.8); | ||
257 | - font-weight: bold; | ||
258 | - font-size: 12PX; | ||
259 | - } | 228 | + a { |
229 | + display: block; | ||
230 | + box-sizing: border-box; | ||
231 | + width: 100%; | ||
232 | + height: 100%; | ||
233 | + color: #999; | ||
234 | + } | ||
260 | 235 | ||
261 | - .filter .iconfont { | ||
262 | - font-size: 12PX; | ||
263 | - transition: transform 0.1 ease-in; | ||
264 | - } | 236 | + .nav-txt { |
237 | + display: inline-block; | ||
238 | + height: 100%; | ||
239 | + box-sizing: border-box; | ||
240 | + } | ||
241 | + | ||
242 | + .active > a { | ||
243 | + color: #000; | ||
244 | + | ||
245 | + .iconfont { | ||
246 | + color: #999; | ||
265 | 247 | ||
266 | &.cur { | 248 | &.cur { |
267 | color: #000; | 249 | color: #000; |
@@ -269,6 +251,21 @@ | @@ -269,6 +251,21 @@ | ||
269 | } | 251 | } |
270 | } | 252 | } |
271 | 253 | ||
254 | + .new .iconfont { | ||
255 | + transform: scale(0.8); | ||
256 | + font-weight: bold; | ||
257 | + font-size: 12PX; | ||
258 | + } | ||
259 | + | ||
260 | + .filter .iconfont { | ||
261 | + font-size: 12PX; | ||
262 | + transition: transform 0.1 ease-in; | ||
263 | + } | ||
264 | + | ||
265 | + .filter.active .iconfont { | ||
266 | + transform: rotate(-180deg); | ||
267 | + } | ||
268 | + | ||
272 | .icon { | 269 | .icon { |
273 | position: relative; | 270 | position: relative; |
274 | 271 | ||
@@ -288,85 +285,58 @@ | @@ -288,85 +285,58 @@ | ||
288 | } | 285 | } |
289 | } | 286 | } |
290 | 287 | ||
291 | - .filter .iconfont { | ||
292 | - font-size: 24px; | ||
293 | - transition: transform 0.1 ease-in; | ||
294 | - } | ||
295 | - | ||
296 | - .filter.active .iconfont { | ||
297 | - transform: rotate(-180deg); | 288 | + .no-result { |
289 | + text-align: center; | ||
290 | + vertical-align: middle; | ||
291 | + color: #ccc; | ||
292 | + font-size: 1.2em; | ||
293 | + margin-top: 440px; | ||
298 | } | 294 | } |
299 | 295 | ||
300 | - .icon { | 296 | + .goods-container { |
301 | position: relative; | 297 | position: relative; |
298 | + min-height: 880px; | ||
299 | + padding-left: 0.375rem; | ||
300 | + padding-top: 0.2rem; | ||
301 | + } | ||
302 | 302 | ||
303 | - i { | ||
304 | - position: absolute; | ||
305 | - transform: scale(0.8); | ||
306 | - font-weight: bold; | ||
307 | - } | 303 | + .new-list { |
304 | + width: 100%; | ||
305 | + background-color: #fff; | ||
306 | + font-size: 28px; | ||
307 | + color: #444; | ||
308 | + position: absolute; | ||
309 | + z-index: 5; | ||
310 | + | ||
311 | + li { | ||
312 | + margin-left: 35px; | ||
313 | + height: 88px; | ||
314 | + line-height: 88px; | ||
315 | + border-bottom: 1px solid #e0e0e0; | ||
316 | + padding-right: 38px; | ||
317 | + | ||
318 | + &:last-child { | ||
319 | + border-bottom: none; | ||
320 | + } | ||
308 | 321 | ||
309 | - .up { | ||
310 | - top: -22px; | 322 | + &.active { |
323 | + background: resolve('product/shop/check.png') no-repeat 94% center; | ||
324 | + background-size: 36px 26px; | ||
325 | + } | ||
311 | } | 326 | } |
327 | + } | ||
312 | 328 | ||
313 | - .down { | ||
314 | - top: -8px; | ||
315 | - } | 329 | + .suspend-home { |
330 | + bottom: 258px; | ||
316 | } | 331 | } |
317 | -} | ||
318 | - | ||
319 | -.no-result { | ||
320 | - text-align: center; | ||
321 | - vertical-align: middle; | ||
322 | - color: #ccc; | ||
323 | - font-size: 1.2em; | ||
324 | - margin-top: 440px; | ||
325 | -} | ||
326 | - | ||
327 | -.goods-container { | ||
328 | - position: relative; | ||
329 | - min-height: 880px; | ||
330 | - padding-left: 0.375rem; | ||
331 | - padding-top: 0.2rem; | ||
332 | -} | ||
333 | - | ||
334 | -.new-list { | ||
335 | - width: 100%; | ||
336 | - background-color: #fff; | ||
337 | - font-size: 28px; | ||
338 | - color: #444; | ||
339 | - position: absolute; | ||
340 | - z-index: 5; | ||
341 | - | ||
342 | - li { | ||
343 | - margin-left: 35px; | ||
344 | - height: 88px; | ||
345 | - line-height: 88px; | ||
346 | - border-bottom: 1px solid #e0e0e0; | ||
347 | - padding-right: 38px; | ||
348 | - | ||
349 | - &:last-child { | ||
350 | - border-bottom: none; | ||
351 | - } | ||
352 | 332 | ||
353 | - &.active { | ||
354 | - background: resolve("product/shop/check.png") no-repeat 94% center; | ||
355 | - background-size: 36px 26px; | ||
356 | - } | 333 | + /*搜索分割*/ |
334 | + .search-divide { | ||
335 | + float: left; | ||
336 | + height: 50px; | ||
337 | + width: 100%; | ||
338 | + padding: 10px 0; | ||
339 | + color: #ccc; | ||
340 | + text-align: center; | ||
357 | } | 341 | } |
358 | -} | ||
359 | - | ||
360 | -.suspend-home { | ||
361 | - bottom: 258px; | ||
362 | -} | ||
363 | - | ||
364 | -/* 搜索分割 */ | ||
365 | -.search-divide { | ||
366 | - float: left; | ||
367 | - height: 50px; | ||
368 | - width: 100%; | ||
369 | - padding: 10px 0; | ||
370 | - color: #ccc; | ||
371 | - text-align: center; | ||
372 | -} | 342 | +} |
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | 6 | ||
7 | const helpers = global.yoho.helpers; | 7 | const helpers = global.yoho.helpers; |
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | +const productProcess = require('./product-process'); | ||
9 | 10 | ||
10 | const regPromoTitle = /^【[^】]+】(.*)/; | 11 | const regPromoTitle = /^【[^】]+】(.*)/; |
11 | 12 | ||
@@ -203,8 +204,9 @@ const formatPromotion = (promo) => { | @@ -203,8 +204,9 @@ const formatPromotion = (promo) => { | ||
203 | */ | 204 | */ |
204 | const procGoodsDetail = (productData, num) => { | 205 | const procGoodsDetail = (productData, num) => { |
205 | let data = {}; | 206 | let data = {}; |
207 | + let sizeInfo = productProcess.processSizeInfo(productData); | ||
206 | 208 | ||
207 | - data.name = productData.product_name; | 209 | + Object.assign(data, sizeInfo); |
208 | data.productSkn = productData.product_skn; | 210 | data.productSkn = productData.product_skn; |
209 | if (_.has(productData, 'special_price')) { // 加价购或者赠品的销售价字段 | 211 | if (_.has(productData, 'special_price')) { // 加价购或者赠品的销售价字段 |
210 | data.price = productData.format_market_price; | 212 | data.price = productData.format_market_price; |
@@ -222,145 +224,8 @@ const procGoodsDetail = (productData, num) => { | @@ -222,145 +224,8 @@ const procGoodsDetail = (productData, num) => { | ||
222 | if (num) { | 224 | if (num) { |
223 | data.num = _.parseInt(num); | 225 | data.num = _.parseInt(num); |
224 | } | 226 | } |
225 | - | ||
226 | - // 商品选择 | ||
227 | - if (_.has(productData, 'goods_list')) { | ||
228 | - let goodsList = productData.goods_list; | ||
229 | - let sizeName = '', | ||
230 | - colors = [], | ||
231 | - colorList = [], | ||
232 | - sizes = [], | ||
233 | - sizeList = {}, | ||
234 | - allSizeList = {}, // 所有尺码列表 | ||
235 | - thumbImageList = [], | ||
236 | - colorNum = 0, | ||
237 | - totalStorageNum = 0, // 总库存数 | ||
238 | - colorStorageGroup = {}; // 颜色分组的库存总数集合, 多个之间用/分隔 | ||
239 | - | ||
240 | - goodsList.forEach(val => { | ||
241 | - // 商品的尺码列表 | ||
242 | - if (!colorStorageGroup[val.product_skc]) { | ||
243 | - colorStorageGroup[val.product_skc] = {}; | ||
244 | - } | ||
245 | - if (_.has(val, 'size_list')) { | ||
246 | - // 尺码 | ||
247 | - if (!sizeList[val.product_skc]) { | ||
248 | - sizeList[val.product_skc] = []; | ||
249 | - } | ||
250 | - val.size_list.forEach(one => { | ||
251 | - sizeName = one.size_name; | ||
252 | - sizeList[val.product_skc].push({ | ||
253 | - id: one.size_id, | ||
254 | - skuId: one.product_sku, | ||
255 | - goodsId: val.goods_id, | ||
256 | - colorId: val.color_id, | ||
257 | - name: one.size_name, | ||
258 | - sizeNum: _.parseInt(one.storage_number, 10), | ||
259 | - sizeInfo: one.size_info ? one.size_info : '' | ||
260 | - }); | ||
261 | - | ||
262 | - // 所有尺码列表,赋值用于前端展示默认尺码的时候 判断出没有库存则显示灰色 | ||
263 | - allSizeList[sizeName] = !_.has(allSizeList, sizeName) ? { | ||
264 | - id: one.size_id, | ||
265 | - storage: one.storage_number, | ||
266 | - sizeInfo: one.size_info ? one.size_info : '' | ||
267 | - } : allSizeList[sizeName]; | ||
268 | - | ||
269 | - colorNum += _.parseInt(one.storage_number, 10); | ||
270 | - | ||
271 | - colorStorageGroup[val.product_skc][sizeName] = _.parseInt(one.storage_number, 10); | ||
272 | - }); | ||
273 | - | ||
274 | - // 颜色分组 | ||
275 | - colorList.push({ | ||
276 | - id: val.color_id, | ||
277 | - skcId: val.product_skc, | ||
278 | - name: val.factory_goods_name || val.color_name, | ||
279 | - colorNum: colorNum, | ||
280 | - goodsName: productData.product_name | ||
281 | - }); | ||
282 | - } | ||
283 | - | ||
284 | - // 缩略图 | ||
285 | - thumbImageList.push({ | ||
286 | - img: helpers.image(val.color_image, 300, 395) | ||
287 | - }); | ||
288 | - | ||
289 | - // 商品库存总数 | ||
290 | - totalStorageNum += colorNum; | ||
291 | - }); | ||
292 | - | ||
293 | - // 遍历所有尺码,构建颜色显示数据 | ||
294 | - let i = 1; | ||
295 | - | ||
296 | - if (!sizes[0]) { | ||
297 | - sizes[0] = { | ||
298 | - size: [] | ||
299 | - }; | ||
300 | - } | ||
301 | - if (!colors[0]) { | ||
302 | - colors[0] = { | ||
303 | - color: [] | ||
304 | - }; | ||
305 | - } | ||
306 | - _.forEach(allSizeList, (value, sName) => { | ||
307 | - // 默认尺码 | ||
308 | - sizes[0].size.push({ | ||
309 | - name: sName, | ||
310 | - sizeNum: _.toNumber(value.storage) > 0 ? true : false, | ||
311 | - id: value.id, | ||
312 | - sizeInfo: value.sizeInfo | ||
313 | - }); | ||
314 | - | ||
315 | - // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | ||
316 | - if (!colors[i]) { | ||
317 | - colors[i] = { | ||
318 | - color: [] | ||
319 | - }; | ||
320 | - } | ||
321 | - colorList.forEach(colorArr => { | ||
322 | - colors[i].color.push({ | ||
323 | - id: colorArr.id, | ||
324 | - skcId: colorArr.skcId, | ||
325 | - name: colorArr.name, | ||
326 | - colorNum: _.has(colorStorageGroup, `${colorArr.skcId}.${sName}`) ? _.parseInt(colorStorageGroup[colorArr.skcId][sName], 10) : 0, | ||
327 | - goodsName: colorArr.goodsName | ||
328 | - }); | ||
329 | - }); | ||
330 | - | ||
331 | - colors[i].id = value.id; | ||
332 | - | ||
333 | - ++i; | ||
334 | - }); | ||
335 | - | ||
336 | - // 遍历所有颜色, 构建尺码显示数据 | ||
337 | - i = 1; | ||
338 | - if (!sizes[i]) { | ||
339 | - sizes[i] = { | ||
340 | - color: [] | ||
341 | - }; | ||
342 | - } | ||
343 | - colorList.forEach(value => { | ||
344 | - // 各个尺码的颜色,每行显示一个颜色的对应尺码 | ||
345 | - sizes[i] = { | ||
346 | - size: sizeList[value.skcId], | ||
347 | - colorId: value.skcId | ||
348 | - }; | ||
349 | - | ||
350 | - // 默认颜色 | ||
351 | - colors[0].color.push(value); | ||
352 | - | ||
353 | - ++i; | ||
354 | - }); | ||
355 | - data.thumbs = thumbImageList; | ||
356 | - data.colors = colors; | ||
357 | - data.sizes = sizes; | ||
358 | - data.totalNum = totalStorageNum; | ||
359 | - | ||
360 | - data.colorName = '颜色'; | ||
361 | - data.sizeName = '尺码'; | ||
362 | - } | ||
363 | - | 227 | + data.colorName = '颜色'; |
228 | + data.sizeName = '尺码'; | ||
364 | return data; | 229 | return data; |
365 | }; | 230 | }; |
366 | 231 |
@@ -344,3 +344,158 @@ exports.processFilter = (list, options) => { | @@ -344,3 +344,158 @@ exports.processFilter = (list, options) => { | ||
344 | 344 | ||
345 | return filters; | 345 | return filters; |
346 | }; | 346 | }; |
347 | + | ||
348 | +/** | ||
349 | + * 解析尺码弹出框数据 | ||
350 | + */ | ||
351 | +exports.processSizeInfo = (origin) => { | ||
352 | + let cartInfo = {}, | ||
353 | + thumbImageList = [], | ||
354 | + colorGroup = {}, | ||
355 | + sizeGroup = [], | ||
356 | + totalStorageNum = 0; | ||
357 | + | ||
358 | + if (origin.goods_list.length) { | ||
359 | + let goodsGroup = [], | ||
360 | + sizeName = '', | ||
361 | + colorList = [], | ||
362 | + sizeList = {}, | ||
363 | + allSizeList = {}, | ||
364 | + colorStorageGroup = {}, | ||
365 | + colorStorageNum = 0; | ||
366 | + | ||
367 | + _.forEach(origin.goods_list, function(value) { | ||
368 | + // 未上架也显示 | ||
369 | + // if (value.status === 0) { | ||
370 | + // return; | ||
371 | + // } | ||
372 | + | ||
373 | + colorStorageNum = 0; | ||
374 | + | ||
375 | + // 商品分组 | ||
376 | + if (value.images_list) { | ||
377 | + _.forEach(value.images_list, function(good) { | ||
378 | + goodsGroup.push({ | ||
379 | + goodsId: value.goods_id, | ||
380 | + img: good.image_url | ||
381 | + }); | ||
382 | + }); | ||
383 | + } | ||
384 | + | ||
385 | + // 商品的尺码列表 | ||
386 | + colorStorageGroup[value.product_skc] = {}; | ||
387 | + if (value.size_list) { | ||
388 | + sizeList[value.product_skc] = []; | ||
389 | + _.forEach(value.size_list, function(size) { | ||
390 | + sizeList[value.product_skc].push({ | ||
391 | + id: size.size_id, | ||
392 | + skuId: size.product_sku, | ||
393 | + goodsId: value.goods_id, | ||
394 | + colorId: value.color_id, | ||
395 | + name: size.size_name, | ||
396 | + sizeNum: size.storage_number, | ||
397 | + sizeInfo: size.size_info ? size.size_info : '' | ||
398 | + }); | ||
399 | + | ||
400 | + sizeName = size.size_name; | ||
401 | + | ||
402 | + // 所有尺码列表,赋值用于前端展示默认尺码的时候 | ||
403 | + // 判断出没有库存则显示灰色 | ||
404 | + let build = { | ||
405 | + id: size.size_id, | ||
406 | + storage: size.storage_number, | ||
407 | + sizeInfo: size.size_info ? size.size_info : '' | ||
408 | + }; | ||
409 | + | ||
410 | + allSizeList[sizeName] = (allSizeList[sizeName] === null || | ||
411 | + typeof allSizeList[sizeName] === 'undefined') ? build : allSizeList[sizeName]; | ||
412 | + colorStorageNum += parseInt(size.storage_number, 10); | ||
413 | + colorStorageGroup[value.product_skc][sizeName] = parseInt(size.storage_number, 10); | ||
414 | + }); | ||
415 | + | ||
416 | + | ||
417 | + // 颜色分组 | ||
418 | + colorList.push({ | ||
419 | + id: value.color_id, | ||
420 | + skcId: value.product_skc, | ||
421 | + name: value.factory_goods_name || value.color_name, | ||
422 | + colorNum: colorStorageNum | ||
423 | + }); | ||
424 | + } | ||
425 | + | ||
426 | + // 缩略图 | ||
427 | + thumbImageList.push({ | ||
428 | + img: helpers.image(value.color_image, 300, 395) | ||
429 | + }); | ||
430 | + | ||
431 | + // 商品库存总数 | ||
432 | + totalStorageNum += _.toNumber(colorStorageNum); | ||
433 | + }); | ||
434 | + | ||
435 | + // 遍历所有尺码,构建颜色显示数据 | ||
436 | + let i = 1; | ||
437 | + | ||
438 | + sizeGroup[0] = { | ||
439 | + size: [] | ||
440 | + }; | ||
441 | + _.forEach(allSizeList, (value, key) => { | ||
442 | + | ||
443 | + // 默认尺码 | ||
444 | + sizeGroup[0].size.push({ | ||
445 | + name: key, | ||
446 | + sizeNum: _.toNumber(value.storage) > 0 ? true : false, | ||
447 | + id: value.id, | ||
448 | + sizeInfo: value.sizeInfo | ||
449 | + }); | ||
450 | + | ||
451 | + colorGroup[i] = { | ||
452 | + color: [] | ||
453 | + }; | ||
454 | + | ||
455 | + // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | ||
456 | + _.forEach(colorList, (colorArr) => { | ||
457 | + let tempColorArr = _.cloneDeep(colorArr); | ||
458 | + | ||
459 | + if (colorStorageGroup[tempColorArr.skcId] && | ||
460 | + colorStorageGroup[tempColorArr.skcId][key]) { | ||
461 | + tempColorArr.colorNum = colorStorageGroup[tempColorArr.skcId][key]; | ||
462 | + } else { | ||
463 | + tempColorArr.colorNum = 0; | ||
464 | + } | ||
465 | + colorGroup[i].color.push(Object.assign({}, tempColorArr)); | ||
466 | + }); | ||
467 | + colorGroup[i].id = value.id; | ||
468 | + | ||
469 | + ++i; | ||
470 | + }); | ||
471 | + | ||
472 | + colorGroup[0] = { | ||
473 | + color: [] | ||
474 | + }; | ||
475 | + | ||
476 | + // 遍历所有颜色, 构建尺码显示数据 | ||
477 | + i = 1; | ||
478 | + _.forEach(colorList, function(value) { | ||
479 | + | ||
480 | + // 各个尺码的颜色, 每行显示一个颜色的对应尺码 | ||
481 | + sizeGroup[i] = { | ||
482 | + size: sizeList[value.skcId], | ||
483 | + colorId: value.skcId | ||
484 | + }; | ||
485 | + | ||
486 | + // 默认颜色 | ||
487 | + colorGroup[0].color.push(value); | ||
488 | + ++i; | ||
489 | + }); | ||
490 | + _.orderBy(colorGroup); | ||
491 | + Object.assign(cartInfo, { | ||
492 | + productId: origin.product_id, | ||
493 | + thumbs: thumbImageList, | ||
494 | + name: origin.product_name || '', | ||
495 | + totalNum: totalStorageNum, | ||
496 | + colors: _.toArray(colorGroup), | ||
497 | + sizes: sizeGroup | ||
498 | + }); | ||
499 | + } | ||
500 | + return cartInfo; | ||
501 | +}; |
-
Please register or login to post a comment