微信小程序导入微信地址

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

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": "你的位置信息将用来进行接口调试"
  }
}
相关推荐
前端 贾公子3 小时前
在移动端使用 Tailwind CSS (uniapp)
前端·uni-app
源码_V_saaskw9 天前
宇鹿家政服务系统小程序ThinkPHP+UniApp
微信小程序·小程序·uni-app·微信公众平台
xw59 天前
支付宝小程序IDE版本迭代异常
uni-app·支付宝
!win !9 天前
支付宝小程序IDE版本迭代异常
uni-app·支付宝小程序
xw59 天前
抖音小程序支付错误码141211
uni-app·抖音小程序
好好的哦10 天前
抖音小程序支付错误码141211
小程序·uni-app
anyup10 天前
uni-app 应用隐私政策怎么写?一份模板+实用技巧送给你
前端·uni-app·cursor
郭玉齐10 天前
uniapp+vue3做小程序,获取容器高度
小程序·uni-app
Q_Q196328847510 天前
python基于微信小程序的广西文化传承系统
开发语言·spring boot·python·微信小程序·django·flask
kingbal10 天前
uniapp:微信小程序胶囊「复制链接」灰色处理
微信小程序·小程序·uni-app