请问为什么真机上点击位置权限不跳转当前城市
发布于 6 年前 作者 yong42 17105 次浏览 来自 问答
  • 当前 Bug 的表现

点击获取位置权限同意后还是默认的值,没有改变。。。

  • 预期表现

应该是点击后会自动跳转当前城市,但是不管我是同意还是拒绝后的操作,位置都没变,还是默认值“广州市”,请问这怎么解决?

  • 复现路径

首先最开始是这样的页面

然后点击获取当前位置,出现如下提示页面:

点击确定后,应该出现我所在城市的名字:

在开发者工具上一切都正常,但是真机上面一点击就出现图一那种情况,请问这到底是怎么回事啊?我把代码附上,请帮我检查一下,谢谢

  • 提供一个最简复现 Demo
onTapLocation() {
    if (this.data.locationAuthType === UNAUTHORIZED)
      wx.openSetting()
    else
      this.getLocation()
  },
 
  getLocation () {
    wx.getLocation({
      success: res => {
        this.setData({
          locationAuthType: AUTHORIZED,
        })
        this.qqmapsdk.reverseGeocoder({
          location: {
            latitude: res.latitude,
            longitude: res.longitude
          },
          success: res =>{
            let city = res.result.address_component.city
            this.setData({
              city: city,
              locationTipsText: ""
            })
            this.getNow()
          }
        })
      },
      fail: ()=> {
          this.setData ({
            locationAuthType: UNAUTHORIZED,
          })
        }
    })
  }
})
回到顶部