|
|
@@ -15,7 +15,7 @@
|
|
|
</n-layout-sider> -->
|
|
|
<n-layout-content content-style="padding: 0px;">
|
|
|
<iframe
|
|
|
- v-if="isOK"
|
|
|
+ v-if="isOK && isGetToken"
|
|
|
id="mainFrame"
|
|
|
class="main-frame"
|
|
|
:src="iframeURL"
|
|
|
@@ -26,7 +26,7 @@
|
|
|
title=""
|
|
|
size="huge"
|
|
|
class="page-result"
|
|
|
- v-else
|
|
|
+ v-else-if="!isOK && isGetToken"
|
|
|
description="带看已结束"
|
|
|
>
|
|
|
<template #icon>
|
|
|
@@ -63,10 +63,13 @@ import {
|
|
|
} from "naive-ui";
|
|
|
import { onMounted, ref, computed } from "vue";
|
|
|
import { useUrlSearchParams } from "@vueuse/core";
|
|
|
-import { getRoomInfo, dimissMissRoom } from "./http.ts";
|
|
|
+import { getRoomInfo, dimissMissRoom, getSyncSceneInfo, login } from "./http.ts";
|
|
|
+import { encodeStr } from './encodeUtil.ts';
|
|
|
import EndPng from "./assets/end.png";
|
|
|
+import { Base64 } from './base64';
|
|
|
// import sceneList from "./components/sceneList.vue";
|
|
|
const isOK = ref(true);
|
|
|
+const isGetToken = ref(false);
|
|
|
// const iframe = ref(
|
|
|
// "https://127.0.0.1:6100/livestream/?vruserId=066893f525e56f09ce8b4420dff7e068&roomId=fd_22253&role=leader&avatar=https%3A%2F%2F4dkk.4dage.com%2Ftake-look%2Fimages%2Fother%2F1573b607db124917804edfaf1887df7a.jpeg&name=Gemer1&isTour=0&m=KJ-t-wOXfx2SDFy&vlog=1"
|
|
|
// );
|
|
|
@@ -81,28 +84,43 @@ interface needParams {
|
|
|
vruserId: string;
|
|
|
fromMiniApp?: number;
|
|
|
redirect?: string;
|
|
|
+ token?: any,
|
|
|
t?: string;
|
|
|
+ u?: string;
|
|
|
+ p?: string;
|
|
|
}
|
|
|
const params: needParams = useUrlSearchParams("history");
|
|
|
+console.log('params111111:', params);
|
|
|
const searchParams = new URLSearchParams(
|
|
|
Object.assign({ platform: "fd" }, params ? params : {})
|
|
|
);
|
|
|
const iframeDomain = import.meta.env.VITE_APP_IFRAME_URL;
|
|
|
|
|
|
let url = searchParams.toString();
|
|
|
-
|
|
|
const iframeURL = computed(() => {
|
|
|
+ const roomId = params.roomId;
|
|
|
+ const token = params.token;
|
|
|
+ const redirect = params.redirect;
|
|
|
searchParams.set("fromMiniApp", "0");
|
|
|
searchParams.set("isTour", "0");
|
|
|
searchParams.set("t", `${Date.now()}`);
|
|
|
+ if (roomId) {
|
|
|
+ searchParams.set("roomId", roomId);
|
|
|
+ }
|
|
|
+ if (token) {
|
|
|
+ searchParams.set("token", token);
|
|
|
+ }
|
|
|
+ if (redirect) {
|
|
|
+ searchParams.set("redirect", redirect);
|
|
|
+ }
|
|
|
url = searchParams.toString();
|
|
|
// searchParams.delete("redirect");
|
|
|
return iframeDomain + "?" + url;
|
|
|
});
|
|
|
|
|
|
-if (!params.m || !params.role || !params.roomId) {
|
|
|
- isOK.value = false;
|
|
|
-}
|
|
|
+// if (!params.m || !params.role || !params.roomId) {
|
|
|
+// isOK.value = false;
|
|
|
+// }
|
|
|
|
|
|
const themes: Record<string, GlobalTheme> = {
|
|
|
dark: darkTheme,
|
|
|
@@ -130,9 +148,10 @@ const getIframeMessage = async (event: MessageEvent) => {
|
|
|
handlerredirect();
|
|
|
}
|
|
|
if (type === "fillName") {
|
|
|
- console.error("填写后", data);
|
|
|
+ console.error("填写后", data, params.token);
|
|
|
searchParams.set("name", data.name);
|
|
|
searchParams.set("vruserId", data.userId);
|
|
|
+ searchParams.set("token", params.token);
|
|
|
url = searchParams.toString();
|
|
|
const reloadURL = location.origin + location.pathname + "?" + url;
|
|
|
history.replaceState(null, "", reloadURL);
|
|
|
@@ -169,16 +188,61 @@ onMounted(async () => {
|
|
|
frameEle.addEventListener("load", loadFrame, true);
|
|
|
}
|
|
|
window.addEventListener("message", getIframeMessage, false);
|
|
|
- const res = await getRoomInfo(params.roomId);
|
|
|
- if (res && res.data.code === 0) {
|
|
|
- console.log("res", res.data.data);
|
|
|
- const { roomStatus } = res.data.data;
|
|
|
- console.log("当前房间状态::", roomStatus);
|
|
|
- if (roomStatus === 2 && params.role !== "leader") {
|
|
|
+ // 获取登录token
|
|
|
+ isOK.value = false;
|
|
|
+ if (!params.redirect && params.m) {
|
|
|
+ let redirect = '';
|
|
|
+ if(window.location.origin.includes("localhost")){
|
|
|
+ redirect = "http://192.168.0.125:1804/spg.html?m=" + params.m
|
|
|
+ } else {
|
|
|
+ redirect = window.location.origin + "/spg.html?m=" + params.m
|
|
|
+ }
|
|
|
+ params.redirect = redirect;
|
|
|
+ searchParams.set("redirect", redirect);
|
|
|
+ }
|
|
|
+ if(params.token) {
|
|
|
+ searchParams.set("token", params.token);
|
|
|
+ }
|
|
|
+ if(params.u && params.p && !params.token) {
|
|
|
+ console.log('params.u:', decodeURIComponent(params.u));
|
|
|
+ const orginU = Base64.decode(decodeURIComponent(params.u).replace(/ /g, '+'));
|
|
|
+ const orginP = Base64.decode(decodeURIComponent(params.p).replace(/ /g, '+'));
|
|
|
+ console.log('orginU:', orginU);
|
|
|
+ console.log('orginP:', orginP);
|
|
|
+ const res = await login(orginU, encodeStr(window.btoa(orginP)));
|
|
|
+ if (res && res.data && res.data.code === 0) {
|
|
|
+ params.token = res.data.data.token;
|
|
|
+ searchParams.set("token", res.data.data.token);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取房间id
|
|
|
+ if (!params.roomId) {
|
|
|
+ const scene = await getSyncSceneInfo(params.token);
|
|
|
+ if (scene && scene.data && scene.data.code === 0) {
|
|
|
+ params.roomId = scene.data.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ const res = await getRoomInfo(params.roomId);
|
|
|
+ if (res && res.data.code === 0) {
|
|
|
+ const { roomStatus } = res.data.data;
|
|
|
+ console.log("当前房间状态::", roomStatus);
|
|
|
+ isOK.value = true
|
|
|
+ isGetToken.value = true
|
|
|
+ if (roomStatus === 2 && params.role !== "leader") {
|
|
|
+ isGetToken.value = true
|
|
|
+ isOK.value = false;
|
|
|
+ }
|
|
|
+ } else if(res.data.code == 4008 && params.role) {
|
|
|
+ params.token = '';
|
|
|
+ isOK.value = true;
|
|
|
+ isGetToken.value = true;
|
|
|
+ } else {
|
|
|
isOK.value = false;
|
|
|
+ isGetToken.value = true
|
|
|
}
|
|
|
- } else {
|
|
|
- isOK.value = false;
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error, 8888)
|
|
|
}
|
|
|
});
|
|
|
</script>
|