罗广辉
2025-10-23 6d009f08368f93713c1ebeca6acde4163042faa4
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
43
44
45
<!-- 新建任务 -->
<template>
  <WebViewPlus v-if="isApp" :src="`${viewUrl}`" @webMessage="onPostMessage"/>
</template>
 
<script setup>
import WebViewPlus from "@/components/WebViewPlus.vue";
 
import {getWebViewUrl} from "@/utils/index.js";
import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
 
// const viewUrl = ref(getWebViewUrl('/addTask'))
const sWebViewRef = ref(null);
const viewUrl = ref('')
 
function onPostMessage(data) {
  if (data.type === 'submitSuccess'){
    uni.switchTab({
      url: '/pages/inspectionTask/index'
    });
  }
}
 
// onLoad( (options) => {
//   console.log(options, '8888')
//   const sns = options.device_sn
//
// });
 
const isApp = ref(false)
onShow(() => {
  isApp.value = true
  let params = {}
  const encodedData = uni.getStorageSync('webview_params')
  params = JSON.parse(decodeURIComponent(encodedData))
  console.log(params, '6666')
  viewUrl.value = getWebViewUrl('/addTask', params)
});
 
onHide(() => {
  isApp.value = false
});
</script>
 
<style lang="scss" scoped></style>