提交代码
This commit is contained in:
1 parent
ccea2c8fb2
commit
5e0af12650
2 files changed
+41
-21
No files matched your search
@@ -928,7 +928,7 @@ export default {
|
||||
const [latStr, lngStr] = this.cancelForm.cancelLocation.split(',');
|
||||
const latitude = parseFloat(latStr);
|
||||
const longitude = parseFloat(lngStr);
|
||||
|
||||
let formattedAddress = '';
|
||||
// 调用后台API进行逆地理编码
|
||||
try {
|
||||
const geocodingResponse = await request({
|
||||
@@ -941,7 +941,7 @@ export default {
|
||||
});
|
||||
|
||||
if (geocodingResponse.code === 200 && geocodingResponse.data) {
|
||||
const formattedAddress = geocodingResponse.data.regeocode?.formattedAddress;
|
||||
formattedAddress = geocodingResponse.data.regeocode?.formattedAddress;
|
||||
if (formattedAddress) {
|
||||
console.log('销假位置逆地理编码成功:', formattedAddress);
|
||||
// 可以选择将地址信息显示给用户或保存到表单中
|
||||
@@ -960,7 +960,8 @@ export default {
|
||||
await this.wechatSDK.openLocation({
|
||||
latitude,
|
||||
longitude,
|
||||
name: formattedAddress,
|
||||
name: formattedAddress || '请假位置',
|
||||
address: formattedAddress || '当前位置',
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -980,7 +981,7 @@ export default {
|
||||
const latitude = parseFloat(latStr);
|
||||
const longitude = parseFloat(lngStr);
|
||||
if (Number.isNaN(latitude) || Number.isNaN(longitude)) return;
|
||||
|
||||
let formattedAddress = '';
|
||||
// 调用后台API进行逆地理编码
|
||||
try {
|
||||
const geocodingResponse = await request({
|
||||
@@ -993,7 +994,7 @@ export default {
|
||||
});
|
||||
|
||||
if (geocodingResponse.code === 200 && geocodingResponse.data) {
|
||||
const formattedAddress = geocodingResponse.data.regeocode?.formattedAddress;
|
||||
formattedAddress = geocodingResponse.data.regeocode?.formattedAddress;
|
||||
if (formattedAddress) {
|
||||
console.log('请假位置逆地理编码成功:', formattedAddress);
|
||||
// 可以选择将地址信息显示给用户或保存到表单中
|
||||
@@ -1012,7 +1013,8 @@ export default {
|
||||
await this.wechatSDK.openLocation({
|
||||
latitude,
|
||||
longitude,
|
||||
name: formattedAddress,
|
||||
name: formattedAddress || '请假位置',
|
||||
address: formattedAddress || '当前位置',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -825,6 +825,10 @@ export default {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 声明变量在外部作用域,确保finally块可以访问
|
||||
let formattedAddress = '';
|
||||
|
||||
// 调用高德sdk 逆地理编码
|
||||
try {
|
||||
// 调用后台API进行逆地理编码
|
||||
@@ -838,11 +842,16 @@ export default {
|
||||
});
|
||||
|
||||
if (geocodingResponse.code === 200 && geocodingResponse.data) {
|
||||
const formattedAddress = geocodingResponse.data.regeocode?.formattedAddress;
|
||||
formattedAddress = geocodingResponse.data.regeocode?.formattedAddress || '';
|
||||
if (formattedAddress) {
|
||||
console.log('逆地理编码成功:', formattedAddress);
|
||||
// 可以选择将地址信息显示给用户或保存到表单中
|
||||
// this.form.leaveLocationAddress = formattedAddress; // 如果需要保存地址信息
|
||||
uni.showToast({
|
||||
title: formattedAddress,
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.warn('逆地理编码失败:', geocodingResponse.msg);
|
||||
@@ -850,23 +859,32 @@ export default {
|
||||
} catch (error) {
|
||||
console.error('逆地理编码请求失败:', error);
|
||||
// 逆地理编码失败不影响地图打开功能
|
||||
}
|
||||
} finally {
|
||||
console.log('=== finally块开始执行 ===');
|
||||
console.log('formattedAddress:', formattedAddress);
|
||||
console.log('isWechatBrowser:', this.isWechatBrowser);
|
||||
console.log('wechatSDK.isInitialized:', this.wechatSDK?.isInitialized);
|
||||
|
||||
if (this.isWechatBrowser && this.wechatSDK.isInitialized) {
|
||||
try {
|
||||
await this.wechatSDK.openLocation({
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
name: formattedAddress,
|
||||
address: this.form.leaveLocation || '当前位置',
|
||||
scale: 16,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('微信地图打开失败:', error);
|
||||
if (this.isWechatBrowser && this.wechatSDK?.isInitialized) {
|
||||
try {
|
||||
console.log('尝试使用微信SDK打开地图...');
|
||||
await this.wechatSDK.openLocation({
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
name: formattedAddress || '请假位置',
|
||||
address: formattedAddress || '当前位置',
|
||||
scale: 16,
|
||||
});
|
||||
console.log('微信地图打开成功');
|
||||
} catch (error) {
|
||||
console.error('微信地图打开失败:', error);
|
||||
this.fallbackOpenMap(latitude, longitude);
|
||||
}
|
||||
} else {
|
||||
console.log('使用备用地图打开方式...');
|
||||
this.fallbackOpenMap(latitude, longitude);
|
||||
}
|
||||
} else {
|
||||
this.fallbackOpenMap(latitude, longitude);
|
||||
console.log('=== finally块执行完成 ===');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user