52 lines
1.0 KiB
Vue
52 lines
1.0 KiB
Vue
<template>
|
|
<web-view :src="url" @message="fnMessage"></web-view>
|
|
</template>
|
|
|
|
<script>
|
|
import gcoord from '../../utils/gcoord.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
url: '',
|
|
longitude: '',
|
|
latitude: ''
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
uni.getLocation({
|
|
type: 'GCJ02',
|
|
success: (res) => {
|
|
var result = gcoord.transform(
|
|
[res.longitude, res.latitude],
|
|
gcoord.GCJ02,
|
|
gcoord.BD09
|
|
);
|
|
this.longitude = result[0]
|
|
this.latitude = result[1]
|
|
this.fnInitMapUrl();
|
|
},
|
|
fail: () => {
|
|
uni.showToast({
|
|
title: "获取位置失败",
|
|
});
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
fnInitMapUrl() {
|
|
this.url = ('/hybrid/html/map.html?longitude=' + this.longitude + '&latitude=' + this.latitude + 't=' +
|
|
new Date().getTime());
|
|
},
|
|
fnMessage(event) {
|
|
const eventChannel = this.getOpenerEventChannel();
|
|
eventChannel.emit('acceptLocationData', {
|
|
data: event.detail.data[0]
|
|
});
|
|
uni.navigateBack();
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style> |