账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    webapp使用微信定位api,安卓机上出现getLocation:timeout
    48
    0

    安卓机,切换路由,在componentWillMount中发起ajax请求,向后台所有签名数据,然后使用wx.config进行签名,

      window.wx.config({
        debug: true,
        appId: _config.appId,
        timestamp: _config.timestamp,
        nonceStr: _config.nonceStr,
        signature: _config.signature,
        jsApiList: ['getLocation', 'openLocation', 'chooseWXPay'],
      })
      window.wx.ready(() => {
        const loading = weui.loading('定位中')
        window.wx.getLocation({
          type: 'wgs84',
          timeout: 2000,
          success: (res) => {
            console.log(res)
          },
          fail: (err) => {
            console.log(err)
            weui.alert('定位失败,请刷新页面重试')
          },
          complete: () => {
            loading.hide()
          },
        })
      })

    然而安卓机在退出路由再进退出再进时,偶尔会出现getLocation:timeout,也就是直接fail了,不知道为什么,求助

    1
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部