|
@@ -1,10 +1,14 @@
|
|
|
import { appConstant } from "@/app";
|
|
|
-import { SceneTypeDomain, SceneTypePaths } from "@/constant/scene";
|
|
|
+import {
|
|
|
+ SceneTypeDesc,
|
|
|
+ SceneTypeDomain,
|
|
|
+ SceneTypePaths,
|
|
|
+} from "@/constant/scene";
|
|
|
import { alert } from "@/helper/message";
|
|
|
-import { getCaseSceneList } from "@/store/case";
|
|
|
+import { getCaseSceneList, getSyncSceneInfo } from "@/store/case";
|
|
|
import { CaseTagging } from "@/store/caseTagging";
|
|
|
-import { SceneType } from "@/store/scene";
|
|
|
-import { user } from "@/store/user";
|
|
|
+import { ModelScene, QuoteScene, Scene, SceneType } from "@/store/scene";
|
|
|
+import { transformSWToken, user } from "@/store/user";
|
|
|
import { base64ToBlob, drawImage } from "@/util";
|
|
|
|
|
|
export type MenuItem = {
|
|
@@ -32,6 +36,48 @@ export const getFuseCodeLink = (caseId: number, query?: boolean) => {
|
|
|
return url.href;
|
|
|
};
|
|
|
|
|
|
+export const getSWKKSyncLink = async (caseId: number) => {
|
|
|
+ const scenes = await getCaseSceneList(caseId);
|
|
|
+ const supportTypes = [SceneType.SWKK, SceneType.SWKJ];
|
|
|
+ const kkScenes = scenes.filter((scene) =>
|
|
|
+ supportTypes.includes(scene.type)
|
|
|
+ ) as QuoteScene[];
|
|
|
+
|
|
|
+ let msg: string | null = null;
|
|
|
+ if (!scenes.length) {
|
|
|
+ msg = "当前案件下无场景,请先添加场景。";
|
|
|
+ } else if (!kkScenes.length) {
|
|
|
+ msg = `带看仅支持${supportTypes
|
|
|
+ .map((type) => SceneTypeDesc[type])
|
|
|
+ .join("、")}类型场景,请添加此类型场景。`;
|
|
|
+ }
|
|
|
+ if (msg) {
|
|
|
+ alert(msg);
|
|
|
+ throw msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ const url = new URL(
|
|
|
+ SceneTypePaths[SceneType.SWKK][2],
|
|
|
+ SceneTypeDomain[SceneType.SWKK]
|
|
|
+ );
|
|
|
+ console.log(SceneTypePaths[SceneType.SWKK]);
|
|
|
+ const roomId = await getSyncSceneInfo(caseId);
|
|
|
+ const params = {
|
|
|
+ vruserId: user.value.info.userName,
|
|
|
+ platform: "fd",
|
|
|
+ roomId,
|
|
|
+ role: "leader",
|
|
|
+ avatar: user.value.info.avatar,
|
|
|
+ name: user.value.info.userName,
|
|
|
+ isTour: "0",
|
|
|
+ m: kkScenes[0].num,
|
|
|
+ };
|
|
|
+ for (const [name, val] of Object.entries(params)) {
|
|
|
+ url.searchParams.append(name, val || "");
|
|
|
+ }
|
|
|
+ return url;
|
|
|
+};
|
|
|
+
|
|
|
export const checkScenesOpen = async (caseId: number, url: URL | string) => {
|
|
|
const scenes = await getCaseSceneList(caseId);
|
|
|
if (!scenes.length) {
|
|
@@ -183,3 +229,30 @@ export const fuseImageJoinHot = async (
|
|
|
|
|
|
return blob;
|
|
|
};
|
|
|
+
|
|
|
+export enum OpenType {
|
|
|
+ query,
|
|
|
+ edit,
|
|
|
+}
|
|
|
+export const openSceneUrl = async (scene: Scene, type: OpenType) => {
|
|
|
+ const pathname = SceneTypePaths[scene.type][type];
|
|
|
+ const url = new URL(pathname || "", window.location.href);
|
|
|
+ if (scene.type === SceneType.SWMX) {
|
|
|
+ url.searchParams.append(
|
|
|
+ "modelId",
|
|
|
+ (scene as ModelScene).modelId.toString()
|
|
|
+ );
|
|
|
+ url.hash = "#sign-model";
|
|
|
+ url.searchParams.append("share", "1");
|
|
|
+ } else {
|
|
|
+ url.searchParams.append("m", (scene as QuoteScene).num);
|
|
|
+
|
|
|
+ if (type === OpenType.edit) {
|
|
|
+ url.searchParams.append(
|
|
|
+ "token",
|
|
|
+ await transformSWToken(scene as QuoteScene)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ window.open(url);
|
|
|
+};
|