#### 1. 前言 --- `wx.chooseAddress()` 用于獲取用戶的收貨地址。調(diào)起用戶微信收貨地址原生界面,返回用戶選擇的地址 微信開發(fā)文檔: [https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html) #### 2. 使用示例 --- ``` <button type="primary" bindtap="getAddress">獲取收貨地址</button> ``` ```javascript wx.chooseAddress({ success (res) { // 選擇了地址 console.log(res, 'success') }, fail (res) { // 取消選擇 console.log(res, 'fail') }, complete (res) { // 是否選擇地址都會執(zhí)行 console.log(res, 'complete') } }) ``` #### 3. 返回值 --- **選擇了收貨地址,`success` 成功回調(diào)** ```json { "cityName": "廣州市", "countyName": "海珠區(qū)", "detailInfo": "新港中路397號", "errMsg": "chooseAddress:ok", "nationalCode": "510000", "postalCode": "510000", "provinceName": "廣東省", "telNumber": "020-81167888", "userName": "張三" } ``` **未選擇收貨地址,`fail` 回調(diào)** ```json { "errMsg": "chooseAddress:fail cancel" } ```