s***@163.com
s***@163.com
  • 发布:2024-07-25 13:42
  • 更新:2024-07-25 13:42
  • 阅读:231

【报Bug】uni.getLocation的wgs84加载太慢

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 1

HBuilderX类型: 正式

HBuilderX版本号: 3.98

手机系统: Android

手机系统版本号: Android 14

手机厂商: 三星

手机机型: 三星

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
    uni.getLocation({  
        type: 'wgs84',  
        success: function (res) {  
            console.log('当前位置',res)  
            // 是否需要设置 token  
            const isToken = (config.headers || {}).isToken === false  
            config.header = config.header || {}  
            config.header['Accept'] ='application/json'  
            // console.log('getToken',getToken(),isToken)  
            if (getToken() && !isToken) {  
                 config.header['Authorization'] ='Bearer '+getToken()  
            }  
            config.header['lat'] =res.latitude  
            config.header['lon'] =res.longitude  
            toast(JSON.stringify(res) )  
            // console.log('config.header',config.header)  
            // get请求映射params参数  
            if (config.params) {  
                let url = config.url + '?' + tansParams(config.params)  
                url = url.slice(0, -1)  
                config.url = url  
            }  

            uni.request({  
                    method: config.method || 'get',  
                    timeout: config.timeout || timeout,  
                    url: config.baseUrl || baseUrl + config.url,  
                    data: config.data || {},  
                    header: config.header,  
                    dataType: 'json'  
                }).then(response => {  

                    let {data,errMsg} = response  
                    const code = data.code || 0  
                    const msg = errorCode[code] || data.msg || errorCode['default']  
                    if (code == 10000) {  
                        uni.navigateTo({  
                            url:`/pages/my/login`  
                        })  

                    }else if(code !== 0 && code !== 10000 ){             
                        if (config.showErrorMsg !== false) toast(msg)  
                        reject(code)  
                    }  
                    if (code == 0 && code !== 10000 ) {  
                        resolve(data)  
                    }  

                })  
                .catch(error => {  
                    let { msg } = error  
                    toast(msg)  
                    reject(error)  
                })  
        },  
        fail: function (err) {  
            console.log(err)  
        }  
    });

操作步骤:

每次加载接口的时候

预期结果:

希望获取定位快点

实际结果:

希望获取定位快点

bug描述:

在安卓手机打开定位反应很慢 我需要把接口放在请求头中,每个接口都需要获取实时定位,这样的话反应不过来导致接口就加载不出来

2024-07-25 13:42 负责人:无 分享
已邀请:

要回复问题请先登录注册