6 changed files with 71 additions and 9 deletions
@ -0,0 +1,49 @@ |
|||||
|
<template> |
||||
|
<van-action-sheet v-model="show" title="选择发生地点"> |
||||
|
<div class="content"> |
||||
|
<iframe |
||||
|
id="mapPage" |
||||
|
frameborder="0" |
||||
|
height="100%" |
||||
|
:src="`https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${mapKey}&referer=myapp`" |
||||
|
width="100%" |
||||
|
></iframe> |
||||
|
</div> |
||||
|
</van-action-sheet> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
var loc |
||||
|
import { mapKey } from "@/config" |
||||
|
export default { |
||||
|
name: 'index', |
||||
|
data() { |
||||
|
return { |
||||
|
show: false, |
||||
|
mapKey: mapKey |
||||
|
} |
||||
|
}, |
||||
|
mounted() { |
||||
|
window.addEventListener( |
||||
|
'message', |
||||
|
event => { |
||||
|
loc = event.data |
||||
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息 |
||||
|
if (loc && loc.module == 'locationPicker') { |
||||
|
//防止其他应用也会向该页面post信息,需判断module是否为'locationPicker' |
||||
|
console.log('location', loc) |
||||
|
this.show = false |
||||
|
this.$emit('locationChange', loc) |
||||
|
} |
||||
|
}, |
||||
|
false |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.content { |
||||
|
height: 80vh; |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue