用户拒绝授权定位信息的

在使用wx.getLocation请求位置时,一旦用户明确同意或拒绝过授权,其授权关系会记录在后台,直到用户主动删除小程序,

如果用授权后,可以通过调用wx.openSetting,打开设置页。

<view class="img-box">
      <image wx:if="{{QrCode}}" src="{{QrCode}}" bindtap="getRefresh" style="width: 100%;height: 100%;"></image>
      <view wx:else class="img-box-text" >
         <text>{{ResultMsg}}</text>
         <view bindtap="getRefresh">重新获取</view>
      </view>
    </view>
  //获取位置
  locationFunc(){
    var that = this
    wx.getLocation({
      type: 'wgs84',
      success (res) {
        console.log('位置',res)
        that.setData({
          longitude: res.longitude,
          latitude: res.latitude
        })
        //请求接口
        that.GetMemberCodeV2()
      },
      fail(err) {
        console.log(err)
         // 第一次拒绝后,下次点击提示打开设置授权弹窗
        wx.showModal({
          title:'定位获取失败',
          content:'会员码将无法生成,是否去设置授权打开?',
          success(res){
            if (res.confirm) {
              wx.openSetting({
                success: (res) => { 
                  console.log(res,"授权打开定位信息")
                }
              })
            } else if (res.cancel) {
              console.log('用户点击取消')
              that.setData({
                ResultMsg:'定位不成功,会员码获取失败'
              })
            }
          }
        })
      }
      })
  },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值