收藏
回答

wx.getLocation 获取定位超时?

wx.getLocation({
    type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
    isHighAccuracy:true,
    highAccuracyExpireTime:5000,
    success: function (res) {
      console.log(res,'getLocation返回的信息')
    
       
        let latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
        let longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
        var speed = res.speed; // 速度,以米/每秒计
        var accuracy = res.accuracy; // 位置精度

     
        }).catch(err => {
            console.log(err.response?.data?.error?.message || err.message);
            showToast({
                message: '打卡失败',
                type: 'fail',
                duration: 1000
            });
        });
    },
    cancel: function (res) {
     
        alert("用户拒绝授权获取地理位置");
    },
    fail: function (res) {
     
        console.error('获取位置失败', res);
        showToast({
            message: '获取位置失败,请检查定位权限',
            type: 'fail',
            duration: 2000
        });
    }
});

机型: 华为mate70Pro,系统 鸿蒙4.3,网络信号满格,位置权限正常开启,SDK正常配置,用户已授权,之前一直能正常调用wx.getLocation,
但从今天早上开始调用wx.getLocation一直显示getLocation:timeout。


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

2 个回答

  • #8599A1
    #8599A1
    2025-12-19

    微信版本为8.0.66

    2025-12-19
    有用
    回复 1
    • #8599A1
      #8599A1
      2025-12-19
      重启后能正常调用wx.getLocation了
      2025-12-19
      回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-12-19
    有用
登录 后发表内容