|
@@ -2,7 +2,7 @@ |
|
@@ -2,7 +2,7 @@ |
2
|
* @Author: Targaryen
|
2
|
* @Author: Targaryen
|
3
|
* @Date: 2016-05-19 10:20:08
|
3
|
* @Date: 2016-05-19 10:20:08
|
4
|
* @Last Modified by: Targaryen
|
4
|
* @Last Modified by: Targaryen
|
5
|
- * @Last Modified time: 2016-05-20 16:52:10
|
5
|
+ * @Last Modified time: 2016-05-20 17:55:34
|
6
|
*/
|
6
|
*/
|
7
|
|
7
|
|
8
|
'use strict';
|
8
|
'use strict';
|
|
@@ -17,7 +17,7 @@ const _ = require('lodash'); |
|
@@ -17,7 +17,7 @@ const _ = require('lodash'); |
17
|
* @param {Object} origin [原始数据]
|
17
|
* @param {Object} origin [原始数据]
|
18
|
* @return {Object} [结果]
|
18
|
* @return {Object} [结果]
|
19
|
*/
|
19
|
*/
|
20
|
-const handleSaleData = (origin) => {
|
20
|
+const handleSaleIndexData = (origin) => {
|
21
|
var dest = {};
|
21
|
var dest = {};
|
22
|
|
22
|
|
23
|
dest = origin;
|
23
|
dest = origin;
|
|
@@ -30,38 +30,55 @@ const handleSaleData = (origin) => { |
|
@@ -30,38 +30,55 @@ const handleSaleData = (origin) => { |
30
|
* @return {[type]} [description]
|
30
|
* @return {[type]} [description]
|
31
|
*/
|
31
|
*/
|
32
|
const handleSaleGoodsListData = (origin) => {
|
32
|
const handleSaleGoodsListData = (origin) => {
|
33
|
- var dest = {};
|
|
|
34
|
-
|
|
|
35
|
- dest.saleList = {};
|
|
|
36
|
- dest.saleList.leftContent = {};
|
|
|
37
|
- dest.saleList.goods = [];
|
33
|
+ var goods = [];
|
38
|
|
34
|
|
39
|
|
35
|
|
40
|
if (!_.isEmpty(origin.product_list)) {
|
36
|
if (!_.isEmpty(origin.product_list)) {
|
41
|
|
37
|
|
42
|
_.forEach(origin.product_list, function(value) {
|
38
|
_.forEach(origin.product_list, function(value) {
|
43
|
- let goods = {};
|
39
|
+ let oneGoods = {};
|
44
|
|
40
|
|
45
|
- goods.tags = value.tags;
|
|
|
46
|
- goods.thumb = value.default_images;
|
|
|
47
|
- goods.url = '/product/pro_' + value.product_id + '_' + value.goods_list[0].goods_id + '/' +
|
41
|
+ oneGoods.tags = value.tags;
|
|
|
42
|
+ oneGoods.thumb = value.default_images;
|
|
|
43
|
+ oneGoods.url = '/product/pro_' + value.product_id + '_' + value.goods_list[0].goods_id + '/' +
|
48
|
value.cn_alphabet + '.html';
|
44
|
value.cn_alphabet + '.html';
|
49
|
- goods.goodsList = value.goods_list;
|
|
|
50
|
- goods.name = value.product_name;
|
|
|
51
|
- goods.brand = {};
|
|
|
52
|
- goods.brand.url = value.brand_domain + '.SUB_DOMAIN'; // 待处理
|
|
|
53
|
- goods.brand.name = value.brand_name;
|
|
|
54
|
- goods.marketPrice = value.market_price;
|
|
|
55
|
-
|
|
|
56
|
- dest.saleList.goods.push(goods);
|
45
|
+ oneGoods.goodsList = value.goods_list;
|
|
|
46
|
+ oneGoods.name = value.product_name;
|
|
|
47
|
+ oneGoods.brand = {};
|
|
|
48
|
+ oneGoods.brand.url = value.brand_domain + '.SUB_DOMAIN'; // 待处理
|
|
|
49
|
+ oneGoods.brand.name = value.brand_name;
|
|
|
50
|
+ oneGoods.marketPrice = value.market_price;
|
|
|
51
|
+
|
|
|
52
|
+ goods.push(oneGoods);
|
57
|
});
|
53
|
});
|
58
|
}
|
54
|
}
|
59
|
|
55
|
|
60
|
- return dest;
|
56
|
+ return goods;
|
61
|
};
|
57
|
};
|
62
|
|
58
|
|
63
|
/**
|
59
|
/**
|
64
|
- * 获取商品列表
|
60
|
+ * 处理分类筛选数据
|
|
|
61
|
+ * @return {[type]} [description]
|
|
|
62
|
+ */
|
|
|
63
|
+const handleSaleSortData = (origin) => {
|
|
|
64
|
+ var leftContent = {};
|
|
|
65
|
+
|
|
|
66
|
+ leftContent.allDiscount = {};
|
|
|
67
|
+ leftContent.allDiscount.list = [];
|
|
|
68
|
+
|
|
|
69
|
+ _.forEach(origin, function(value) {
|
|
|
70
|
+ let category = {};
|
|
|
71
|
+
|
|
|
72
|
+ category.name = value.sort_name;
|
|
|
73
|
+ leftContent.allDiscount.list.push(category);
|
|
|
74
|
+ });
|
|
|
75
|
+
|
|
|
76
|
+
|
|
|
77
|
+ return leftContent;
|
|
|
78
|
+};
|
|
|
79
|
+
|
|
|
80
|
+/**
|
|
|
81
|
+ * 返回商品列表 promise 对象
|
65
|
* @return {[type]} [description]
|
82
|
* @return {[type]} [description]
|
66
|
*/
|
83
|
*/
|
67
|
const getSaleGoodsList = () => {
|
84
|
const getSaleGoodsList = () => {
|
|
@@ -76,10 +93,10 @@ const getSaleGoodsList = () => { |
|
@@ -76,10 +93,10 @@ const getSaleGoodsList = () => { |
76
|
};
|
93
|
};
|
77
|
|
94
|
|
78
|
/**
|
95
|
/**
|
79
|
- * 获取断码区分类信息
|
96
|
+ * 获取分类信息 promise 对象
|
80
|
* @return {[type]} [description]
|
97
|
* @return {[type]} [description]
|
81
|
*/
|
98
|
*/
|
82
|
-const getBreakingSort = () => {
|
99
|
+const getSortList = () => {
|
83
|
return api.get('', sign.apiSign({
|
100
|
return api.get('', sign.apiSign({
|
84
|
method: 'app.sale.getBreakingSort',
|
101
|
method: 'app.sale.getBreakingSort',
|
85
|
yh_channel: 1
|
102
|
yh_channel: 1
|
|
@@ -87,47 +104,34 @@ const getBreakingSort = () => { |
|
@@ -87,47 +104,34 @@ const getBreakingSort = () => { |
87
|
};
|
104
|
};
|
88
|
|
105
|
|
89
|
/**
|
106
|
/**
|
90
|
- * 获取首页数据
|
107
|
+ * 获取 Sale 首页数据
|
91
|
* @return {[type]} [description]
|
108
|
* @return {[type]} [description]
|
92
|
*/
|
109
|
*/
|
93
|
-exports.getSaleDate = () => {
|
110
|
+exports.getSaleIndexDate = () => {
|
94
|
return api.get('', sign.apiSign({
|
111
|
return api.get('', sign.apiSign({
|
95
|
method: 'app.activity.get',
|
112
|
method: 'app.activity.get',
|
96
|
sort: 2,
|
113
|
sort: 2,
|
97
|
plateform: 2
|
114
|
plateform: 2
|
98
|
})).then(result => {
|
115
|
})).then(result => {
|
99
|
|
116
|
|
100
|
- return handleSaleData(result);
|
|
|
101
|
- });
|
|
|
102
|
-};
|
|
|
103
|
-
|
|
|
104
|
-/**
|
|
|
105
|
- * 获取商品列表数据
|
|
|
106
|
- * @return {[type]} [description]
|
|
|
107
|
- */
|
|
|
108
|
-exports.getSaleGoodsListData = () => {
|
|
|
109
|
-
|
|
|
110
|
- return getSaleGoodsList().then(result => {
|
|
|
111
|
- if (result.code === 200) {
|
|
|
112
|
- return handleSaleGoodsListData(result.data);
|
|
|
113
|
- }
|
117
|
+ return handleSaleIndexData(result);
|
114
|
});
|
118
|
});
|
115
|
};
|
119
|
};
|
116
|
|
120
|
|
117
|
/**
|
121
|
/**
|
118
|
- * 获取断码区信息
|
122
|
+ * 获取页面全部信息
|
119
|
* @return {[type]} [description]
|
123
|
* @return {[type]} [description]
|
120
|
*/
|
124
|
*/
|
121
|
-exports.getbreakingYardsData = () => {
|
125
|
+exports.getSaleData = () => {
|
122
|
|
126
|
|
123
|
- return api.all([getBreakingSort(), getSaleGoodsList()]).then(result => {
|
127
|
+ return api.all([getSortList(), getSaleGoodsList()]).then(result => {
|
124
|
let finalResult = {};
|
128
|
let finalResult = {};
|
125
|
|
129
|
|
126
|
if (result[0].code === 200) {
|
130
|
if (result[0].code === 200) {
|
127
|
- finalResult.category = result[0].data;
|
131
|
+ finalResult.leftContent = handleSaleSortData(result[0].data);
|
128
|
}
|
132
|
}
|
129
|
if (result[1].code === 200) {
|
133
|
if (result[1].code === 200) {
|
130
|
- finalResult.goodsList = handleSaleGoodsListData(result[1].data);
|
134
|
+ finalResult.goods = handleSaleGoodsListData(result[1].data);
|
131
|
}
|
135
|
}
|
132
|
return finalResult;
|
136
|
return finalResult;
|
133
|
});
|
137
|
});
|