微信小程序导入微信地址

获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。

1:原生微信小程序接口使用API:wx.chooseAddress(OBJECT)

javascript 复制代码
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。

javascript 复制代码
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节点中加入以下配置即可成功调用:

javascript 复制代码
"requiredPrivateInfos": [
    "getFuzzyLocation",
    "choosePoi",
    "chooseAddress"
],
"permission": {
  "scope.userLocation": {
    "desc": "你的位置信息将用来进行接口调试"
  }
}
相关推荐
AnalogElectronic5 小时前
uniapp学习5,兼容微信小程序的俄罗斯方块游戏
学习·微信小程序·uni-app
克里斯蒂亚诺更新10 小时前
微信小程序调用腾讯地图路线规划-注意点
微信小程序·小程序
AnalogElectronic11 小时前
uniapp学习6,滚动字幕播报
javascript·学习·uni-app
AnalogElectronic12 小时前
uniapp学习3,简易记事本
学习·uni-app
Можно12 小时前
uni-app 三端上线全流程指南:H5 / 小程序 / App 完整发布手册
小程序·uni-app
2501_9151063214 小时前
Flutter 开发工具有哪些 跨平台项目开发与上架实操指南
android·flutter·ios·小程序·uni-app·iphone·webview
摇滚侠14 小时前
JAVA 项目教程《苍穹外卖-10》,微信小程序项目,前后端分离,从开发到部署
java·开发语言·微信小程序
AnalogElectronic14 小时前
uniapp学习7,美团闪购生鲜蔬菜商家详情页
javascript·学习·uni-app
AnalogElectronic15 小时前
uniapp学习4,简易记事本2.0
学习·uni-app
小旋风0123415 小时前
uniapp开发app解决视频层级太高的问题(subNvue方法)
前端·uni-app·音视频