更新定位

This commit is contained in:
weipengfei 2023-09-21 12:03:54 +08:00
parent 4f5aa895a5
commit 8aa746a65e
2 changed files with 21 additions and 27 deletions

View File

@ -74,7 +74,7 @@
// "appkey_ios" : "0799f37420c0784f1e6cba230a68bdb1", // "appkey_ios" : "0799f37420c0784f1e6cba230a68bdb1",
// "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1", // "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1",
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee", "appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "048d9f3f323eea894b49c3a7edbc8d87" "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
} }
}, },
// "appkey_ios" : "4f8f55618010007147aab96fc72bb408", // "appkey_ios" : "4f8f55618010007147aab96fc72bb408",
@ -83,7 +83,7 @@
"amap" : { "amap" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee", "appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "048d9f3f323eea894b49c3a7edbc8d87" "appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
} }
} }
}, },

View File

@ -165,30 +165,24 @@
// //
locationFn() { locationFn() {
let that = this; let that = this;
// uni.showLoading({ uni.showLoading({
// title: '' title: '获取位置中'
// }) })
uni.sendHostEvent('getLocation', '获取位置', (ret) => { uni.sendHostEvent('getLocation', '获取位置', (ret) => {
uni.$on('uniMP_getLocation', (res) => { uni.$on('uniMP_getLocation', (res) => {
try { try {
that.markers[1].latitude = res.latitude; if(!res.latitude)new Error();
that.markers[1].longitude = res.longitude; that.markers[1].latitude = res.latitude;
that.getDriverLine(); that.markers[1].longitude = res.longitude;
uni.hideLoading(); that.getDriverLine();
uni.showModal({ uni.hideLoading();
title: 'uniMP成功', } catch (e) {
content: JSON.parse(res) uni.hideLoading();
}) Toast('获取位置失败');
} catch (e) { }
Toast('获取位置失败'); })
uni.showModal({ });
title: 'uniMP失败', return ;
content: JSON.parse(e)
})
}
})
});
return ;
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
geocode: true, geocode: true,
@ -198,7 +192,7 @@
that.markers[1].longitude = res.longitude; that.markers[1].longitude = res.longitude;
that.getDriverLine(); that.getDriverLine();
// uni.hideLoading(); // uni.hideLoading();
console.log(res); console.log(res);
uni.showModal({ uni.showModal({
title: '成功', title: '成功',
content: JSON.stringify(res) content: JSON.stringify(res)