微信小程序导入微信地址

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

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": "你的位置信息将用来进行接口调试"
  }
}
相关推荐
初尘屿风1 小时前
基于微信小程序的电影院订票选座系统的设计与实现,SSM+Vue+毕业论文+开题报告+任务书+指导搭建视频
vue.js·微信小程序·小程序
貂蝉空大2 小时前
uni-app开发app时 使用uni.chooseLocation遇到的问题
uni-app
林同学++2 小时前
uniapp多端适配
uni-app
kidding7232 小时前
uniapp引入uview组件库(可以引用多个组件)
前端·前端框架·uni-app·uview
qq_316837752 小时前
uniapp 安卓10+ 选择并上传文件
uni-app
合法的咸鱼2 小时前
uniapp 使用unplugin-auto-import 后, vue文件报红问题
前端·vue.js·uni-app
阳%6 小时前
uni-app小程序开发 基础知识2
前端·uni-app
韩召华9 小时前
微信小程序(uni)+蓝牙连接+Xprint打印机实现打印功能
微信小程序·小程序·notepad++
韩召华10 小时前
微信小程序实现拉卡拉支付
微信小程序·小程序
花伤情犹在11 小时前
uView UI 在 UniApp 中的集成与配置
uni-app·view design