地图页面 及页面加语言编译
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<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: 100%;" @message="postMessagefn"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
function receiveMessage(event){
|
||||
// console.log(event.data)
|
||||
if(event.data.type){
|
||||
|
||||
}else{
|
||||
uni.setStorageSync('location', event.data);
|
||||
uni.navigateBack({})
|
||||
}
|
||||
|
||||
}
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
src:''
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 获取当前位置
|
||||
this.getlocahost()
|
||||
},
|
||||
methods:{
|
||||
postMessagefn(e){
|
||||
console.log(e)
|
||||
},
|
||||
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://219.157.255.213:8082?arr='+encodeURIComponent(JSON.stringify(arr))
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('获取位置失败:', err);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('获取位置完成');
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user