1. 前言
wx.chooseAddress()
用于获取用户的收货地址。调起用户微信收货地址原生界面,返回用户选择的地址
站长源码网
微信开发文档: https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html
2. 使用示例
代码语言:javascript复制<button type="primary" bindtap="getAddress">获取收货地址</button>
代码语言:javascript复制wx.chooseAddress({
success (res) {
// 选择了地址
console.log(res, 'success')
},
fail (res) {
// 取消选择
console.log(res, 'fail')
},
complete (res) {
// 是否选择地址都会执行
console.log(res, 'complete')
}
})
3. 返回值
选择了收货地址,success
成功回调
{
"cityName": "广州市",
"countyName": "海珠区",
"detailInfo": "新港中路397号",
"errMsg": "chooseAddress:ok",
"nationalCode": "510000",
"postalCode": "510000",
"provinceName": "广东省",
"telNumber": "020-81167888",
"userName": "张三"
}
未选择收货地址,fail
回调
{
"errMsg": "chooseAddress:fail cancel"
}