sale.js
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* @Author: Targaryen
* @Date: 2016-05-19 10:20:08
* @Last Modified by: Targaryen
* @Last Modified time: 2016-05-20 15:05:05
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const api = new API();
const _ = require('lodash');
/**
* 处理 sale 首页原始数据
* @param {Object} origin [原始数据]
* @return {Object} [结果]
*/
const handleSaleData = (origin) => {
var dest = {};
dest = origin;
return dest;
};
/**
* 处理商品列表数据
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
const handleSaleGoodsListData = (origin) => {
var dest = {};
dest.saleList = {};
dest.saleList.leftContent = {};
dest.saleList.goods = [];
if (!_.isEmpty(origin.product_list)) {
_.forEach(origin.product_list, function(value) {
let goods = {};
goods.tags = value.tags;
goods.url = ''; // 待处理
goods.thumb = value.goods_list;
goods.name = value.product_name;
goods.brand = {};
goods.brand.url = ''; // 待处理
goods.brand.name = value.brand_name;
goods.marketPrice = value.market_price;
dest.saleList.goods.push(goods);
});
}
return dest;
};
/**
* 获取首页数据
* @return {[type]} [description]
*/
exports.getSaleDate = () => {
return api.get('', sign.apiSign({
method: 'app.activity.get',
sort: 2,
plateform: 2
})).then(result => {
return handleSaleData(result);
});
};
/**
* 获取商品列表数据
* @return {[type]} [description]
*/
exports.getSaleGoodsListData = () => {
return api.get('', sign.apiSign({
method: 'app.search.sales',
limit: 5,
order: 's_t_desc',
page: 1,
productSize: '384x511',
yh_channel: 1
})).then(result => {
if (result.code === 200) {
return handleSaleGoodsListData(result.data);
}
});
};