罗广辉
2025-10-13 c1b33671b42e5d2d11f0c8a0fea31bfbe0b35b38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<template>
  <view class="page-wrap">
    <web-view
      ref="sWebViewRef"
      :src='`${viewUrl}?token=${token}&wayLineJodInfoId=${active.id}`'
      @message="onPostMessage"
      @onPostMessage="onPostMessage"
    />
  </view>
</template>
 
<script setup>
import {onLoad} from "@dcloudio/uni-app";
import {useUserStore} from "@/store/index.js";
 
const active = defineModel('active')
const sWebViewRef = ref(null)
const viewUrl = 'http://192.168.1.15:5173/drone-app-web-view/#/appTaskDetails'
const userStore = useUserStore()
const token = computed(() => userStore?.userInfo?.access_token)
 
function onPostMessage(event) {
  if (event.detail.data[0].type === 'back') {
    active.value = null
  }
}
 
onLoad(() => {
  window.addEventListener('message', function (e) {
    if (e.data.data.type === 'back') {
      active.value = null
    }
  });
})
 
</script>
 
<style scoped lang="scss">
.page-wrap {
  font-size: 20px;
}
</style>