123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- /* eslint-disable jsx-a11y/iframe-has-title */
- import React, { useMemo, useRef, useState } from "react";
- import styles from "./index.module.scss";
- import { baseUrl } from "@/index";
- import { InfoRowType } from "@/types";
- import history from "@/utils/history";
- import { SwapRightOutlined } from "@ant-design/icons";
- import classNames from "classnames";
- const iconArr = [
- { id: 2, name: "放大" },
- { id: 3, name: "缩小" },
- { id: 4, name: "复位" },
- ];
- type Props = {
- info: InfoRowType;
- type: "C2ArchitecInfo" | "D2BuildInfo";
- };
- function ArcOrBuildInfoM({ info, type }: Props) {
- // 模型的ref
- const ifrRefNew = useRef<any>(null);
- const modelChangeFu = (val: number) => {
- const dom = ifrRefNew.current;
- if (dom && dom.contentWindow && dom.contentWindow.webview) {
- if (val === 2) dom.contentWindow.webview.zoomIn(); // 放大
- else if (val === 3) dom.contentWindow.webview.zoomOut(); // 缩小
- else dom.contentWindow.webview.resetView(); // 复位
- }
- };
- // 文字介绍
- const [txtShow, setTxtShow] = useState(false);
- // 全屏
- const [full, setFull] = useState(false);
- // 是否没有大场景也没有构件
- const isFullBox = useMemo(() => {
- let flag = false;
- if (
- !info.code &&
- (!info.isBuild || (info.isBuild && info.isBuild.length === 0))
- ) {
- flag = true;
- }
- return flag;
- }, [info.code, info.isBuild]);
- return (
- <div
- className={styles.ArcOrBuildInfoM}
- style={{ backgroundImage: `url(${baseUrl}/C2ArchitecInfo/bg2.jpg)` }}
- >
- {/* 返回按钮 */}
- <div className="AMback" onClick={() => history.go(-1)} hidden={full}>
- <img src={`${baseUrl}/C2ArchitecInfo/icon_back.png`} alt="" />
- </div>
- {/* 主体模型 */}
- <div
- className={classNames(
- "AMtop",
- full ? "AMtopFull" : "",
- isFullBox ? "AMtopFull2" : ""
- )}
- >
- {/* 名字 */}
- <div className="AMtopName">{info.name}</div>
- {/* 模型 */}
- <iframe
- ref={ifrRefNew}
- src={`/model.html?m=${info.id}&n=new&r=${type}`}
- frameBorder="0"
- ></iframe>
- {/* 右侧按钮 */}
- <div className="AMtopBtn">
- {/* 打开介绍 */}
- <div
- hidden={!info.txt}
- className={classNames(
- "AMtopBtnRow AMtopBtnRow1",
- txtShow ? "AMtopBtnRow1Ac" : ""
- )}
- onClick={() => setTxtShow(!txtShow)}
- ></div>
- {iconArr.map((v) => (
- <div
- onClick={() => modelChangeFu(v.id)}
- className={`AMtopBtnRow AMtopBtnRow${v.id}`}
- key={v.id}
- ></div>
- ))}
- {/* 全屏 */}
- <div
- hidden={isFullBox}
- onClick={() => {
- const dom = ifrRefNew.current;
- if (dom && dom.contentWindow && dom.contentWindow.modelLoding)
- setFull(!full);
- }}
- className={classNames(
- "AMtopBtnRow AMtopBtnRow5",
- full ? "AMtopBtnRow5Ac" : ""
- )}
- ></div>
- </div>
- </div>
- {/* 底部按钮 */}
- <div className="AMbtn" hidden={full}>
- {info.isBuild ? (
- <>
- {info.isBuild.map((v) => (
- <div
- className="AMbtnRow"
- key={v.id}
- onClick={() => history.push(`/buildInfo?id=${v.id}`)}
- >
- <div>
- {v.name[0]} {v.name[1]}
- </div>
- </div>
- ))}
- </>
- ) : null}
- {/* 去大场景 */}
- {type === "C2ArchitecInfo" && info.code ? (
- <div
- className="AMtoVr"
- onClick={() => history.push(`/scene?id=${info.code}`)}
- >
- 室内VR
- <p>
- <SwapRightOutlined />
- </p>
- </div>
- ) : null}
- </div>
- {/* 文字介绍 */}
- <div
- className={classNames("AMtxt", txtShow ? "AMtxtAc" : "")}
- style={{ backgroundImage: `url(${baseUrl}/C2ArchitecInfo/tab.png)` }}
- >
- <h3>
- 简介 {/* 右侧关闭按钮 */}
- <img
- onClick={() => setTxtShow(false)}
- className="AMtxtClose"
- src={`${baseUrl}/C2ArchitecInfo/icon_cancel.png`}
- alt=""
- />
- </h3>
- <div className="AMtxtLine">
- <img src={`${baseUrl}/C1Architec/line.png`} alt="" />
- </div>
- <div className="AMtxtCon">
- <div
- dangerouslySetInnerHTML={{
- __html: info.txt ? info.txt : "暂无介绍",
- }}
- ></div>
- </div>
- </div>
- </div>
- );
- }
- const MemoArcOrBuildInfoM = React.memo(ArcOrBuildInfoM);
- export default MemoArcOrBuildInfoM;
|