address-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
104
105
106
107
108
/**
* address api
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/09/27
*/
'use strict';
const api = global.yoho.API;
/**
* 获取用户收货地址列表
* @param uid [number] uid
*/
const getAddressListAsync = (uid) => api.get('', {
method: 'app.address.gethidden',
uid: uid
}, {code: 200});
/**
* 省市区列表
* @param id [number] 省市区id
*/
const getAreaListAsync = (id) => {
return api.get('', {
method: 'app.address.provinces',
id: id || 0
});
};
/**
* 地址删除
* @param uid [number] uid
* @param id [string] address id
*/
const delAddressAsync = (uid, id) => api.get('', {
method: 'app.address.del',
uid: uid,
id: id
});
/**
* 新增地址api
* @param uid [Number]
* @param consignee [String] 收货人
* @param areaCode [Number] 区号
* @param address [String] 地址
* @param mobile [String] 手机号
* @param phone [String] 电话号码
* @param zipCode [String] 邮编
* @param email [String] 邮箱
*/
const addAddressAsync = (uid, consignee, areaCode, address, mobile, phone, zipCode, email) => api.get('', {
method: 'app.address.add',
uid: uid,
consignee: consignee,
area_code: areaCode,
address: address,
mobile: mobile,
phone: phone,
zip_code: zipCode,
email: email
});
/**
* 更新地址地址api
* @param uid [Number]
* @param id [Number] 地址id
* @param consignee [String] 收货人
* @param areaCode [Number] 区号
* @param address [String] 地址
* @param mobile [String] 手机号
* @param phone [String] 电话号码
* @param zipCode [String] 邮编
* @param email [String] 邮箱
*/
const updateAddressAsync = (uid, id, consignee, areaCode, address, mobile, phone, zipCode, email) => api.get('', {
method: 'app.address.update',
uid: uid,
id: id,
consignee: consignee,
area_code: areaCode,
address: address,
mobile: mobile,
phone: phone,
zip_code: zipCode,
email: email
});
/**
* 设置默认地址
* @param uid [Number]
* @param id [Number] 地址id
*/
const setDefaultAddressAsync = (uid, id) => api.get('', {
method: 'app.address.setdefault',
uid: uid,
id: id
});
module.exports = {
getAddressListAsync,
getAreaListAsync,
delAddressAsync,
addAddressAsync,
updateAddressAsync,
setDefaultAddressAsync
};