From be4e2d7c2b330c3b8991a0286ea16cc1285b9ec0 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Fri, 08 May 2026 17:47:32 +0800
Subject: [PATCH] feat: 微信小程序支持上传头像

---
 src/pages/map/index.vue |  115 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/src/pages/map/index.vue b/src/pages/map/index.vue
index 7473a20..7c44236 100644
--- a/src/pages/map/index.vue
+++ b/src/pages/map/index.vue
@@ -1,66 +1,89 @@
+
 <template>
   <view class="page-wrap">
-    <web-view
-      ref="sWebViewRef"
-      :src="`${viewUrl}`"
-      @message="onPostMessage"
-      @onPostMessage="onPostMessage"
-    />
+    <WebViewPlus :src="`${viewUrl}`" @webMessage="onPostMessage" />
   </view>
 </template>
 
 <script setup>
-import { useUserStore } from "@/store/index.js";
+import { getWebViewUrl } from "@/utils/index.js";
+import WebViewPlus from "@/components/WebViewPlus.vue";
+import { onHide, onShow } from "@dcloudio/uni-app";
+import {getUserInfo} from "@/api/user/index.js";
 
-const sWebViewRef = ref(null);
-const userStore = useUserStore();
-const viewUrl = `http://192.168.1.194:5174/drone-app-web-view/#/webViewWrapper/defaultMap?params=${JSON.stringify(
-  userStore?.userInfo
-)}`;
+let envParam = "";
+// #ifdef WEB
+envParam = "true";
+// #endif
+// #ifdef APP-PLUS
+envParam = "false";
+// #endif
 
-const onPostMessage = (event) => {
-  // #ifdef APP-PLUS
-  if (event.detail.data[0].type === "scanCode") {
-    scanCode();
+const updateKey = ref(0);
+const viewUrl = computed(() => {
+  return getWebViewUrl("/defaultMap", {
+    isWeb: envParam,
+    updateKey: updateKey.value,
+  });
+});
+
+const onPostMessage = (data) => {
+  // #ifdef MP-WEIXIN
+  if (data.type === "scanCode") {
+  } else if (data.type === "jumpAddWork") {
+  } else if (data.type === "jumpMapNav") {
+    //事件导航
+  } else if (data.type === "workid") {
+    //事件详情
+  }
+  // #endif
+
+  // #ifndef MP-WEIXIN
+  if (data.type === "scanCode") {
+    uni.navigateTo({
+      url: "/subPackages/qrCode/index",
+    });
+  } else if (data.type === "jumpAddWork") {
+    //新建任务
+    const encodedData = encodeURIComponent(JSON.stringify(data.rowItem));
+    uni.setStorageSync("webview_params", encodedData);
+    uni.navigateTo({
+      url: `/subPackages/taskDetail/addTask/index`,
+    });
+  } else if (data.type === "jumpMapNav") {
+    //事件导航
+    uni.navigateTo({
+      url: `/subPackages/workDetail/mapWork/index?currentItem=${data.eventNum}`,
+    });
+  } else if (data.type === "workid") {
+    //事件详情
+    uni.navigateTo({
+      url: `/subPackages/workDetail/index?eventNum=${data.eventNum}`,
+    });
   }
   // #endif
 };
 
-const scanCode = () => {
-  // 只允许通过相机扫码
-  uni.scanCode({
-    onlyFromCamera: true,
-    success: function (res) {
-      console.log("条码类型:" + res.scanType);
-      console.log("条码内容:" + res.result);
+onShow(() => {
+  // 验证一下有没有登录
+  getUserInfo()
 
-      // 获取扫码结果
-      let url = res.result;
-
-      // 跳转到B页面,并传递URL参数
-      uni.navigateTo({
-        url: "/subPackages/browser/index?url=" + encodeURIComponent(url),
-      });
-    },
-    fail: function (err) {
-      console.log("扫码失败:", err);
-      uni.showToast({
-        title: "扫码失败",
-        icon: "none",
-      });
-    },
+  // #ifndef MP-WEIXIN
+  uni.setTabBarItem({
+    index: 2, // Tab 的索引(从0开始)
+    visible: false,
+    pagePath: "subPackages/taskDetail/addTask/index",
   });
-};
-
-onLoad(() => {
-  // #ifdef H5
-  window.addEventListener("message", function (e) {
-    if (e.data.data.type === "scanCode") {
-      scanCode();
-    }
+  uni.setTabBarItem({
+    index: 3, // Tab
+    visible: true,
   });
   // #endif
 });
+
+onHide(() => {
+  updateKey.value = updateKey.value + 1;
+});
 </script>
 
 <style scoped lang="scss">

--
Gitblit v1.9.3