收藏
回答

位置获取授权不弹出,app.json设置permission了,开发者工具都正常

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getlocation 客户端 7.0.4 2.7.1

- 当前 Bug 的表现(可附上截图)





- 预期表现

wx.getLocation({
            type: "wgs84",
            success: function(t) {
              console.log('定位开始');
                wx.setStorageSync("Location", t);
                console.log('这是位置信息'),console.log(t);
                var e = t.latitude + "," + t.longitude;
                app.util.request({
                    url: "entry/wxapp/map",
                    cachetime: "0",
                    data: {
                        op: e
                    },
                    success: function(i) {
                       
                      var status = wx.getStorageSync("langStatus");
                        console.log('这是服务器提供的位置信息'),console.log(i), app.util.request({
                            url: "entry/wxapp/System",
                            cachetime: "0",
                          data: {
                            langType: status
                          },
                            success: function(t) {
                                console.log('这是关于位置信息的系统信息'),console.log(t), "1" == t.data.dw_more && c.setData({
                                    dwcity: i.data.result.address_component.district
                                }), "2" == t.data.dw_more && c.setData({
                                    dwcity: i.data.result.address_component.city
                                });
                                var e = t.data.gd_key;
                                "" == e && wx.showModal({
                                    title: "配置提示",
                                    content: "请在后台配置高德地图的key",
                                    showCancel: !0,
                                    cancelText: "取消",
                                    confirmText: "确定",
                                    success: function(t) {},
                                    fail: function(t) {},
                                    complete: function(t) {}
                                }), new (require("../amap-wx.js").AMapWX)({
                                    key: e
                                }).getWeather({
                                    success: function(t) {
                                      console.log('这是搞的地图提供的位置信息',t);
                                        var e, a, n = t.liveData.city, i = t.liveData.weather, o = t.liveData.reporttime.slice(0, 10), s = (0 == (e = new Date(o)).getDay() && (a = "星期日"),
                                        1 == e.getDay() && (a = "星期一"), 2 == e.getDay() && (a = "星期二"), 3 == e.getDay() && (a = "星期三"),
                                        4 == e.getDay() && (a = "星期四"), 5 == e.getDay() && (a = "星期五"), 6 == e.getDay() && (a = "星期六"),
                                        a), r = t.temperature.data;
                                        c.setData({
                                            area: n,
                                            reporttime: o,
                                            weather: i,
                                            w1: s,
                                            temperature: r
                                        });
                                    },
                                    fail: function(t) {}
                                });
 
                               
                          
       wx.setStorageSync("System", t.data), 1 == t.data.many_city ? (wx.setStorageSync("city", t.data.cityname),
 
 
 
                                  console.log("这是c", c),
                                  console.log('这是城市属性', wx.getStorageSync("city_type")),
                                c.setData({
                                    city: t.data.cityname
                                })) : (console.log('这是城市属性',wx.getStorageSync("city_type")), 1 != wx.getStorageSync("city_type") ? (wx.setStorageSync("city", c.data.dwcity),
                                
                                c.setData({
                                    city: c.data.dwcity
                                    })) : (console.log("这是c", wx.getStorageSync("city")),c.setData({
                                    city: wx.getStorageSync("city")
                                }), console.log("choosecity")));
                                var n = wx.getStorageSync("city");
                                console.log('这是城市名称',n), app.util.request({
                                    url: "entry/wxapp/SaveHotCity",
                                    cachetime: "0",
                                    data: {
                                        cityname: n,
                                        user_id: wx.getStorageSync("users").id
                                    },
                                    success: function(t) {
                                        console.log(t);
                                    }
                                });
                                n = wx.getStorageSync("city");
                                c.setData({
                                    bkarr: a
                                }), c.refresh(), c.seller();
                            }
                        });
                    }
                });
            },
            fail: function(t) {
              
 
       console.log('定位失败',t);
             app.checkPermission();
            }
        }),



//小程序进入首页  权限校验
checkPermission:function (obj){
  console.log("-------------checkPermission----------");
  wx.getSetting({
    success: function (res) {
      if (!res.authSetting['scope.userLocation']) {
        console.log("-------------不满足scope.userLocation权限----------");
        //申请授权
        wx.authorize({
          scope: 'scope.userLocation',
          success() {
          console.log('重新申请定位成功')
          }, fail: function (t) {
            console.log('重新申请定位失败authorize',t)
             
            wx.openSetting({
                         success: function(t) {
                           console.log('这是授权结果',res.authSetting)
                             res.authSetting = {
                                     "scope.userInfo": true,
                                     "scope.userLocation": true
                             }
                        },fail:function(t){
                          console.log('授权结果失败open setting', t)
                        }
                     });
             
            }
             
        })
      }
    }
  })
}

开发者工具里正常,真机调试也正常,预览·开发版·发布版都定位失败,没弹出。设置里面只有用户信息授权选项,我看很多人遇到此类问题,这是代码写错了的问题还是????????????

,
  "permission": {
    "scope.userLocation": {
      "desc": "你的位置信息将用于定位您的家庭地址"
    }
  },


回答关注问题邀请回答
收藏

2 个回答

  • 社区技术运营专员-灵芝
    社区技术运营专员-灵芝
    2019-06-17

    你好,这个问题麻烦用这个版本的开发工具试试:https://developers.weixin.qq.com/miniprogram/dev/devtools/rc.html

    2019-06-17
    赞同
    回复
  • 铭锋科技
    铭锋科技
    2019-06-16

    微信 -> 发现 -> 小程序 最近使用的小程序列表中,把你的小程序所有版本删除(包括体验版、正式版、开发版),然后扫码重试

    2019-06-16
    赞同
    回复 2
    • Flicker
      Flicker
      2019-06-20

      都删了,还是一样。偶尔新上传体验版的时候不弹出但是可以定位,然后再删掉重新进入的时候还是老样子

      2019-06-20
      回复
    •  JJCHAN
      JJCHAN
      2019-06-21回复Flicker

      兄弟,我也一样,解决了没有

      2019-06-21
      回复
登录 后发表内容