Files
crm-uni/pages/customer/map.nvue
T

56 lines
1.4 KiB
Plaintext
Raw Normal View History

2025-03-19 15:39:21 +08:00
<template>
<view>
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="map"></uni-nav-bar>
2025-03-20 10:58:04 +08:00
<web-view :src="src" style="width: 100%; height: 700px;" @message="postMessagefn" @onPostMessage="postMessagefn"></web-view>
2025-03-19 15:39:21 +08:00
</view>
</template>
<script>
export default {
data() {
return {
src:''
}
},
onLoad() {
// 获取当前位置
this.getlocahost()
},
methods:{
postMessagefn(e){
2025-03-19 16:45:55 +08:00
uni.setStorageSync('location', e.detail.data);
uni.navigateBack({})
2025-06-09 17:58:22 +08:00
// console.log(JSON.parse(e.detail.data))
2025-03-19 15:39:21 +08:00
},
leftClick(){
uni.navigateBack({})
},
// 获取当前位置
getlocahost(){
var that = this;
uni.getLocation({
type: 'wgs84', // 默认为 wgs84 坐标系,可选 gcj02
success: function (res) {
var obj={}
obj.lng=res.longitude
obj.lat=res.latitude
var arr=[]
arr.push(obj)
2025-06-09 17:58:22 +08:00
// console.log(arr)
2025-03-19 15:39:21 +08:00
2025-03-20 17:35:53 +08:00
// that.src = 'http://dap?arr='+encodeURIComponent(JSON.stringify(arr))
2025-03-19 15:39:21 +08:00
that.src = 'http://219.157.255.213:8082?arr='+encodeURIComponent(JSON.stringify(arr))
},
fail: function (err) {
2025-06-09 17:58:22 +08:00
// console.log('获取位置失败:', err);
2025-03-19 15:39:21 +08:00
},
complete: function () {
2025-06-09 17:58:22 +08:00
// console.log('获取位置完成');
2025-03-19 15:39:21 +08:00
}
})
},
},
}
</script>