Authored by 周少峰

add sort intro and ads

... ... @@ -14,6 +14,9 @@ const searchHandler = require('./search-handler');
// 搜索分类信息需要的参数
const positionId = 10;
// 获取分类左侧广告id
const sortAdsId = 79;
/**
* 获取商品分类列表数据
*/
... ... @@ -28,14 +31,13 @@ exports.getListData = (params) => {
// 搜索分类介绍和广告
if (params.msort && params.misort) {
let IntroParams = {
position_id: positionId,
max_sort_id: params.msort,
middle_sort_id: params.misort,
gender: params.gender || '1,3'
};
apiMethod.push(searchApi.getSortIntro(IntroParams));
apiMethod.push(searchApi.getSortAds(IntroParams));
apiMethod.push(searchApi.getSortIntro(Object.assign(IntroParams, {position_id: positionId})));
apiMethod.push(searchApi.getSortAds(Object.assign(IntroParams, {position_id: sortAdsId})));
}
return api.all(apiMethod).then(result => {
... ... @@ -43,12 +45,14 @@ exports.getListData = (params) => {
headerData: Object.assign(result[0].headerData, {
header: true
}),
search: {}
list: {
leftContent: {}
}
};
// 获取左侧类目数据
if (result[1].code === 200) {
finalResult.search = {
finalResult.list = {
leftContent: searchHandler.handleSortData(result[1].data.sort, params),
pathNav: searchHandler.handlePathNavData(result[1].data.sort, params, 'sort')
};
... ... @@ -56,7 +60,7 @@ exports.getListData = (params) => {
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
Object.assign(finalResult.search, {
Object.assign(finalResult.list, {
filters: searchHandler.handleFilterData(result[2].data.filter, params),
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
... ... @@ -68,12 +72,12 @@ exports.getListData = (params) => {
// 分类介绍
if (result[3] && result[3].code === 200) {
finalResult.sortIntro = searchHandler.handleSortIntro(result[3].data);
finalResult.list.sortIntro = searchHandler.handleSortIntro(result[3].data);
}
// 分类广告
if (result[4] && result[4].code === 200) {
finalResult.sortIntro = searchHandler.handleSortAds(result[4].data);
Object.assign(finalResult.list.leftContent, searchHandler.handleSortAds(result[4].data));
}
return finalResult;
});
... ...
... ... @@ -9,12 +9,14 @@ const api = global.yoho.SearchAPI;
const yohoApi = global.yoho.API;
const serviceApi = global.yoho.ServiceAPI;
const getSortByConditionAsync = (condition) => {
return api.get('sortgroup.json', condition);
};
// 获取list页广告
const adsUrl = 'shops/api/v1/ads/getList';
const adsUrl = '/shops/api/v1/ads/getList';
/**
* 获取商品列表
... ... @@ -63,7 +65,7 @@ const getSortIntro = (params) => {
* @return
*/
const getSortAds = (params) => {
return yohoApi.get(adsUrl, params);
return serviceApi.get(adsUrl, params);
};
/**
... ...
... ... @@ -51,7 +51,6 @@ const handleCheckedData = (params, origin, param) => {
if (!_.isEmpty(origin)) {
_.forEach(origin, value => {
if (value.checked) {
console.log(value);
let tempPatam = {};
tempPatam[param] = '';
... ... @@ -589,7 +588,6 @@ exports.handleFilterData = (origin, params) => {
dest.ageLevel.push(ageLevel);
});
console.log(dest.ageLevel);
}
// 清除所有选中数据
... ... @@ -664,7 +662,6 @@ exports.handlePathNavData = (data, params, page) => {
// 分类
_.forEach(data, (sort) => {
if (sort.sort_id === params.msort) {
console.log(params.msort);
pathNav.push({
name: sort.sort_name,
href: helpers.urlFormat('/product/outlets/list', {msort: sort.sort_id}),
... ... @@ -819,7 +816,6 @@ exports.handleSortIntro = (data, params) => {
});
});
return sortIntro;
};
... ... @@ -827,12 +823,20 @@ exports.handleSortIntro = (data, params) => {
* 处理分类页左侧广告
* @type {[type]}
*/
exports.handleSortAds = (data, params) => {
exports.handleSortAds = (data) => {
let sortAds = {
data: data,
params: params
picLink: {
picTitle: '',
list: []
}
};
_.forEach(data, function(value) {
sortAds.picLink.list.push({
href: value.ads_url,
src: value.ads_image
});
});
return sortAds;
};
... ...
{{> list/list}}
\ No newline at end of file
<div class="product-page yoho-page product-list-page">
{{# list}}
{{> list/list}}
{{/list}}
</div>
\ No newline at end of file
... ...
{{> list/list}}
\ No newline at end of file
<div class="product-page yoho-page">
{{# search}}
{{> list/list}}
{{/search}}
</div>
\ No newline at end of file
... ...
<div class="product-page yoho-page">
{{# search}}
<div class="center-content clearfix">
{{# brandBanner}}
<div class="brand-banner">
<div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div>
<div class="opt-wrap">
<p class="opt center-content">
<a href="{{brandHome}}">
<i class="iconfont">&#xe617;</i>
品牌首页
</a>
<a href="{{brandIntro}}">
<i class="iconfont">&#xe631;</i>
品牌介绍
</a>
<span id="brand-favor" class="brand-favor" data-id="{{dataId}}">
<i class="iconfont{{#if coled}} coled{{/if}}">&#xe616;</i>
</span>
</p>
</div>
</div>
{{/ brandBanner}}
{{# shopBanner}}
<div class="brand-banner base-shop-banner">
<div class="banner-img" style="height: {{bannerHeight}}px;background: url({{banner}})"></div>
<div class="opt-wrap">
<p class="opt center-content">
{{#if showShopName}}
<span class="shop-name">{{shopName}}</span>
{{/if}}
<a href="{{shopHome}}">
<i class="iconfont">&#xe617;</i>
店铺首页
</a>
<a href="{{shopIntro}}">
<i class="iconfont">&#xe631;</i>
店铺介绍
</a>
<span id="shop-favor" class="brand-favor shop-favor" data-id="{{shopId}}">
<i class="iconfont{{#if coled}} coled{{/if}}">&#xe616;</i>
</span>
</p>
</div>
</div>
{{/ shopBanner}}
<div class="center-content clearfix">
{{# pathNav}}
{{> common/path-nav}}
{{/ pathNav}}
... ... @@ -26,9 +71,10 @@
<img class="pull-right img" src="{{img}}">
</div>
{{/ sortIntro}}
{{> list/shop-entry}}
{{> product/standard-content}}
</div>
</div>
{{/search}}
</div>
... ...
... ... @@ -14,13 +14,15 @@ module.exports = {
port: 6002,
siteUrl: 'http://www.yohobuy.com',
domains: {
api: 'http://api.yoho.yohoops.org',
// api: 'http://api.yoho.yohoops.org',
api: 'http://devapi.yoho.cn:58078/',
// api: 'http://devapi.yoho.cn:58078/',
// api: 'http://testapi.yoho.cn:28078/',
service: 'http://devservice.yoho.cn:58077/',
// service: 'http://service.yoho.yohoops.org',
// service: 'http://testservice.yoho.cn:28077/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
... ...