wx.getLocation在系统没有打开GPS时不能获取定位

发布于 7 年前作者 yguo15478 次浏览最后编辑 7 年前来自 ask
  • 当前 Bug 的表现(可附上截图)

  • 预期表现

  • 复现路径

  • 提供一个最简复现 Demo

运行环境:HUAWEI Nova2s  Android 8.0

问题: wx.getLocation在系统没有打开GPS时不能获取定位,会执行fail内的内容,打印出:

  1. errCode:2

  2. errMsg:"getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF"

然后在fail内也无法使用wx.showToast打印信息。

代码:

wx.getSetting({
   success(res) {
     console.log(res)
     wx.getLocation({
       success: function (res) {
         console.log(res)
       },fail:function(res){
         console.log(res)
         wx.showToast({
           title: '1111111111111',
         })
       }
     })
   }
 })

已授权,不存在小程序内的权限问题。

小程序没有打开GPS的API吗?

2 回复
nqian
nqian1 楼6 年前

这是个BUG吗?在fail内wx.showToast无法打印出信息,这样在用户没有开GPS的情况下就无法提示,程序功能也无法正常使用,体验极差

jinxiulan
jinxiulan2 楼5 年前

目前只能获取到状态,控制不了

https://developers.weixin.qq.com/miniprogram/dev/api/wx.getSystemInfoSync.html

locationEnabled