chenyao
2025-12-01 08fcc710d0a2acb185b3477d72fe32aff6f2e29a
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!-- 新建任务 -->
<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.setStorageSync('joinParams', {
      type: 'add'
    });
    // console.log('打印新增成功')
    uni.switchTab({
      url: '/pages/inspectionTask/index'
    });
    // uni.redirectTo({
    //   url: `/pages/inspectionTask/index?addLog=1111`
    // });
  }
}
 
// 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))
  viewUrl.value = getWebViewUrl('/addTask', params)
  uni.setTabBarItem({
    index: 3, // Tab
    visible: false,
  });
  uni.setTabBarItem({
    index: 2, // Tab 的索引(从0开始)
    // text: '新建任务',
    visible: true,
    "pagePath": "subPackages/taskDetail/addTask/index"
  });
});
 
onHide(() => {
  isApp.value = false
});
</script>
 
<style lang="scss" scoped></style>