address.js
2.87 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
124
125
126
127
128
129
/**
* [个人中心]收货地址
* @author: jiangmin
* @date: 2016/07/05
*/
'use strict';
const api = global.yoho.API;
/**
* 地址列表数据
*
* @param uid 用户ID
* @param limit 分页大小参数(默认10条)
* @return array 地址接口返回的数据
*/
const getAddressDataAsync = (uid, limit) => {
return api.get('', {
method: 'app.address.gethidden',
uid: uid,
limit: limit
}).then(result => {
// console.log('列表结果result', result);
if (result.code === 200) {
return result.data;
} else {
return result;
}
});
};
/**
* 保存地址数据
*
* @param uid 用户ID
* @param address 地址信息
* @param areaCode 城市码
* @param consignee 收货人
* @param mobile 手机号码
* @param phone 电话号码
* @return array 地址接口返回的数据
*/
const addAddressData = (uid, address, areaCode, consignee, mobile, phone) => {
return api.get('', {
method: 'app.address.add',
uid: uid,
address: address,
area_code: areaCode,
consignee: consignee,
mobile: mobile,
phone: phone
}).then(result => {
// console.log("添加result",result);
return result;
});
};
/**
* 修改地址数据
*
* @param id 地址id
* @param uid 用户ID
* @param address 地址信息
* @param areaCode 城市码
* @param consignee 收货人
* @param mobile 手机号码
* @param phone 电话号码
* @return array 地址接口返回的数据
*/
const updateAddressData = (id, uid, address, areaCode, consignee, mobile, phone) => {
return api.get('', {
method: 'app.address.update',
id: id,
uid: uid,
address: address,
area_code: areaCode,
consignee: consignee,
mobile: mobile,
phone: phone
}).then(result => {
// console.log("修改result", result);
return result;
});
};
/**
* 删除地址数据
*
* @param id 地址id
* @param uid 用户ID
* @return array 地址接口返回的数据
*/
const delAddressData = (id, uid) => {
return api.get('', {
method: 'app.address.del',
id: id,
uid: uid
}).then(result => {
// console.log("删除result",result);
return result;
});
};
/**
* 设置默认地址
*
* @param id 地址id
* @param uid 用户ID
* @return array 地址接口返回的数据
*/
const setDefaultAddress = (id, uid) => {
return api.get('', {
method: 'app.address.setdefault',
id: id,
uid: uid
}).then(result => {
// console.log('设置默认result', result);
return result;
});
};
module.exports = {
getAddressDataAsync: getAddressDataAsync,
addAddressData: addAddressData,
updateAddressData: updateAddressData,
delAddressData: delAddressData,
setDefaultAddress: setDefaultAddress
};