...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-05-19 10:20:08
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-05-20 16:52:10
|
|
|
* @Last Modified time: 2016-05-20 17:55:34
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
...
|
...
|
@@ -17,7 +17,7 @@ const _ = require('lodash'); |
|
|
* @param {Object} origin [原始数据]
|
|
|
* @return {Object} [结果]
|
|
|
*/
|
|
|
const handleSaleData = (origin) => {
|
|
|
const handleSaleIndexData = (origin) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest = origin;
|
...
|
...
|
@@ -30,38 +30,55 @@ const handleSaleData = (origin) => { |
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
const handleSaleGoodsListData = (origin) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest.saleList = {};
|
|
|
dest.saleList.leftContent = {};
|
|
|
dest.saleList.goods = [];
|
|
|
var goods = [];
|
|
|
|
|
|
|
|
|
if (!_.isEmpty(origin.product_list)) {
|
|
|
|
|
|
_.forEach(origin.product_list, function(value) {
|
|
|
let goods = {};
|
|
|
let oneGoods = {};
|
|
|
|
|
|
goods.tags = value.tags;
|
|
|
goods.thumb = value.default_images;
|
|
|
goods.url = '/product/pro_' + value.product_id + '_' + value.goods_list[0].goods_id + '/' +
|
|
|
oneGoods.tags = value.tags;
|
|
|
oneGoods.thumb = value.default_images;
|
|
|
oneGoods.url = '/product/pro_' + value.product_id + '_' + value.goods_list[0].goods_id + '/' +
|
|
|
value.cn_alphabet + '.html';
|
|
|
goods.goodsList = value.goods_list;
|
|
|
goods.name = value.product_name;
|
|
|
goods.brand = {};
|
|
|
goods.brand.url = value.brand_domain + '.SUB_DOMAIN'; // 待处理
|
|
|
goods.brand.name = value.brand_name;
|
|
|
goods.marketPrice = value.market_price;
|
|
|
|
|
|
dest.saleList.goods.push(goods);
|
|
|
oneGoods.goodsList = value.goods_list;
|
|
|
oneGoods.name = value.product_name;
|
|
|
oneGoods.brand = {};
|
|
|
oneGoods.brand.url = value.brand_domain + '.SUB_DOMAIN'; // 待处理
|
|
|
oneGoods.brand.name = value.brand_name;
|
|
|
oneGoods.marketPrice = value.market_price;
|
|
|
|
|
|
goods.push(oneGoods);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
return goods;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品列表
|
|
|
* 处理分类筛选数据
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
const handleSaleSortData = (origin) => {
|
|
|
var leftContent = {};
|
|
|
|
|
|
leftContent.allDiscount = {};
|
|
|
leftContent.allDiscount.list = [];
|
|
|
|
|
|
_.forEach(origin, function(value) {
|
|
|
let category = {};
|
|
|
|
|
|
category.name = value.sort_name;
|
|
|
leftContent.allDiscount.list.push(category);
|
|
|
});
|
|
|
|
|
|
|
|
|
return leftContent;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 返回商品列表 promise 对象
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
const getSaleGoodsList = () => {
|
...
|
...
|
@@ -76,10 +93,10 @@ const getSaleGoodsList = () => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取断码区分类信息
|
|
|
* 获取分类信息 promise 对象
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
const getBreakingSort = () => {
|
|
|
const getSortList = () => {
|
|
|
return api.get('', sign.apiSign({
|
|
|
method: 'app.sale.getBreakingSort',
|
|
|
yh_channel: 1
|
...
|
...
|
@@ -87,47 +104,34 @@ const getBreakingSort = () => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取首页数据
|
|
|
* 获取 Sale 首页数据
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSaleDate = () => {
|
|
|
exports.getSaleIndexDate = () => {
|
|
|
return api.get('', sign.apiSign({
|
|
|
method: 'app.activity.get',
|
|
|
sort: 2,
|
|
|
plateform: 2
|
|
|
})).then(result => {
|
|
|
|
|
|
return handleSaleData(result);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品列表数据
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSaleGoodsListData = () => {
|
|
|
|
|
|
return getSaleGoodsList().then(result => {
|
|
|
if (result.code === 200) {
|
|
|
return handleSaleGoodsListData(result.data);
|
|
|
}
|
|
|
return handleSaleIndexData(result);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取断码区信息
|
|
|
* 获取页面全部信息
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getbreakingYardsData = () => {
|
|
|
exports.getSaleData = () => {
|
|
|
|
|
|
return api.all([getBreakingSort(), getSaleGoodsList()]).then(result => {
|
|
|
return api.all([getSortList(), getSaleGoodsList()]).then(result => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
if (result[0].code === 200) {
|
|
|
finalResult.category = result[0].data;
|
|
|
finalResult.leftContent = handleSaleSortData(result[0].data);
|
|
|
}
|
|
|
if (result[1].code === 200) {
|
|
|
finalResult.goodsList = handleSaleGoodsListData(result[1].data);
|
|
|
finalResult.goods = handleSaleGoodsListData(result[1].data);
|
|
|
}
|
|
|
return finalResult;
|
|
|
});
|
...
|
...
|
|