微信小程序导入微信地址

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

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": "你的位置信息将用来进行接口调试"
  }
}
相关推荐
滴水未满11 小时前
uniapp的调试和安装
uni-app
沉默-_-11 小时前
微信小程序网络请求 wx.request 详解
网络·学习·微信小程序·小程序
2501_9159090612 小时前
设置了 SSL Pinning 与双向 TLS 验证要怎么抓包
网络·网络协议·ios·小程序·uni-app·iphone·ssl
壹号机长13 小时前
vue3+uniapp 今天及未来六天日期的时间段预约选择,时间段预约当前时间之前禁用选择
uni-app
沉默-_-13 小时前
微信小程序页面配置详解
学习·微信小程序·apache·微信开发者工具
滴水未满17 小时前
uniapp的页面
前端·uni-app
2501_9160074718 小时前
如何查看 iOS 设备系统与硬件信息,iOS系统信息显示工具
android·ios·小程序·https·uni-app·iphone·webview
逆龙泰氽19 小时前
微信小程序开发04-1(小程序API)
微信小程序·小程序
苏苏哇哈哈20 小时前
微信小程序实现高性能动态配置水滴凹槽、凸起Tabbar 组件
微信小程序·小程序
逆龙泰氽20 小时前
微信小程序开发03(WXML语法)
微信小程序·小程序