From 32febb140d320b35d580c8d4e78a80ef846e75fc Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 19 Dec 2025 15:59:34 +0800
Subject: [PATCH] feat:webview通信处理

---
 src/subPackages/taskDetail/execution/index.vue |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/subPackages/taskDetail/execution/index.vue b/src/subPackages/taskDetail/execution/index.vue
index 957529d..2d6071c 100644
--- a/src/subPackages/taskDetail/execution/index.vue
+++ b/src/subPackages/taskDetail/execution/index.vue
@@ -1,14 +1,16 @@
 <!-- 已执行 -->
 <template>
-  <WebViewPlus :src="`${viewUrl}`"/>
+  <WebViewPlus v-if="isApp" :src="`${viewUrl}`" @webMessage="onPostMessage"/>
 </template>
 
 <script setup>
-import {onLoad} from "@dcloudio/uni-app";
+import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
 import WebViewPlus from "@/components/WebViewPlus.vue";
 import {getWebViewUrl} from "@/utils/index.js";
 
-const viewUrl = ref(getWebViewUrl('/execution'))
+const wayLineJobInfoId = ref(null)
+const viewUrl = ref('')
+// const viewUrl = ref(getWebViewUrl('/execution'))
 
 // function onPostMessage(data) {
 //   console.log(data, '9999')
@@ -19,6 +21,35 @@
 //     });
 //   }
 // }
+function onPostMessage(data) {
+  if (data.type === 'back') {
+    uni.switchTab({
+      url: '/pages/inspectionTask/index'
+    });
+  } else if (data.type === 'control') {
+    uni.redirectTo({
+      url: `/pages/inspectionTask/execution/index?wayLineJobInfoId=${wayLineJobInfoId.value}`
+    });
+  } else if(data.type === 'workid') {
+    uni.navigateTo({
+      url: `/subPackages/workDetail/index?eventNum=${data.eventNum}&wLJobInfoId=${data.wLJobInfoId}`
+    });
+  }
+}
+
+onLoad((options) => {
+  wayLineJobInfoId.value = options.wayLineJobInfoId
+  viewUrl.value = getWebViewUrl('/execution', {wayLineJobInfoId: wayLineJobInfoId.value, waylineJobId: options.waylineJobId, batch_no: options.batch_no})
+})
+const isApp = ref(false)
+onShow(() => {
+  isApp.value = true
+});
+
+onHide(() => {
+  // 如果工单详情返回任务详情,那么tab栏对应的是关联事件一项
+  // isApp.value = false
+});
 </script>
 
 <style lang="scss" scoped></style>

--
Gitblit v1.9.3