2023-12-14 16:44:35 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
|
|
|
|
|
<block slot="backText">返回</block>
|
|
|
|
|
<block slot="content">位置定位</block>
|
|
|
|
|
</cu-custom>
|
|
|
|
|
<web-view id="webview" :src="url" @message="messageChange"></web-view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
2024-01-26 11:12:16 +08:00
|
|
|
|
import gcoord from '@/components/gcoord.js'
|
|
|
|
|
|
2023-12-14 16:44:35 +08:00
|
|
|
|
export default {
|
|
|
|
|
components: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
url: '',
|
|
|
|
|
longitude: '',
|
|
|
|
|
latitude: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-01-26 11:12:16 +08:00
|
|
|
|
async onLoad(option) {
|
|
|
|
|
// this.longitude = 119.67751
|
|
|
|
|
// this.latitude = 39.92596
|
|
|
|
|
var userWeizhi = await this.getUserAppZuobiao()
|
|
|
|
|
this.longitude = userWeizhi[0]
|
|
|
|
|
this.latitude = userWeizhi[1]
|
2023-12-14 16:44:35 +08:00
|
|
|
|
this.init();
|
|
|
|
|
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
|
|
|
|
|
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
|
|
|
|
|
eventChannel.on('acceptDataFromOpenerPage', function (data) {
|
|
|
|
|
console.log(data)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onBackPress(options) {
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onUnload() {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
goBack() {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
saveData() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
init() {
|
2024-01-26 11:12:16 +08:00
|
|
|
|
this.url = ('/hybrid/html/newMap.html?longitude=' + this.longitude + '&latitude=' + this.latitude + 't=' + new Date().getTime());
|
2023-12-14 16:44:35 +08:00
|
|
|
|
console.log(this.url);
|
|
|
|
|
},
|
|
|
|
|
messageChange(e) {
|
|
|
|
|
console.log("messageChange");
|
|
|
|
|
console.log(e);
|
|
|
|
|
uni.setStorageSync("info", e.detail.data[0]);
|
|
|
|
|
const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
|
|
|
|
|
console.log(eventChannel)
|
|
|
|
|
eventChannel.emit('acceptDataFromOpenedPage', {data: e.detail.data[0]});
|
|
|
|
|
uni.navigateBack();
|
2024-01-26 11:12:16 +08:00
|
|
|
|
},
|
|
|
|
|
getUserAppZuobiao() { //获取手机坐标信息
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
uni.getLocation({
|
|
|
|
|
type: 'GCJ02',
|
|
|
|
|
success: function (res1) {
|
|
|
|
|
this.longitude = res1.longitude;
|
|
|
|
|
this.latitude = res1.latitude;
|
|
|
|
|
var result = gcoord.transform(
|
|
|
|
|
[this.longitude, this.latitude], // 经纬度坐标
|
|
|
|
|
gcoord.GCJ02, // 当前坐标系
|
|
|
|
|
gcoord.BD09 // 目标坐标系
|
|
|
|
|
);
|
|
|
|
|
resolve(result);
|
|
|
|
|
},
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: "获取位置失败",
|
|
|
|
|
duration: 2000
|
|
|
|
|
});
|
|
|
|
|
reject(['119.67751', '39.92596']);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
2023-12-14 16:44:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
page,
|
|
|
|
|
uni-page-body,
|
|
|
|
|
.container {
|
|
|
|
|
background: rgba(245, 245, 245, 1);
|
|
|
|
|
min-height: calc(100%);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|