brands-api.js
2.3 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
/**
* 品牌一览 api
* @author: ghw<hongwei.gao@yoho.cn>
* @date: 2016/9/29
*/
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const config = global.yoho.config;
/**
* 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC
* 顶部的轮翻广告及热门品牌数据
* @param string $contentCode 获取广告资源需要的位置码
*/
const getBrandTopData = (contentCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode
}, config.apiCache);
};
/**
* 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据"
* @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
*/
const getBrandListData = channel => {
let params = {method: 'app.brand.allBrandList'};
if (!isNaN(channel)) {
params.yh_channel = channel;
}
return api.get('', params, config.apiCache);
};
/**
* 获取品牌简介
*
* @param integer $brandId 品牌ID
* @param int 用户ID
* @return array 品牌介绍信息
*/
const getBrandIntro = (brandId, uid) => {
let param = {};
if (!uid) {
param.cache = 3600;
}
return api.get('', {
method: 'app.brand.getBrandIntro',
brand_id: brandId,
uid: uid
}, param, config.apiCache);
};
/**
* 获取品牌中产品图片
* @param int 品牌ID
* @return array 品牌产品信息
*/
const getProductByBrand = (brandId, limit) => {
return api.get('', {
method: 'web.search.search',
brand: brandId,
limit: limit
}, config.apiCache);
};
/**
* 获取品牌信息
*
* @param array $ids
* @return array
*/
const getBrandInfoByIds = (ids) => {
return api.get('', {
method: 'web.brand.info',
ids: ids instanceof Array ? ids.join(',') : parseInt(ids, 10)
}, config.apiCache);
};
/**
* 获取品牌列表
*
* @param int $brandType
* @param string $gender
* @param string $type
* @return array
*/
const getPlusstarList = (brandType, gender) => {
return serviceAPI.get('guang/api/v3/plustar/getlist', {
gender: gender,
brand_type: brandType
}, config.apiCache);
};
module.exports = {
getBrandTopData,
getBrandListData,
getBrandIntro,
getProductByBrand,
getPlusstarList,
getBrandInfoByIds
};