获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。
1:原生微信小程序接口使用API:wx.chooseAddress(OBJECT)
wx.chooseAddress({success (res) {console.log(res.userName)console.log(res.postalCode)console.log(res.provinceName)console.log(res.cityName)console.log(res.countyName)console.log(res.detailInfo)console.log(res.nationalCode)console.log(res.telNumber)}
})
2:uniapp 使用uni.chooseAddress(OBJECT)
获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址,需要用户授权 scope.address。
uni.chooseAddress({success(res) {console.log(res.userName)console.log(res.postalCode)console.log(res.provinceName)console.log(res.cityName)console.log(res.countyName)console.log(res.detailInfo)console.log(res.nationalCode)console.log(res.telNumber)}
})
直接使用此接口会报错:{errMsg: "chooseAddress:fail the api need to be declared in …e requiredPrivateInfos field in app.json/ext.json"}
HBuilderX中开发,manifest.json文件的mp-weixin节点中加入以下配置即可成功调用:
"requiredPrivateInfos": ["getFuzzyLocation","choosePoi","chooseAddress"
],
"permission": {"scope.userLocation": {"desc": "你的位置信息将用来进行接口调试"}
}