123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <template>
- <view>
- <web-view src='https://feiniao-mini-h5-dev.sysuimars.cn/youwei/#/gardenMap?userId=91429'
- @message="handleMapEvent"></web-view>
-
- <!-- <web-view src='http://localhost:8081/#/gardenMap?userId=91754&token=034d7cf5-25fc-42d3-993e-460120419e5a'
- @message="handleMapEvent" @onPostMessage="handleHashChange"></web-view> -->
- </view>
- </template>
- <script setup>
- import config from "@/api/config.js"
- import {
- onMounted
- } from 'vue';
- const handleBack = () => {
- uni.navigateBack();
- };
-
- function handleHashChange(e) {
- console.log('handleHashChange', e)
- const hash = e.detail.url.split("#")[1];
- if (hash && hash.startsWith("jump=")) {
- const path = decodeURIComponent(hash.split("=")[1]);
- uni.navigateTo({
- url: path, // 如 "/pages/home/home"
- });
- }
- }
-
- function randomIndexName(){
- const randomNum = Math.floor(Math.random() * 10) + 1; // 生成1到10之间的随机数
- let v = new Date().getTime()
- let filename = `index${randomNum}.html?v=${v}`
- return filename;
- }
- const handleMapEvent = (e) => {
- console.log('地图点击坐标:', e);
- const data = e.detail.data;
- switch (data.type) {
- case 'map-click':
- console.log('地图点击坐标:', data.lat, data.lng);
- break;
- case 'marker-click':
- console.log('标记点点击:', data.markerId);
- break;
- }
- }
- // 动态注入 JS 监听(兼容性方案)
- // onMounted(() => {
- // window.addEventListener('message', (e) => {
- // alert('eee', e.data)
- // if (e.data && e.data.type === 'from-h5') {
- // console.log('H5页面消息2222:', e.data.payload);
- // }
- // });
- // });
- </script>
|