小程序获取用户地址信息api

前台部分

<view class="address-wraper"><view bindtap="chooseAddress" wx:if="{{user_address_flag}}"><view class="address-mesg flex-container"><view class="mesg-title">收货人</view><view class="mesg-content-p flex-one flex-container flex-between" style="padding-right:60rpx;"><view class="addressee">{{receiver}}</view><view>{{mobile}}</view></view></view><view class="address-mesg flex-container" style="margin-top:9rpx;"><view class="mesg-title">收货地址</view><view class="flex-one mesg-content-p" style="padding-right:60rpx;">{{address}}</view><image class="address-arrow" src="https://try.fishqc.com/img/go.png"/></view></view><!-- 选择地址 --><view wx:if="{{!user_address_flag}}" bindtap="chooseAddress" class="flex-container horizontal-between vertical-center" style="height:80rpx;margin-top:20rpx;"><view class="flex-one choose-address">请点击选择收货地址</view><image style="width:17rpx;height:30rpx;" src="https://try.fishqc.com/img/go.png"/></view>
</view>

css部分

/* 地址 */.address-wraper {padding: 0 30rpx 35rpx;background: #ffffff;margin-bottom: 24rpx;background: #ffffff url(https://buy.fishqc.com/img/address-line.png) no-repeat left bottom;background-size: contain;overflow: hidden;
}.address-mesg {margin-top: 20rpx;position: relative;
}.mesg-title {width: 128rpx;padding-right: 15rpx;font-family: 'PingFangSC-Light';font-size: 28rpx;color: #848a95;letter-spacing: 0;line-height: 40rpx;
}.mesg-content-p {font-family: 'PingFangSC-Light';font-size: 24rpx;color: #2f3736;letter-spacing: 0;line-height: 36rpx;
}.flex-between {justify-content: space-between;-webkit-justify-content: space-between;
}.addressee {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 270rpx;
}.address-arrow {width: 17rpx;height: 30rpx;position: absolute;right: 0;top: 50%;transform: translate(-50%, -50%);-webkit-transform: translate(-50%, -50%);
}.choose-address {min-height: 40rpx;background: url(https://try.fishqc.com/img/address.jpg) no-repeat;background-size: 32rpx 40rpx;padding-left: 50rpx;font-family: 'PingFangSC-Light';font-size: 32rpx;color: #2f3736;letter-spacing: 0;line-height: 40rpx;
}.flex-one {-webkit-box-flex: 1;-webkit-flex: 1;flex: 1;
}.vertical-center {align-items: center;-webkit-align-items: center;
}.horizontal-between {justify-content: space-between;-webkit-justify-content: space-between;
}.flex-container {display:flex;
}

js部分

judgeAuth:function(authStr) {return new Promise((resolve, reject) => {wx.getSetting({success(res) {if (!(authStr in res.authSetting) || res.authSetting[authStr]) {// 同意授权且调用对应api后取消操作resolve(true)} else {// 未同意授权时,打开微信授权设定列表重新尝试获得授权resolve(false)}},fail(err) {reject(err)}})})},chooseAddress: function chooseAddress() {if (this.pay_coundDown_flag) {return;}var that = this;// 先判断是否已经授权this.judgeAuth('scope.address').then(function (isSuccess) {if (isSuccess) {wx.chooseAddress({success: function success(res) {// 賦值that.setData({address: '' + res.provinceName + res.cityName + res.countyName + res.detailInfo,receiver: res.userName,mobile: res.telNumber,   user_address_flag:true})console.log(that.data.address,101010)//缓存收货信息wx.setStorage({key: 'receiver',data: res.userName});wx.setStorage({key: 'mobile',data: res.telNumber});wx.setStorage({key: 'address',data: that.data.address});},fail: function fail() {// that.$parent.toasttips('选择地址失败')}});} else {// 未授权则提醒用户打开授权列表wx.showModal({title: '小鱼提示',content: '请允许我们读取您的通信地址',showCancel: false,success: function success(res) {if (res.confirm) {wx.openSetting({success: function success(res) {if (res.authSetting['scope.address']) {// 使用 call 调用将 this 指向指回 EvaluateCard 类上的原因是,这里直接调用 that.methods 会导致 this 指向 methods// 使其函数重新执行时,上面的this指向全部变为了methodsthat.methods.chooseAddress.call(that);} else {that.$parent.toasttips('选择地址需同意授权');}if (res.confirm) {console.log('用户点击确定')} else if (res.cancel) {console.log('用户点击取消')}},fail: function fail() {that.$parent.toasttips('调用授权列表管理失败');}});}}});}});},

小程序获取用户地址信息api相关推荐

  1. Uniapp实现小程序获取用户微信信息功能

    Uniapp实现小程序获取用户微信信息功能 实现后发现其实这个功能实现起来非常简单,但是,在实现这个功能的过程中真的好多坑啊,可能是我菜吧. 1.获取uniapp的appid和微信小程序的appid, ...

  2. 微信小程序获取用户位置信息并显示到地图上

    1.配置地理位置用途说明 在app.json中的大括号内输入 "permission": {"scope.userLocation": {"desc& ...

  3. 小程序 | 获取用户头像信息接口改进:getUserInfo的使用

    开发小程序过程中,发现最近微信官方新调整了getUserInfo的接口的使用,并发布了一篇<小程序登录.用户信息相关接口调整说明>公告,摸索了一番之后,了解到getUserProfile用 ...

  4. uni-app 对接微信小程序获取用户个人信息和获取用户手机号码

    第一次对接小程序授权的时候以为能一进入这个项目就要调用获取授权信息,后面写好逻辑之后提交审核,一直审核不通过,后面查了原因之后才发现不能一进入页面就调用授权,而且项目需要个人信息和手机号码两个都要获取 ...

  5. 微信小程序获取用户真实信息

    微信在2020年4月13日到4月28日调整了获取用户信息的接口,4月28日24时后发布的新版本小程序就获取不到用户的真实信息了 附上原文链接:微信用户信息接口调整 注意事项: 调用wx.getUser ...

  6. 微信小程序—获取用户位置信息

    一.使用 wx.getLocation 获取经纬度信息 1.1 在 app.json 中加入如下配置 "permission": {"scope.userLocation ...

  7. 微信小程序获取用户简要信息

    因为项目的需要,研究了一下微信获取用户的简单信息,在过程中耗费了许多的时间,想发出来与大家一起分享学习,有大牛看到不足的地方也希望大家指教! 小程序: var utils = require(&quo ...

  8. Java微信授权小程序获取用户手机号信息

    注意:目前该接口针对非个人开发者,且完成了认证的小程序开放(不包含海外主体).需谨慎使用,若用户举报较多或被发现在不必要场景下使用,微信有权永久回收该小程序的该接口权限. 官网地址如下: https: ...

  9. 微信小程序获取用户位置信息

    1.在 app.json 里面增加 permission 属性配置小程序配置 | 微信开放文档 "permission": {"scope.userLocation&qu ...

最新文章

  1. css中调整高度充满_CSS(十三).高度如何铺满全屏
  2. java专业编码_java编码中的坑(记一次解决编码BUG的经历) - 贪吃蛇学院-专业IT技术平台...
  3. python 类-Python中的类
  4. C语言程序可以没有main函数
  5. Win32汇编ListBox最简Demo
  6. 计算机基础知识菜鸟教程,机器学习基础知识整理归纳
  7. bind1st bind2nd的使用
  8. 这样准备,面试成功率提升30%
  9. oracle日期相减工作日_oracle 日期相减 转载
  10. Sql loader使用教程
  11. 苹果ipad8和ipad9的区别
  12. 5个简单的游戏设计技巧,让你的游戏更有趣
  13. UART嵌入式通信协议(以AVR单片机为例)
  14. 开源RapidScada插件开发---短信报警插件
  15. 小米路由r2d论坛_小米路由R2D,拼夕夕翻车了没
  16. 论文复现-1:Perturbation CheckLists for Evaluating NLG Evaluation Metrics
  17. 计算 11+12+13+...+m python
  18. STM8S自学笔记之利用库函数点亮一个LED
  19. 恢复微信撤回的图片(不容root,极其简单)
  20. 从键盘上输入两个字符串,将两个字符串首尾相连接后,再输出新的字符串(c语言)

热门文章

  1. php字符串转二进制数组中,如何将php字符串转成二进制
  2. 泛型 (Generics)一定是最易懂简单的
  3. 构建官方CoreOS COSA 镜像并构建 CoreOS
  4. KVM Virtual Networking Concepts
  5. 8086和8088微处理器之间的区别
  6. Linux IO复用:select、poll、epoll的理解与对比
  7. .net pdf转图片_在客户端实现PDF转图片
  8. 秋风秋雨愁煞人:寒宵独坐心如捣
  9. Springboot细节挖掘(对web的支持之数据校验)
  10. mac pycharm 卸载_Mac上Virtual Box虚拟机Linux系统安装