56 lines
1.4 KiB
Plaintext
56 lines
1.4 KiB
Plaintext
<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>
|
|
|
|
<web-view :src="src" style="width: 100%; height: 700px;" @message="postMessagefn" @onPostMessage="postMessagefn"></web-view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
src:''
|
|
|
|
}
|
|
},
|
|
onLoad() {
|
|
// 获取当前位置
|
|
this.getlocahost()
|
|
},
|
|
methods:{
|
|
postMessagefn(e){
|
|
uni.setStorageSync('location', e.detail.data);
|
|
uni.navigateBack({})
|
|
console.log(JSON.parse(e.detail.data))
|
|
},
|
|
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)
|
|
console.log(arr)
|
|
|
|
// that.src = 'http://dap?arr='+encodeURIComponent(JSON.stringify(arr))
|
|
that.src = 'http://219.157.255.213:8082?arr='+encodeURIComponent(JSON.stringify(arr))
|
|
},
|
|
fail: function (err) {
|
|
console.log('获取位置失败:', err);
|
|
},
|
|
complete: function () {
|
|
console.log('获取位置完成');
|
|
}
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|