let then = this
uni.chooseLocation({
success: res => {
then.longitude = res.longitude;
then.latitude = res.latitude;
then.formData.Longitude = res.longitude;
then.formData.Latitude = res.latitude;
//为标记点经纬度重新赋值【在data中赋坐标的方式无效】
// then.covers[0].longitude = res.longitude;
// then.covers[0].latitude = res.latitude;
then.formData.Position = res.name
let location = then.latitude + ',' + then.longitude
let params={
'location':location
}
api.getLocations(params).then(res => {
//if (res.Success == true) {
var resObj=JSON.parse(res.Data)
if (res.message ='Success') {
let province = resObj.result.address_component.province //省
let city = resObj.result.address_component.city //市
let district = resObj.result.address_component.district //区
console.log(province)
console.log(city)
console.log(district)
// then.formData.Position = res.data.result.address
then.formData.Province = province
then.formData.city = city
then.region = province + city //所在地区
} else {
console.log(res.errMsg, '解析失败返回的错误信息');
}
//}
})
},
fail: err => {
uni.showToast({
icon: 'none',
title: '获取位置失败'
});
}
});
DCloud_UNI_yuhe
这个是文档错误,应该是4.24
2024-07-23 12:02