uni.getLocation({
type: 'gcj02',
geocode: true,
success: (res) => {
console.log(res,'当前定位')
this.city=res.address?res.address.city:''
// console.log('getCityCode(this.city)',getCityCode(this.city))
uni.request({
url:'http://www.weather.com.cn/data/sk/'+getCityCode(this.city)+'.html',
method: 'GET',
success: (res2) => {
console.log(res2,'天气')
this.wendu = res2.data.weatherinfo.temp + '°'
},
fail: (e) => {
console.log(e,'e')
this.$refs.uToast.show({
title: '天气加载失败',
type: 'warning'
})
}
})
}
})
![z***@yitiangroup.com.cn](https://img-cdn-tc.dcloud.net.cn/account/identicon/4083f1cf55b1a4a71a4fa1ad04b96675.png)
- 发布:2022-10-17 10:22
- 更新:2023-09-26 14:09
- 阅读:272
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows7
HBuilderX类型: 正式
HBuilderX版本号: 3.5.3
手机系统: iOS
手机系统版本号: iOS 15
手机厂商: 苹果
手机机型: iphone 13pro Max
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.getLocation({
type: 'gcj02',
geocode: true,
success: (res) => {
console.log(res,'当前定位')
this.city=res.address?res.address.city:''
// console.log('getCityCode(this.city)',getCityCode(this.city))
uni.request({
url:'http://www.weather.com.cn/data/sk/'+getCityCode(this.city)+'.html',
method: 'GET',
success: (res2) => {
console.log(res2,'天气')
this.wendu = res2.data.weatherinfo.temp + '°'
},
fail: (e) => {
console.log(e,'e')
this.$refs.uToast.show({
title: '天气加载失败',
type: 'warning'
})
}
})
}
})
uni.getLocation({
type: 'gcj02',
geocode: true,
success: (res) => {
console.log(res,'当前定位')
this.city=res.address?res.address.city:''
// console.log('getCityCode(this.city)',getCityCode(this.city))
uni.request({
url:'http://www.weather.com.cn/data/sk/'+getCityCode(this.city)+'.html',
method: 'GET',
success: (res2) => {
console.log(res2,'天气')
this.wendu = res2.data.weatherinfo.temp + '°'
},
fail: (e) => {
console.log(e,'e')
this.$refs.uToast.show({
title: '天气加载失败',
type: 'warning'
})
}
})
}
})
预期结果:
定位返回address数据
定位返回address数据
实际结果:
定位不返回address数据
定位不返回address数据
bug描述:
在ios系统上运行app ,调用 uni.getloaction后,返回数据没有address,在安卓端正常,
第三方定位key已经配置
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221017/9a63b5f14329c16fea8b7ed38ef5c0ae.jpg)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221017/d7269206c2b42deb21eddcb3db32b0f0.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221017/a9fc134472dc8e9642bb144c5a6ea786.png)