Authored by 周少峰

add sort intro and ads

@@ -14,6 +14,9 @@ const searchHandler = require('./search-handler'); @@ -14,6 +14,9 @@ const searchHandler = require('./search-handler');
14 // 搜索分类信息需要的参数 14 // 搜索分类信息需要的参数
15 const positionId = 10; 15 const positionId = 10;
16 16
  17 +// 获取分类左侧广告id
  18 +const sortAdsId = 79;
  19 +
17 /** 20 /**
18 * 获取商品分类列表数据 21 * 获取商品分类列表数据
19 */ 22 */
@@ -28,14 +31,13 @@ exports.getListData = (params) => { @@ -28,14 +31,13 @@ exports.getListData = (params) => {
28 // 搜索分类介绍和广告 31 // 搜索分类介绍和广告
29 if (params.msort && params.misort) { 32 if (params.msort && params.misort) {
30 let IntroParams = { 33 let IntroParams = {
31 - position_id: positionId,  
32 max_sort_id: params.msort, 34 max_sort_id: params.msort,
33 middle_sort_id: params.misort, 35 middle_sort_id: params.misort,
34 gender: params.gender || '1,3' 36 gender: params.gender || '1,3'
35 }; 37 };
36 38
37 - apiMethod.push(searchApi.getSortIntro(IntroParams));  
38 - apiMethod.push(searchApi.getSortAds(IntroParams)); 39 + apiMethod.push(searchApi.getSortIntro(Object.assign(IntroParams, {position_id: positionId})));
  40 + apiMethod.push(searchApi.getSortAds(Object.assign(IntroParams, {position_id: sortAdsId})));
39 } 41 }
40 42
41 return api.all(apiMethod).then(result => { 43 return api.all(apiMethod).then(result => {
@@ -43,12 +45,14 @@ exports.getListData = (params) => { @@ -43,12 +45,14 @@ exports.getListData = (params) => {
43 headerData: Object.assign(result[0].headerData, { 45 headerData: Object.assign(result[0].headerData, {
44 header: true 46 header: true
45 }), 47 }),
46 - search: {} 48 + list: {
  49 + leftContent: {}
  50 + }
47 }; 51 };
48 52
49 // 获取左侧类目数据 53 // 获取左侧类目数据
50 if (result[1].code === 200) { 54 if (result[1].code === 200) {
51 - finalResult.search = { 55 + finalResult.list = {
52 leftContent: searchHandler.handleSortData(result[1].data.sort, params), 56 leftContent: searchHandler.handleSortData(result[1].data.sort, params),
53 pathNav: searchHandler.handlePathNavData(result[1].data.sort, params, 'sort') 57 pathNav: searchHandler.handlePathNavData(result[1].data.sort, params, 'sort')
54 }; 58 };
@@ -56,7 +60,7 @@ exports.getListData = (params) => { @@ -56,7 +60,7 @@ exports.getListData = (params) => {
56 60
57 // 获取商品数据和顶部筛选条件 61 // 获取商品数据和顶部筛选条件
58 if (result[2].code === 200) { 62 if (result[2].code === 200) {
59 - Object.assign(finalResult.search, { 63 + Object.assign(finalResult.list, {
60 filters: searchHandler.handleFilterData(result[2].data.filter, params), 64 filters: searchHandler.handleFilterData(result[2].data.filter, params),
61 opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), 65 opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
62 totalCount: result[2].data.total, 66 totalCount: result[2].data.total,
@@ -68,12 +72,12 @@ exports.getListData = (params) => { @@ -68,12 +72,12 @@ exports.getListData = (params) => {
68 72
69 // 分类介绍 73 // 分类介绍
70 if (result[3] && result[3].code === 200) { 74 if (result[3] && result[3].code === 200) {
71 - finalResult.sortIntro = searchHandler.handleSortIntro(result[3].data); 75 + finalResult.list.sortIntro = searchHandler.handleSortIntro(result[3].data);
72 } 76 }
73 77
74 // 分类广告 78 // 分类广告
75 if (result[4] && result[4].code === 200) { 79 if (result[4] && result[4].code === 200) {
76 - finalResult.sortIntro = searchHandler.handleSortAds(result[4].data); 80 + Object.assign(finalResult.list.leftContent, searchHandler.handleSortAds(result[4].data));
77 } 81 }
78 return finalResult; 82 return finalResult;
79 }); 83 });
@@ -9,12 +9,14 @@ const api = global.yoho.SearchAPI; @@ -9,12 +9,14 @@ const api = global.yoho.SearchAPI;
9 9
10 const yohoApi = global.yoho.API; 10 const yohoApi = global.yoho.API;
11 11
  12 +const serviceApi = global.yoho.ServiceAPI;
  13 +
12 const getSortByConditionAsync = (condition) => { 14 const getSortByConditionAsync = (condition) => {
13 return api.get('sortgroup.json', condition); 15 return api.get('sortgroup.json', condition);
14 }; 16 };
15 17
16 // 获取list页广告 18 // 获取list页广告
17 -const adsUrl = 'shops/api/v1/ads/getList'; 19 +const adsUrl = '/shops/api/v1/ads/getList';
18 20
19 /** 21 /**
20 * 获取商品列表 22 * 获取商品列表
@@ -63,7 +65,7 @@ const getSortIntro = (params) => { @@ -63,7 +65,7 @@ const getSortIntro = (params) => {
63 * @return 65 * @return
64 */ 66 */
65 const getSortAds = (params) => { 67 const getSortAds = (params) => {
66 - return yohoApi.get(adsUrl, params); 68 + return serviceApi.get(adsUrl, params);
67 }; 69 };
68 70
69 /** 71 /**
@@ -51,7 +51,6 @@ const handleCheckedData = (params, origin, param) => { @@ -51,7 +51,6 @@ const handleCheckedData = (params, origin, param) => {
51 if (!_.isEmpty(origin)) { 51 if (!_.isEmpty(origin)) {
52 _.forEach(origin, value => { 52 _.forEach(origin, value => {
53 if (value.checked) { 53 if (value.checked) {
54 - console.log(value);  
55 let tempPatam = {}; 54 let tempPatam = {};
56 55
57 tempPatam[param] = ''; 56 tempPatam[param] = '';
@@ -589,7 +588,6 @@ exports.handleFilterData = (origin, params) => { @@ -589,7 +588,6 @@ exports.handleFilterData = (origin, params) => {
589 588
590 dest.ageLevel.push(ageLevel); 589 dest.ageLevel.push(ageLevel);
591 }); 590 });
592 - console.log(dest.ageLevel);  
593 } 591 }
594 592
595 // 清除所有选中数据 593 // 清除所有选中数据
@@ -664,7 +662,6 @@ exports.handlePathNavData = (data, params, page) => { @@ -664,7 +662,6 @@ exports.handlePathNavData = (data, params, page) => {
664 // 分类 662 // 分类
665 _.forEach(data, (sort) => { 663 _.forEach(data, (sort) => {
666 if (sort.sort_id === params.msort) { 664 if (sort.sort_id === params.msort) {
667 - console.log(params.msort);  
668 pathNav.push({ 665 pathNav.push({
669 name: sort.sort_name, 666 name: sort.sort_name,
670 href: helpers.urlFormat('/product/outlets/list', {msort: sort.sort_id}), 667 href: helpers.urlFormat('/product/outlets/list', {msort: sort.sort_id}),
@@ -819,7 +816,6 @@ exports.handleSortIntro = (data, params) => { @@ -819,7 +816,6 @@ exports.handleSortIntro = (data, params) => {
819 }); 816 });
820 }); 817 });
821 818
822 -  
823 return sortIntro; 819 return sortIntro;
824 }; 820 };
825 821
@@ -827,12 +823,20 @@ exports.handleSortIntro = (data, params) => { @@ -827,12 +823,20 @@ exports.handleSortIntro = (data, params) => {
827 * 处理分类页左侧广告 823 * 处理分类页左侧广告
828 * @type {[type]} 824 * @type {[type]}
829 */ 825 */
830 -exports.handleSortAds = (data, params) => { 826 +exports.handleSortAds = (data) => {
831 let sortAds = { 827 let sortAds = {
832 - data: data,  
833 - params: params 828 + picLink: {
  829 + picTitle: '',
  830 + list: []
  831 + }
834 }; 832 };
835 833
  834 + _.forEach(data, function(value) {
  835 + sortAds.picLink.list.push({
  836 + href: value.ads_url,
  837 + src: value.ads_image
  838 + });
  839 + });
836 840
837 return sortAds; 841 return sortAds;
838 }; 842 };
1 -{{> list/list}}  
  1 +<div class="product-page yoho-page product-list-page">
  2 + {{# list}}
  3 +
  4 + {{> list/list}}
  5 +
  6 + {{/list}}
  7 +</div>
1 -{{> list/list}}  
  1 +<div class="product-page yoho-page">
  2 + {{# search}}
  3 +
  4 + {{> list/list}}
  5 +
  6 + {{/search}}
  7 +</div>
1 -<div class="product-page yoho-page">  
2 - {{# search}}  
3 - <div class="center-content clearfix">  
4 - {{# pathNav}}  
5 - {{> common/path-nav}}  
6 - {{/ pathNav}}  
7 -  
8 -  
9 - <div class="list-left pull-left">  
10 - {{> product/left-content}}  
11 - </div>  
12 -  
13 - <div class="list-right pull-right">  
14 - {{# sortIntro}}  
15 - <div class="sort-intro clearfix">  
16 - <div class="texts pull-left">  
17 - <p class="name">{{name}}</p>  
18 - <p class="en-name">{{enName}}</p>  
19 - <p class="desc">{{{description}}}</p>  
20 - <div class="key-entry">  
21 - {{#each keyEntry}}  
22 - <a href="{{url}}">{{name}}</a>  
23 - {{/each}}  
24 - </div>  
25 - </div>  
26 - <img class="pull-right img" src="{{img}}">  
27 - </div>  
28 - {{/ sortIntro}}  
29 - {{> list/shop-entry}}  
30 - {{> product/standard-content}}  
31 - </div> 1 +
  2 +{{# brandBanner}}
  3 + <div class="brand-banner">
  4 + <div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div>
  5 + <div class="opt-wrap">
  6 + <p class="opt center-content">
  7 + <a href="{{brandHome}}">
  8 + <i class="iconfont">&#xe617;</i>
  9 + 品牌首页
  10 + </a>
  11 + <a href="{{brandIntro}}">
  12 + <i class="iconfont">&#xe631;</i>
  13 + 品牌介绍
  14 + </a>
  15 + <span id="brand-favor" class="brand-favor" data-id="{{dataId}}">
  16 + <i class="iconfont{{#if coled}} coled{{/if}}">&#xe616;</i>
  17 + </span>
  18 + </p>
  19 + </div>
  20 + </div>
  21 +{{/ brandBanner}}
  22 +
  23 +{{# shopBanner}}
  24 + <div class="brand-banner base-shop-banner">
  25 + <div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div>
  26 + <div class="opt-wrap">
  27 + <p class="opt center-content">
  28 + {{#if showShopName}}
  29 + <span class="shop-name">{{shopName}}</span>
  30 + {{/if}}
  31 + <a href="{{shopHome}}">
  32 + <i class="iconfont">&#xe617;</i>
  33 + 店铺首页
  34 + </a>
  35 + <a href="{{shopIntro}}">
  36 + <i class="iconfont">&#xe631;</i>
  37 + 店铺介绍
  38 + </a>
  39 + <span id="shop-favor" class="brand-favor shop-favor" data-id="{{shopId}}">
  40 + <i class="iconfont{{#if coled}} coled{{/if}}">&#xe616;</i>
  41 + </span>
  42 + </p>
32 </div> 43 </div>
33 - {{/search}} 44 + </div>
  45 +{{/ shopBanner}}
  46 +
  47 +<div class="center-content clearfix">
  48 +
  49 + {{# pathNav}}
  50 + {{> common/path-nav}}
  51 + {{/ pathNav}}
  52 +
  53 +
  54 + <div class="list-left pull-left">
  55 + {{> product/left-content}}
  56 + </div>
  57 +
  58 + <div class="list-right pull-right">
  59 + {{# sortIntro}}
  60 + <div class="sort-intro clearfix">
  61 + <div class="texts pull-left">
  62 + <p class="name">{{name}}</p>
  63 + <p class="en-name">{{enName}}</p>
  64 + <p class="desc">{{{description}}}</p>
  65 + <div class="key-entry">
  66 + {{#each keyEntry}}
  67 + <a href="{{url}}">{{name}}</a>
  68 + {{/each}}
  69 + </div>
  70 + </div>
  71 + <img class="pull-right img" src="{{img}}">
  72 + </div>
  73 + {{/ sortIntro}}
  74 +
  75 + {{> list/shop-entry}}
  76 +
  77 + {{> product/standard-content}}
  78 +
  79 + </div>
34 </div> 80 </div>
@@ -14,13 +14,15 @@ module.exports = { @@ -14,13 +14,15 @@ module.exports = {
14 port: 6002, 14 port: 6002,
15 siteUrl: 'http://www.yohobuy.com', 15 siteUrl: 'http://www.yohobuy.com',
16 domains: { 16 domains: {
17 - api: 'http://api.yoho.yohoops.org', 17 + // api: 'http://api.yoho.yohoops.org',
  18 + api: 'http://devapi.yoho.cn:58078/',
18 19
19 - // api: 'http://devapi.yoho.cn:58078/',  
20 // api: 'http://testapi.yoho.cn:28078/', 20 // api: 'http://testapi.yoho.cn:28078/',
21 21
22 service: 'http://devservice.yoho.cn:58077/', 22 service: 'http://devservice.yoho.cn:58077/',
23 23
  24 + // service: 'http://service.yoho.yohoops.org',
  25 +
24 // service: 'http://testservice.yoho.cn:28077/', 26 // service: 'http://testservice.yoho.cn:28077/',
25 search: 'http://192.168.102.216:8080/yohosearch/' 27 search: 'http://192.168.102.216:8080/yohosearch/'
26 }, 28 },