gemercheung 1 anno fa
parent
commit
c5c804ac03
1 ha cambiato i file con 33 aggiunte e 18 eliminazioni
  1. 33 18
      src/App.vue

+ 33 - 18
src/App.vue

@@ -68,6 +68,7 @@ interface needParams {
   vruserId: string;
   fromMiniApp?: number;
   redirect?: string;
+  t?: string;
 }
 const params: needParams = useUrlSearchParams("history");
 const searchParams = new URLSearchParams(
@@ -80,6 +81,8 @@ let url = searchParams.toString();
 const iframeURL = computed(() => {
   searchParams.set("fromMiniApp", "0");
   searchParams.set("isTour", "0");
+  searchParams.set("t", `${Date.now()}`);
+  url = searchParams.toString();
   // searchParams.delete("redirect");
   return iframeDomain + "?" + url;
 });
@@ -108,32 +111,44 @@ const getIframeMessage = async (event: MessageEvent) => {
     }
     if (type === "exit") {
       console.log("火调退出");
-      if (params.role === "leader") {
-        const redirect = decodeURIComponent(
-          decodeURIComponent(params.redirect || "")
-        );
-        //解散房间 ----
-        const res = await dimissMissRoom(params.roomId);
-        if (res && res.data && res.data.code === 0) {
-          setTimeout(() => {
-            window.location.href = redirect;
-          }, 500);
-        } else {
-          isOK.value = false;
-        }
-      } else {
-        isOK.value = false;
-        window.location.search = "";
-      }
+      handlerExit();
+    }
+    if (type === "redirect") {
+      handlerredirect();
     }
     if (type === "fillName") {
-      searchParams.set("name", data);
+      console.error("填写后", data);
+      searchParams.set("name", data.name);
+      searchParams.set("vruserId", data.userId);
       url = searchParams.toString();
       const reloadURL = location.origin + location.pathname + "?" + url;
       history.replaceState(null, "", reloadURL);
     }
   }
 };
+const handlerExit = async () => {
+  if (params.role === "leader") {
+    const res = await dimissMissRoom(params.roomId);
+    if (res && res.data && res.data.code === 0) {
+      // setTimeout(() => {
+      //   handlerredirect();
+      // }, 500);
+    }
+  }
+};
+const handlerredirect = () => {
+  console.error("收到跳转");
+  if (params.role === "leader") {
+    const redirect = decodeURIComponent(
+      decodeURIComponent(params.redirect || "")
+    );
+    window.location.href = redirect;
+    // isOK.value = false;
+  } else {
+    isOK.value = false;
+    window.location.search = "";
+  }
+};
 
 onMounted(async () => {
   const frameEle = document.getElementById("mainFrame");