在获取授权之前应先获取授权设置 wx.getSetting ,
获取结果 res.authSetting[‘scope.userInfo’],结果为 false,则可以引导用户允许微信获得你的公共信息,用 wx.openSetting() 调起客户端小程序设置界面,用户允许后将获得用户的公共信息 userInfo

小程序用户拒绝授权之后,如何下次进来再次弹出授权

const app = getApp()
Page({

/**

  • 页面的初始数据
    */
    data: {
    imgList: [], // 上传列表
    src: “”, // 上传视频
    },
    onLoad() {
    this.gethref()
    wx.getSetting({
    success(res) {
    console.log(res)
    if (res.authSetting == true) {
    console.log(‘已授权’)
    } else if (res.authSetting[‘scope.userLocation’] == false) {
    console.log(‘wei授权’)
    wx.openSetting({
    success(res) {
    console.log(res.authSetting)
    console.log(‘wei授权’)
    }
    })
    }

    }
    })
    },
    gethref() {
    wx.getLocation({
    type: ‘wgs84’,
    success(res) {
    const latitude = res.latitude
    const longitude = res.longitude
    const speed = res.speed
    const accuracy = res.accuracy
    console.log(res, ‘res’)
    }
    })

}
})

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2021-11-22
  • 2022-01-30
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-05-19
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2021-12-05
  • 2021-04-01
  • 2021-12-05
  • 2021-12-05
相关资源
相似解决方案