wx.openSetting方法在发布版下无法跳转设置页面,求解
发布于 6 年前 作者 plai 10011 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

相同的代码在体验版中测试点击定位事件后可以跳转到打开权限设置页面,但是发布后到版本点击无任何响应,求解

  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

定义一个locationUtil.js,添加以下方法,并在页面添加点击事件 (这里我用的是view的catchtap事件),调用该定位方法

const getLocation = (suceess,fail) => {

  if (wx.getLocation) {

    wx.getLocation({

      type: ‘gcj02’,

      success: function (res) {

        suceess(res);

      },

      fail: function (res) {

        wx.getSetting({

          success(res) {

            console.log(res);

            if (!res.authSetting[‘scope.userLocation’]) {

              wx.openSetting({

              })

            } else {

              //打开选择地址

              wx.getLocation({

                type: ‘gcj02’,

                success: function (res) {

                  suceess(res);

                }

              })

            }

          },

          fail(res) {

            fail(res);

          }

        })

      }

    })

  }else {

    fail(“不支持定位”);

  }

}

module.exports = {

getLocation: getLocation

}

1 回复

需要用户点击触发

回到顶部