微信小程序导入微信地址

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

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": "你的位置信息将用来进行接口调试"
  }
}
相关推荐
andrsted16 小时前
练题簿免费刷题小程序:和学习搭子共用一份题库,一起刷题复习
学习·面试·微信小程序·小程序·学习方法·刷题
PedroQue9920 小时前
uni-app x工程化实战:从页面堆到可维护架构
前端·uni-app
计算机毕设定制辅导-无忧学长20 小时前
《基于微信小程序的个人智能刷题助手的设计与实现》
java·spring boot·mysql·微信小程序·uniapp·个人智能刷题助手系统
百慕大三角20 小时前
为了在 Linux CI 里跑小程序 E2E,我把微信官方基础库搬进了浏览器:wxa-runner 开源实践
微信小程序·agent·测试
2501_9160088921 小时前
马甲包过审卡在哪?Ipa Guard 能做的和做不到的
android·小程序·https·uni-app·iphone·webview
2501_915921432 天前
iOS应用耗电测试:使用Energy Log、Keymob和Instruments进行性能监控与能源消耗分析
android·ios·小程序·https·uni-app·iphone·webview
txc2 天前
我用 AI 给两个人写了个微信小程序(二):从「能用」到「用得对」
微信小程序
行思理2 天前
个推厂商应用开通指南
运维·服务器·uni-app·个推·uni-app push
海上彼尚2 天前
【微信小程序】xxx该网站的安全证书存在问题,可选择 “继续”在浏览器中访问。
安全·微信小程序·小程序
郑州光合科技余经理2 天前
同城商城源码:商品库和订单库怎么随包交付
android·java·开发语言·后端·uni-app·php·ai编程