zoukankan      html  css  js  c++  java
  • 小程序调用wx.chooseLocation接口的时候无法获取权限(ios)

    ios手机小程序调用wx.chooseLocation接口的时候,获取权限的时候报authorize:fail:require permission desc这样子的错误,这是由于苹果的安全机制导致需要再app.json加上

    "permission": {
        "scope.userLocation": {
          "desc": "您的位置信息将用于添加收货地址"
        }
      }

    但有时还是无法获取授权,则需要在使用的地方判断是否授权,没有的话则再次提醒用户授权

    chooseLocation:function(){
        let _this = this;
        wx.chooseLocation({
          success(e){
            _this.setData({
              map: e.longitude + ',' + e.latitude,
              addr: e.address
            })
          },
          fail(e){
            wx.showToast({
              title: e.errMsg,
              icon:'none'
            })
          }
        })
      },
      getLocation:function(){
        let _this = this;
        wx.getSetting({
          success(res) {
            // 判断定位的授权
            if (!res.authSetting['scope.userLocation']) {
              wx.authorize({
                scope: 'scope.userLocation',
                success() {
                  _this.chooseLocation();
                },
                fail(errMsg) {
                  wx.showToast({ title: JSON.stringify(errMsg), icon: 'none' }) 
                }
              })
            } else {
              _this.chooseLocation();
            }
          }
        })
      },
  • 相关阅读:
    HDU 2073 无限的路
    HDU 2080 夹角有多大II
    if
    HDU 2094 产生冠军
    HDU 2076 夹角有多大(题目已修改,注意读题)
    HDU 2086 A1 = ?
    HDU 2069 Coin Change
    HDU 2095 find your present (2)
    android常用开发工具的用法
    android安装前期遇到的问题
  • 原文地址:https://www.cnblogs.com/lhj-blog/p/11163872.html
Copyright © 2011-2022 走看看