Authored by 周少峰

check

... ... @@ -42,3 +42,5 @@ exports.getOutletsActivityOrigin = (params) => {
exports.getChannelResouceData = (params) => {
return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params));
};
... ...
'use strict';
const library = '../../../library';
const helpers = require(`${library}/helpers`);
// const library = '../../../library';
// const helpers = require(`${library}/helpers`);
const _ = require('lodash');
const camelCase = require('../../../library/camel-case');
/**
* NL2R图片轮播
*/
const NL2R = (data) => {
const nl2r = (data) => {
const result = {
left: [],
right: [],
right: []
};
//左侧
_.forEach(data.left, (value, key) => {
// 左侧
_.forEach(data.left, (value) => {
result.left.push({
img: value.src,
url: value.url
});
})
//右侧
_.forEach(data.right, (value, key) => {
});
// 右侧
_.forEach(data.right, (value) => {
result.right.push({
img: value.src,
url: value.url
});
})
return result
}
});
return result;
};
/**
* 热门分类
... ... @@ -41,15 +44,55 @@ const hotCategory = (data) => {
brands: data.imgs.slice(0, 1),
types: data.imgs.slice(1, 7)
}
}
}
};
};
/**
* 分类导航
*/
const categoryNavigation = (data) => {
const categoryNavigation = (data) => {
const goodsMenu = {
title: '最新折扣',
menuList: [],
more: 'http://list.yohobuy.com/?msort=3&misort=26'
};
}
_.forEach(data, (value) => {
goodsMenu.menuList.push({
cur: false,
url: value.url,
name: value.categoryName
});
});
return {
goodsBoard: {
oodsMenu: goodsMenu,
sort: {
sortType: [{
name: '最新',
active: true,
hasSortOrient: {
active: true,
desc: true
}
}, {
name: '折扣',
active: false,
hasSortOrient: {
active: false,
desc: true
}
}, {
name: '价格',
active: false,
hasSortOrient: {
active: true,
desc: true
}
}]
}}
};
};
/**
... ... @@ -59,15 +102,16 @@ const hotCategory = (data) => {
*/
exports.processFloor = (list) => {
const formatData = [];
var floorData;
let floorData;
list = list || [];
list = camelCase(list);
//格式化数据
// 格式化数据
_.forEach(list, (floor) => {
switch (floor.templateName) {
case 'NL2R':
floorData = NL2R(floor.data);
floorData = nl2r(floor.data);
break;
case 'hotCategory':
floorData = hotCategory(floor.data);
... ... @@ -88,11 +132,12 @@ exports.processFloor = (list) => {
/**
* 组织嗨购数据
*/
exports.formatActivityData = (data) => {
var high = {
exports.formatActivityData = (data) => {
let high = {
name: '限时嗨购',
imgHot: []
};
_.forEach(data, (value) => {
high.imgHot.push({
url: value.webUrl,
... ... @@ -102,6 +147,6 @@ exports.processFloor = (list) => {
price: value.promotionName,
count: value.endTime
});
})
});
return high;
}
\ No newline at end of file
};
... ...
... ... @@ -7,17 +7,15 @@
'use strict';
const library = '../../../library';
const _ = require('lodash');
const utils = '../../../utils';
// const _ = require('lodash');
const API = require(`${library}/api`).API;
const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const serviceApi = new ServiceAPI();
const api = new API();
const sign = require(`${library}/sign`);
const helpers = require(`${library}/helpers`);
const camelCase = require('../../../library/camel-case');
const saleApi = require('./sale-api');
const outletsProcess = require('./outlets-handler');
const outletsApi = require('./outlets-api');
const productProcess = require(`${utils}/product-process`);
/**
* 处理奥莱活动数据
... ... @@ -25,7 +23,7 @@ const outletsApi = require('./outlets-api');
* @return {[type]} [description]
*/
const handleOutletsActivityData = (origin) => {
var dest = {};
let dest = {};
dest = origin;
... ... @@ -51,7 +49,7 @@ exports.getOutletsIndexData = (params) => {
// 处理资源位数据
if (result[1].code === 200) {
finalResult = Object.assign(finalResult, handleOutletsBannersData(result[1].data));
// finalResult = Object.assign(finalResult, handleOutletsBannersData(result[1].data));
}
return finalResult;
... ... @@ -62,7 +60,6 @@ exports.getOutletsIndexData = (params) => {
// 奥莱频道资源码
const channelCode = {
boys: '2af513637dc5feeec7f6f8b52989b24b',
// 'boys' : 'e0565dad65fb8da1f39bc1ac83fc8346',
girls: 'd1b56b56c3a12dc1f2f83958680a0911',
kids: '0fd7ad594940f9ec5a03697317cf6521',
lifestyle: 'b3d3f55a26f130ac2b516b9fb3823711'
... ... @@ -74,15 +71,28 @@ const channelCode = {
* @return {[type]}
*/
exports.getOutletsChannelData = (params) => {
var channelData = {};
return api.all([outletsApi.getChannelResouceData({content_code: channelCode[params.channel]}), outletsApi.getOutletsActivityOrigin({platform: 2, size: 0, type:1})]).then(result => {
let channelData = {};
return api.all([
outletsApi.getChannelResouceData({content_code: channelCode[params.channel]}),
outletsApi.getOutletsActivityOrigin({platform: 2, size: 0, type: 1}),
saleApi.getSaleGoodsList(params)
]).then(result => {
// 资源楼层
if (result[0].code === 200) {
Object.assign(channelData, outletsProcess.processFloor(result[0].data.list));
}
// 限时嗨购
if (result[1].code === 200) {
Object.assign(channelData, {flashSale: outletsProcess.formatActivityData(result[1].data)});
}
// 商品列表
if (result[2].code === 200) {
channelData.goodsBoard.list = productProcess.processProductList(result[2].data.product_list);
}
return channelData;
});
}
};
... ...
... ... @@ -11,13 +11,13 @@
<div class="product-list clearfix">
{{# list}}
<div class="list-item">
<a class="thumb" href="{{href}}" target="_blank">
<img class="lazy" data-original="{{image img 235 314}}">
<a class="thumb" href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image thumb 235 314}}">
</a>
<div class="detail-text">
<a class="name" href="{{href}}" target="_blank">{{title}}</a>
<a class="name" href="{{url}}" target="_blank">{{productName}}</a>
<p>
<span class="price">{{price}}</span>
<span class="price">¥{{salesPrice}}</span>
<label class="discount">{{discount}}</label>
</p>
</div>
... ...