shop-api.js
2.83 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/7/26
* Time: 10:35
*/
'use strict';
const api = global.yoho.API;
const _ = require('lodash');
const yhChannel = {
men: {
channel: '1'
},
women: {
channel: '2'
},
lifestyle: {
channel: '4'
}
};
module.exports = {
/**
* 通过品牌域名获取品牌信息
* @param params
*/
getBrandInfoByDomain(params) {
return api.get('', {
method: 'web.brand.byDomain',
domain: params.domain
}, {code: 200, cache: false});
},
/**
* 从接口获取品牌店铺数据
* @returns {*}
*/
getShopInfoData(params) {
let finalParams = {
method: 'app.shops.getIntro',
shop_id: params.shopId
};
if (params.uid) {
Object.assign(finalParams, {
uid: params.uid
});
}
return api.get('', finalParams, {code: 200, cache: false});
},
/**
* 从接口获得店铺装修资源
* @param params
* @returns {*}
*/
getShopsDecoratorList(params) {
return api.get('', {
method: 'app.shopsdecorator.getList',
shop_id: params.shopId
}, {code: 200, cache: false});
},
/**
* 从接口获取品牌店铺商品数据
* @returns {*}
*/
getBrandShopGoodsOriginData(params) {
let finalParams = {
method: 'app.search.brand',
yh_channel: params.channel ? yhChannel[params.channel].channel : '1',
brand: params.brand,
shop_id: params.shopId,
order: params.order,
limit: params.limit,
page: params.page,
gender: params.gender,
color: params.color,
price: params.price,
size: params.size,
p_d: params.pd,
sort: params.sort,
tags_filter: params.tagsFilter
};
/* 删除没有参数的条件 */
_.forEach(finalParams, (value, key) => {
if (!value) {
delete finalParams[key];
}
});
return api.get('', finalParams, {code: 200, cache: false});
},
/**
* 收藏取消收藏店铺
* @param params
* @returns {*}
*/
collectShopOriginData(params) {
let finalParams = {
id: params.shopId,
fav_id: params.shopId,
uid: params.uid,
type: params.type
};
if (params.isFav === 'true') {
Object.assign(finalParams, {
method: 'app.favorite.cancel'
});
} else {
Object.assign(finalParams, {
method: 'app.favorite.add'
});
}
return api.get('', finalParams, {code: 200, cache: false});
}
};