sale.js
1.9 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
/**
* 频道页面 model
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/05/17
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const _ = require('lodash');
const camelCase = require(`${library}/camel-case`);
const api = new API();
/**
* 折扣专场跳转链接处理
*/
const processSpecial = (list) => {
const formatData = [];
list = list || [];
list = camelCase(list);
_.forEach(list, (data) => {
data.specialUrl = `/product/specialDetail?id=${data.id}`;
formatData.push(data);
});
return formatData;
};
/**
* 获取首页数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSaleData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
}, params)));
};
/**
* 获取折扣专场专题列表数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSpecialData = (params) => {
const specialData = {};
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 2
}, params))).then((result) => {
if (result && result.code === 200) {
specialData.data = processSpecial(result.data);
return specialData;
// return camelCase(result);
} else {
return Promise.reject('error');
}
});
};
/**
* 获取折扣专场专题详情数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSpecialDetailData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 2
}, params))).then((result) => {
if (result && result.code === 200) {
return camelCase(result.data);
} else {
return Promise.reject('error');
}
});
};