Merge branch 'master' of git.yoho.cn:fe/yohobuy-node into feature/couponcenter
Showing
5 changed files
with
245 additions
and
107 deletions
@@ -17,6 +17,16 @@ const shop = (shopId, req, res, next, brandInfo) => { | @@ -17,6 +17,16 @@ const shop = (shopId, req, res, next, brandInfo) => { | ||
17 | 17 | ||
18 | list.getShopInfo(shopId, req.user.id).then(shopInfo => { | 18 | list.getShopInfo(shopId, req.user.id).then(shopInfo => { |
19 | if (+shopInfo.shopTemplateType === 2) { // 经典模板 | 19 | if (+shopInfo.shopTemplateType === 2) { // 经典模板 |
20 | + let pjax = req.query._pjax; | ||
21 | + | ||
22 | + if (pjax) { | ||
23 | + list.getShopGoodsData(shopId, req.yoho.channel, req.query, shopInfo).then(result => { | ||
24 | + Object.assign(result, {layout: false}); | ||
25 | + res.render('list/goods-list', result); | ||
26 | + }).catch(next); | ||
27 | + return; | ||
28 | + } | ||
29 | + | ||
20 | list.getShopData(shopId, req.yoho.channel, req.query, shopInfo).then(result => { | 30 | list.getShopData(shopId, req.yoho.channel, req.query, shopInfo).then(result => { |
21 | Object.assign(result, { | 31 | Object.assign(result, { |
22 | page: 'shop', | 32 | page: 'shop', |
@@ -27,9 +37,9 @@ const shop = (shopId, req, res, next, brandInfo) => { | @@ -27,9 +37,9 @@ const shop = (shopId, req, res, next, brandInfo) => { | ||
27 | } else { // 基础模板 | 37 | } else { // 基础模板 |
28 | list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo), | 38 | list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo), |
29 | req.yoho.channel, shopId).then(result => { | 39 | req.yoho.channel, shopId).then(result => { |
30 | - Object.assign(result, {page: 'list'}); | ||
31 | - res.render('list/brand', result); | ||
32 | - }).catch(next); | 40 | + Object.assign(result, {page: 'list'}); |
41 | + res.render('list/brand', result); | ||
42 | + }).catch(next); | ||
33 | } | 43 | } |
34 | }).catch(next); | 44 | }).catch(next); |
35 | }; | 45 | }; |
@@ -672,6 +672,54 @@ const getShopData = (shopId, channel, params, shopInfo) => { | @@ -672,6 +672,54 @@ const getShopData = (shopId, channel, params, shopInfo) => { | ||
672 | }); | 672 | }); |
673 | }; | 673 | }; |
674 | 674 | ||
675 | +/** | ||
676 | + * 获取店铺商品数据 | ||
677 | + */ | ||
678 | +const getShopGoodsData = (shopId, channel, params) => { | ||
679 | + let gender = _getGender(channel); | ||
680 | + let resData = {}; | ||
681 | + | ||
682 | + _.unset(params, '_pjax'); | ||
683 | + return Promise.all([ | ||
684 | + searchApi.getProductList(Object.assign({ | ||
685 | + shop_id: shopId | ||
686 | + }, params)), // 搜索店铺商品 | ||
687 | + searchApi.getShopBrands(shopId) // 店铺品牌数据 | ||
688 | + ]).then(result => { | ||
689 | + // 获取商品数据和顶部筛选条件 | ||
690 | + if (result[0].code === 200) { | ||
691 | + Object.assign(resData, { | ||
692 | + sort: searchHandler.handleOptsData(params, _.get(result[0], 'data.total', 0)), | ||
693 | + list: productProcess.processProductList(_.get(result[0], 'data.product_list', []), { | ||
694 | + newCoverSort: true, | ||
695 | + showDiscount: false, | ||
696 | + gender: gender | ||
697 | + }) | ||
698 | + }); | ||
699 | + _.set(resData, 'sort.newPage', true); // 启用新的分页导航 | ||
700 | + } | ||
701 | + | ||
702 | + let shopBrandIds = []; // 店铺的所有品牌id | ||
703 | + | ||
704 | + if (result[1].code === 200 && result[1].data) { | ||
705 | + _.forEach(result[1].data, value => { | ||
706 | + shopBrandIds.push(value.brand_id); | ||
707 | + }); | ||
708 | + } | ||
709 | + | ||
710 | + // 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类) | ||
711 | + return searchApi.getSortList({brand: shopBrandIds}).then(subRes => { | ||
712 | + if (subRes.code === 200) { | ||
713 | + let groupSort = _.get(subRes, 'data.sort', []); | ||
714 | + | ||
715 | + Object.assign(resData, searchHandler.setShopSort(groupSort, params)); | ||
716 | + } | ||
717 | + | ||
718 | + return resData; | ||
719 | + }); | ||
720 | + }); | ||
721 | +}; | ||
722 | + | ||
675 | const getShopListData = (channel, params, uid) => { | 723 | const getShopListData = (channel, params, uid) => { |
676 | let gender = _getGender(channel), | 724 | let gender = _getGender(channel), |
677 | shopId = params.shopId, | 725 | shopId = params.shopId, |
@@ -741,7 +789,8 @@ const getShopListData = (channel, params, uid) => { | @@ -741,7 +789,8 @@ const getShopListData = (channel, params, uid) => { | ||
741 | goods: productProcess.processProductList(goodsList, { | 789 | goods: productProcess.processProductList(goodsList, { |
742 | newCoverSort: true, | 790 | newCoverSort: true, |
743 | showDiscount: false, | 791 | showDiscount: false, |
744 | - gender: _getGender(channel) | 792 | + gender: _getGender(channel), |
793 | + query: params.query | ||
745 | }), | 794 | }), |
746 | footPager: {tip: tip} | 795 | footPager: {tip: tip} |
747 | }); | 796 | }); |
@@ -812,7 +861,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | @@ -812,7 +861,7 @@ const getBaseShopData = (params, extra, channel, shopId) => { | ||
812 | 861 | ||
813 | if (result[1].code === 200) { | 862 | if (result[1].code === 200) { |
814 | let data = result[1].data || {}, | 863 | let data = result[1].data || {}, |
815 | - decorator = shopHandler.getShopDecorator(data, {}, shopId); | 864 | + decorator = shopHandler.getShopDecorator(data, {}, shopId, true); |
816 | 865 | ||
817 | Object.assign(decorator.shopTopBannerBase, { | 866 | Object.assign(decorator.shopTopBannerBase, { |
818 | shopId: shopId, | 867 | shopId: shopId, |
@@ -822,6 +871,10 @@ const getBaseShopData = (params, extra, channel, shopId) => { | @@ -822,6 +871,10 @@ const getBaseShopData = (params, extra, channel, shopId) => { | ||
822 | }); | 871 | }); |
823 | _.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase); | 872 | _.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase); |
824 | _.unset(resData, 'brand.brandBanner'); | 873 | _.unset(resData, 'brand.brandBanner'); |
874 | + | ||
875 | + if (decorator.signboard) { | ||
876 | + _.set(resData, 'brand.signboard', decorator.signboard); | ||
877 | + } | ||
825 | } | 878 | } |
826 | 879 | ||
827 | if (result[2].code === 200) { | 880 | if (result[2].code === 200) { |
@@ -848,6 +901,7 @@ module.exports = { | @@ -848,6 +901,7 @@ module.exports = { | ||
848 | getAdnav, | 901 | getAdnav, |
849 | getShopInfo, | 902 | getShopInfo, |
850 | getShopData, | 903 | getShopData, |
904 | + getShopGoodsData, | ||
851 | getShopListData, | 905 | getShopListData, |
852 | getBaseShopData | 906 | getBaseShopData |
853 | }; | 907 | }; |
@@ -99,7 +99,7 @@ const handleBrandCheckedData = (params, origin) => { | @@ -99,7 +99,7 @@ const handleBrandCheckedData = (params, origin) => { | ||
99 | if (!_.isEmpty(origin)) { | 99 | if (!_.isEmpty(origin)) { |
100 | _.forEach(origin, (value) => { | 100 | _.forEach(origin, (value) => { |
101 | if (typeof _.find(intBrands, o => { | 101 | if (typeof _.find(intBrands, o => { |
102 | - return _.isEqual(o, value.id); | 102 | + return _.isEqual(o, +value.id); |
103 | }) !== 'undefined') { | 103 | }) !== 'undefined') { |
104 | let checked = { | 104 | let checked = { |
105 | name: value.name | 105 | name: value.name |
@@ -204,9 +204,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -204,9 +204,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
204 | index: '0-9', | 204 | index: '0-9', |
205 | name: '0~9' | 205 | name: '0~9' |
206 | }], | 206 | }], |
207 | - selectedBrands: [], | ||
208 | - showMore: true, | ||
209 | - showMulti: true | 207 | + selectedBrands: [] |
210 | }; | 208 | }; |
211 | 209 | ||
212 | 210 | ||
@@ -233,7 +231,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -233,7 +231,7 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
233 | _.forEach(source, function(value) { | 231 | _.forEach(source, function(value) { |
234 | let brand = { | 232 | let brand = { |
235 | checked: (typeof _.find(intBrands, o => { | 233 | checked: (typeof _.find(intBrands, o => { |
236 | - return _.isEqual(o, value.id); | 234 | + return _.isEqual(o, +value.id); |
237 | }) !== 'undefined'), | 235 | }) !== 'undefined'), |
238 | href: handleFilterUrl(params, {brand: value.id}), | 236 | href: handleFilterUrl(params, {brand: value.id}), |
239 | name: value.brand_name, | 237 | name: value.brand_name, |
@@ -257,6 +255,13 @@ const formatterFilterBrands = (source, paramBrand, params) => { | @@ -257,6 +255,13 @@ const formatterFilterBrands = (source, paramBrand, params) => { | ||
257 | count++; | 255 | count++; |
258 | }); | 256 | }); |
259 | 257 | ||
258 | + if (dbrand.default.length > 9) { | ||
259 | + Object.assign(dbrand, { | ||
260 | + showMore: true, | ||
261 | + showMulti: true | ||
262 | + }); | ||
263 | + } | ||
264 | + | ||
260 | if (paramBrand) { | 265 | if (paramBrand) { |
261 | _.forEach(paramBrand, value => { | 266 | _.forEach(paramBrand, value => { |
262 | let brand = { | 267 | let brand = { |
@@ -538,7 +543,10 @@ exports.setShopSort = (data, params) => { | @@ -538,7 +543,10 @@ exports.setShopSort = (data, params) => { | ||
538 | }); | 543 | }); |
539 | 544 | ||
540 | if (list.length) { | 545 | if (list.length) { |
541 | - _.set(resData, 'goodsMenu.menuList', list); | 546 | + resData.goodsMenu = { |
547 | + menuList: list, | ||
548 | + url: `/product/shoplist?navBar=1&shopId=${params.shopId}` | ||
549 | + }; | ||
542 | } | 550 | } |
543 | } | 551 | } |
544 | 552 | ||
@@ -554,19 +562,6 @@ exports.setShopSort = (data, params) => { | @@ -554,19 +562,6 @@ exports.setShopSort = (data, params) => { | ||
554 | exports.handleFilterData = (origin, params, total) => { | 562 | exports.handleFilterData = (origin, params, total) => { |
555 | let dest = { | 563 | let dest = { |
556 | ageLevel: [], | 564 | ageLevel: [], |
557 | - brand: { | ||
558 | - default: [], | ||
559 | - brandsShow: [], | ||
560 | - brandIndex: [{ | ||
561 | - index: 'all', | ||
562 | - name: '全部' | ||
563 | - }, { | ||
564 | - index: '0-9', | ||
565 | - name: '0~9' | ||
566 | - }], | ||
567 | - showMore: true, | ||
568 | - showMulti: true | ||
569 | - }, | ||
570 | price: [], | 565 | price: [], |
571 | gender: [], | 566 | gender: [], |
572 | color: [], | 567 | color: [], |
@@ -873,11 +868,12 @@ exports.handleSeniorFilterData = (data, params) => { | @@ -873,11 +868,12 @@ exports.handleSeniorFilterData = (data, params) => { | ||
873 | }; | 868 | }; |
874 | 869 | ||
875 | exports.handleFilterDataAll = (data, qs) => { | 870 | exports.handleFilterDataAll = (data, qs) => { |
871 | + let destFilter = {}; | ||
876 | let params = _.cloneDeep(qs); | 872 | let params = _.cloneDeep(qs); |
877 | 873 | ||
878 | _.unset(params, 'page'); // 去除筛选项page | 874 | _.unset(params, 'page'); // 去除筛选项page |
879 | 875 | ||
880 | - let baseFilter = this.handleFilterData(data.filter, params, data.total); | 876 | + let baseFilter = this.handleFilterData(_.get(data, 'filter', {}), params, data.total); |
881 | let seniorFilter = this.handleSeniorFilterData({ | 877 | let seniorFilter = this.handleSeniorFilterData({ |
882 | style: _.get(data, 'filter.style', []), | 878 | style: _.get(data, 'filter.style', []), |
883 | standard: _.get(data, 'standard', []) | 879 | standard: _.get(data, 'standard', []) |
@@ -886,12 +882,9 @@ exports.handleFilterDataAll = (data, qs) => { | @@ -886,12 +882,9 @@ exports.handleFilterDataAll = (data, qs) => { | ||
886 | let conditions = _.union(_.get(baseFilter, 'checkedConditions.conditions'), | 882 | let conditions = _.union(_.get(baseFilter, 'checkedConditions.conditions'), |
887 | _.get(seniorFilter, 'checkedConditions.conditions')); | 883 | _.get(seniorFilter, 'checkedConditions.conditions')); |
888 | 884 | ||
889 | - let destFilter = Object.assign({}, seniorFilter, baseFilter); | 885 | + Object.assign(destFilter, seniorFilter, baseFilter); |
890 | 886 | ||
891 | - if (!destFilter.checkedConditions) { | ||
892 | - destFilter.checkedConditions = {}; | ||
893 | - } | ||
894 | - destFilter.checkedConditions.conditions = conditions; | 887 | + _.set(destFilter, 'checkedConditions.conditions', conditions); |
895 | 888 | ||
896 | return destFilter; | 889 | return destFilter; |
897 | }; | 890 | }; |
@@ -1397,7 +1390,6 @@ exports.getBrandSeo = (channel, brandInfo) => { | @@ -1397,7 +1390,6 @@ exports.getBrandSeo = (channel, brandInfo) => { | ||
1397 | bb = b + ' ' + bcn, | 1390 | bb = b + ' ' + bcn, |
1398 | bc = b + c, | 1391 | bc = b + c, |
1399 | bbc = b + bcn + c, | 1392 | bbc = b + bcn + c, |
1400 | - title = bb || b || '', | ||
1401 | keywords = [b ? b + ',' : '', | 1393 | keywords = [b ? b + ',' : '', |
1402 | ((b && bcn) ? (bb + ',') : ''), | 1394 | ((b && bcn) ? (bb + ',') : ''), |
1403 | bc || '', | 1395 | bc || '', |
@@ -1406,7 +1398,7 @@ exports.getBrandSeo = (channel, brandInfo) => { | @@ -1406,7 +1398,7 @@ exports.getBrandSeo = (channel, brandInfo) => { | ||
1406 | bbc || '', | 1398 | bbc || '', |
1407 | '品牌官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'].join(''); | 1399 | '品牌官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'].join(''); |
1408 | 1400 | ||
1409 | - title += (title ? (title + '|') : '') + c + '品牌|YOHO!BUY 有货 100%正品保证'; | 1401 | + let title = (b ? (b + '|') : '') + (bb ? (bb + '|') : '') + c + '品牌|YOHO!BUY 有货 100%正品保证'; |
1410 | 1402 | ||
1411 | return { | 1403 | return { |
1412 | title: title, | 1404 | title: title, |
@@ -5,6 +5,8 @@ | @@ -5,6 +5,8 @@ | ||
5 | 5 | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | const _ = require('lodash'); | 7 | const _ = require('lodash'); |
8 | +const Fn = require('lodash/fp'); | ||
9 | +const qs = require('querystring'); | ||
8 | 10 | ||
9 | const helpers = global.yoho.helpers; | 11 | const helpers = global.yoho.helpers; |
10 | 12 | ||
@@ -68,32 +70,34 @@ const hotProducts = (data) => { | @@ -68,32 +70,34 @@ const hotProducts = (data) => { | ||
68 | */ | 70 | */ |
69 | const goodsTabBar = (data, shopId) => { | 71 | const goodsTabBar = (data, shopId) => { |
70 | let dest = { | 72 | let dest = { |
71 | - hot: [], | ||
72 | - new: [] | ||
73 | - }, | ||
74 | - more = {name: 'MORE', href: shopListUrl + '?shopId=' + shopId}; | ||
75 | - | 73 | + hot: [], |
74 | + new: [] | ||
75 | + }; | ||
76 | 76 | ||
77 | - _.forEach(data.hot, (value) => { | ||
78 | - if (value.url) { | 77 | + _.forEach(_.sortBy(data.hot, o => { |
78 | + return -o.position; | ||
79 | + }), (value) => { | ||
80 | + if (value.url && value.position) { | ||
79 | dest.hot.push({ | 81 | dest.hot.push({ |
80 | name: value.name, | 82 | name: value.name, |
81 | - href: value.url | 83 | + url: value.url |
82 | }); | 84 | }); |
83 | } | 85 | } |
84 | 86 | ||
85 | }); | 87 | }); |
86 | 88 | ||
87 | - _.forEach(data.new, (value) => { | ||
88 | - if (value.url) { | 89 | + _.forEach(_.sortBy(data.new, o => { |
90 | + return -o.position; | ||
91 | + }), (value) => { | ||
92 | + if (value.url && value.position) { | ||
89 | dest.new.push({ | 93 | dest.new.push({ |
90 | name: value.name, | 94 | name: value.name, |
91 | - href: value.url | 95 | + url: value.url |
92 | }); | 96 | }); |
93 | } | 97 | } |
94 | }); | 98 | }); |
95 | - dest.hot.push(more); | ||
96 | - dest.new.push(more); | 99 | + dest.hot.push({name: 'MORE', url: `${shopListUrl}?navBar=2&order=s_n_desc&shopId=${shopId}`}); |
100 | + dest.new.push({name: 'MORE', url: `${shopListUrl}?navBar=3&order=s_t_desc&shopId=${shopId}`}); | ||
97 | return dest; | 101 | return dest; |
98 | }; | 102 | }; |
99 | 103 | ||
@@ -144,17 +148,24 @@ const navigationBar = (data, shopId) => { | @@ -144,17 +148,24 @@ const navigationBar = (data, shopId) => { | ||
144 | }, | 148 | }, |
145 | { | 149 | { |
146 | name: '人气单品', | 150 | name: '人气单品', |
147 | - url: `${shopListUrl}/?navBar=2&shopId=${shopId}` | 151 | + url: `${shopListUrl}/?navBar=2&order=s_n_desc&shopId=${shopId}` |
148 | }, | 152 | }, |
149 | { | 153 | { |
150 | name: '新品上架', | 154 | name: '新品上架', |
151 | - url: `${shopListUrl}/?navBar=3&shopId=${shopId}` | 155 | + url: `${shopListUrl}/?navBar=3&order=s_t_desc&shopId=${shopId}` |
152 | } | 156 | } |
153 | ]; | 157 | ]; |
154 | 158 | ||
155 | - return {navigationBar: _.union(shopNav, _.filter(data, (value) => { | ||
156 | - return value.url; | ||
157 | - }))}; | 159 | + _.forEach(data, (value) => { |
160 | + if (value.url) { | ||
161 | + shopNav.push({ | ||
162 | + name: value.name, | ||
163 | + url: `${value.url}&navBar=${shopNav.length}` | ||
164 | + }); | ||
165 | + } | ||
166 | + }); | ||
167 | + | ||
168 | + return {navigationBar: shopNav}; | ||
158 | }; | 169 | }; |
159 | 170 | ||
160 | /** | 171 | /** |
@@ -166,9 +177,10 @@ const largeSlideImg = (data) => { | @@ -166,9 +177,10 @@ const largeSlideImg = (data) => { | ||
166 | let dest = []; | 177 | let dest = []; |
167 | 178 | ||
168 | _.forEach(data, (value) => { | 179 | _.forEach(data, (value) => { |
180 | + value = _.get(value, 'data[0]', {}); | ||
169 | dest.push({ | 181 | dest.push({ |
170 | - img: value.data[0].src, | ||
171 | - url: helpers.urlFormat(value.data[0].url) | 182 | + img: value.src, |
183 | + url: value.url | ||
172 | }); | 184 | }); |
173 | }); | 185 | }); |
174 | 186 | ||
@@ -184,9 +196,10 @@ const oneRowTwoColImages = (data) => { | @@ -184,9 +196,10 @@ const oneRowTwoColImages = (data) => { | ||
184 | let dest = []; | 196 | let dest = []; |
185 | 197 | ||
186 | _.forEach(data, (value) => { | 198 | _.forEach(data, (value) => { |
199 | + value = _.get(value, 'data[0]', {}); | ||
187 | dest.push({ | 200 | dest.push({ |
188 | - img: value.data[0].src, | ||
189 | - url: helpers.urlFormat(value.data[0].url) | 201 | + img: value.src, |
202 | + url: value.url | ||
190 | }); | 203 | }); |
191 | }); | 204 | }); |
192 | return {oneRowTwoColImages: dest}; | 205 | return {oneRowTwoColImages: dest}; |
@@ -197,7 +210,7 @@ const oneRowTwoColImages = (data) => { | @@ -197,7 +210,7 @@ const oneRowTwoColImages = (data) => { | ||
197 | * @param type $data | 210 | * @param type $data |
198 | * @return type [] | 211 | * @return type [] |
199 | */ | 212 | */ |
200 | -const recommend = (data, shopId) => { | 213 | +const recommend = (data) => { |
201 | let dest = []; | 214 | let dest = []; |
202 | 215 | ||
203 | _.forEach(data, (value) => { | 216 | _.forEach(data, (value) => { |
@@ -206,7 +219,7 @@ const recommend = (data, shopId) => { | @@ -206,7 +219,7 @@ const recommend = (data, shopId) => { | ||
206 | name: value.name, | 219 | name: value.name, |
207 | img: value.src, | 220 | img: value.src, |
208 | title: value.title, | 221 | title: value.title, |
209 | - url: `${shopListUrl}?shopId=${shopId}&filter_poolId=${value.categoryId}` | 222 | + url: value.url |
210 | }); | 223 | }); |
211 | }); | 224 | }); |
212 | 225 | ||
@@ -277,62 +290,130 @@ const hotRecommend = (data) => { | @@ -277,62 +290,130 @@ const hotRecommend = (data) => { | ||
277 | }; | 290 | }; |
278 | 291 | ||
279 | /** | 292 | /** |
280 | - * 店铺装修楼层数据 | ||
281 | - * @param data 装修数据 | ||
282 | - * @returns {{}} | 293 | + * 水牌 |
283 | */ | 294 | */ |
284 | -exports.getShopDecorator = (data, params, shopId) => { | ||
285 | - let dest = { | ||
286 | - newArrivel: {}, | ||
287 | - hotSingle: {} | 295 | +const signboard = (data) => { |
296 | + let list = []; | ||
297 | + | ||
298 | + _.forEach(data, value => { | ||
299 | + if (value.data) { | ||
300 | + _.forEach(value.data, val => { | ||
301 | + list.push({ | ||
302 | + img: helpers.image(val.src, 160, 240), | ||
303 | + url: val.url | ||
304 | + }); | ||
305 | + }); | ||
306 | + } | ||
307 | + }); | ||
308 | + return { | ||
309 | + title: _.get(list, '[0].title', ''), | ||
310 | + list: list | ||
288 | }; | 311 | }; |
312 | +}; | ||
289 | 313 | ||
290 | - _.forEach(data.list, (value) => { | ||
291 | - let info = JSON.parse(value.resource_data); | ||
292 | - let tabBar; | ||
293 | - | ||
294 | - switch (value.resource_name) { | ||
295 | - case 'signboard': | ||
296 | - break; | ||
297 | - case 'newProducts': | ||
298 | - Object.assign(dest.newArrivel, newProducts(info)); | ||
299 | - break; | ||
300 | - case 'hotProducts': | ||
301 | - Object.assign(dest.hotSingle, hotProducts(info)); | ||
302 | - break; | ||
303 | - case 'goodsTabBar': | ||
304 | - tabBar = goodsTabBar(info); | ||
305 | - Object.assign(dest.newArrivel, {navs: tabBar.new}); | ||
306 | - Object.assign(dest.hotSingle, {navs: tabBar.hot}); | ||
307 | - break; | ||
308 | - case 'shopTopBanner': | ||
309 | - Object.assign(dest, shopTopBanner(info)); | ||
310 | - break; | ||
311 | - case 'shopTopBanner_base': | ||
312 | - Object.assign(dest, shopTopBannerBase(info)); | ||
313 | - break; | ||
314 | - case 'navigationBar': | ||
315 | - Object.assign(dest, navigationBar(info, shopId)); | ||
316 | - break; | ||
317 | - case 'largeSlideImg': | ||
318 | - Object.assign(dest, largeSlideImg(info)); | ||
319 | - break; | ||
320 | - case 'oneRowTwoColImages': | ||
321 | - Object.assign(dest, oneRowTwoColImages(info, shopId)); | ||
322 | - break; | ||
323 | - case 'recommend': | ||
324 | - Object.assign(dest, recommend(info, shopId)); | ||
325 | - break; | ||
326 | - case 'brandBrowse': | ||
327 | - Object.assign(dest, brandBrowse(info, params)); | ||
328 | - break; | ||
329 | - case 'hotRecommend': | ||
330 | - Object.assign(dest, hotRecommend(info)); | ||
331 | - break; | ||
332 | - default: | ||
333 | - break; | 314 | + |
315 | +// 销售类目 | ||
316 | +const _handleSaleCategory = (shopId, resourceObj) => { | ||
317 | + const thisShop = (categoryId) => shopListUrl + '?' + qs.stringify({ | ||
318 | + productPool: categoryId, | ||
319 | + shopId: shopId, | ||
320 | + navBar: -1 | ||
321 | + }); | ||
322 | + | ||
323 | + let hasSaleCategory = Fn.pipe(Fn.prop('linkType'), Fn.eq('1')); | ||
324 | + | ||
325 | + if (hasSaleCategory(resourceObj)) { | ||
326 | + return Object.assign(resourceObj, {url: thisShop(resourceObj.categoryId)}); | ||
327 | + } | ||
328 | + | ||
329 | + _(resourceObj).forEach((value) => { | ||
330 | + if (_.has(value, 'data')) { | ||
331 | + _.forEach(value.data, (it) => { | ||
332 | + if (hasSaleCategory(it)) { | ||
333 | + Object.assign(it, {url: thisShop(it.categoryId)}); | ||
334 | + } | ||
335 | + }); | ||
336 | + } | ||
337 | + | ||
338 | + if (hasSaleCategory(value)) { | ||
339 | + Object.assign(value, {url: thisShop(value.categoryId)}); | ||
334 | } | 340 | } |
335 | }); | 341 | }); |
336 | 342 | ||
343 | + return resourceObj; | ||
344 | +}; | ||
345 | + | ||
346 | +/** | ||
347 | + * 店铺装修楼层数据 | ||
348 | + * @param data 装修数据 | ||
349 | + * @returns {{}} | ||
350 | + */ | ||
351 | +exports.getShopDecorator = (data, params, shopId, base) => { | ||
352 | + let dest = {}; | ||
353 | + | ||
354 | + if (base) { | ||
355 | + _.forEach(data.list, (value) => { | ||
356 | + let info = Fn.pipe(JSON.parse, _.partial(_handleSaleCategory, shopId))(value.resource_data); | ||
357 | + | ||
358 | + switch (value.resource_name) { | ||
359 | + case 'signboard': | ||
360 | + dest.signboard = signboard(info); | ||
361 | + break; | ||
362 | + case 'shopTopBanner_base': | ||
363 | + Object.assign(dest, shopTopBannerBase(info)); | ||
364 | + break; | ||
365 | + default: | ||
366 | + break; | ||
367 | + } | ||
368 | + }); | ||
369 | + } else { | ||
370 | + Object.assign(dest, { | ||
371 | + newArrivel: {}, | ||
372 | + hotSingle: {} | ||
373 | + }); | ||
374 | + | ||
375 | + _.forEach(data.list, (value) => { | ||
376 | + let info = Fn.pipe(JSON.parse, _.partial(_handleSaleCategory, shopId))(value.resource_data); | ||
377 | + let tabBar; | ||
378 | + | ||
379 | + switch (value.resource_name) { | ||
380 | + case 'newProducts': | ||
381 | + Object.assign(dest.newArrivel, newProducts(info)); | ||
382 | + break; | ||
383 | + case 'hotProducts': | ||
384 | + Object.assign(dest.hotSingle, hotProducts(info)); | ||
385 | + break; | ||
386 | + case 'goodsTabBar': | ||
387 | + tabBar = goodsTabBar(info, shopId); | ||
388 | + Object.assign(dest.newArrivel, {navs: tabBar.new}); | ||
389 | + Object.assign(dest.hotSingle, {navs: tabBar.hot}); | ||
390 | + break; | ||
391 | + case 'shopTopBanner': | ||
392 | + Object.assign(dest, shopTopBanner(info)); | ||
393 | + break; | ||
394 | + case 'navigationBar': | ||
395 | + Object.assign(dest, navigationBar(info, shopId)); | ||
396 | + break; | ||
397 | + case 'largeSlideImg': | ||
398 | + Object.assign(dest, largeSlideImg(info, shopId)); | ||
399 | + break; | ||
400 | + case 'oneRowTwoColImages': | ||
401 | + Object.assign(dest, oneRowTwoColImages(info, shopId)); | ||
402 | + break; | ||
403 | + case 'recommend': | ||
404 | + Object.assign(dest, recommend(info, shopId)); | ||
405 | + break; | ||
406 | + case 'brandBrowse': | ||
407 | + Object.assign(dest, brandBrowse(info, params)); | ||
408 | + break; | ||
409 | + case 'hotRecommend': | ||
410 | + Object.assign(dest, hotRecommend(info)); | ||
411 | + break; | ||
412 | + default: | ||
413 | + break; | ||
414 | + } | ||
415 | + }); | ||
416 | + } | ||
417 | + | ||
337 | return dest; | 418 | return dest; |
338 | }; | 419 | }; |
1 | +{{> list/shop-list}} |
-
Please register or login to post a comment