|
@@ -1,16 +1,15 @@
|
|
|
-import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
+import React, { useEffect, useState } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
import classNames from "classnames";
|
|
|
import { envUrl } from "@/utils/env";
|
|
|
-import { imgLodingFu, maoData2, mapData1 } from "./data";
|
|
|
+import { MapType, imgLodingFu, maoData2, mapData1 } from "./data";
|
|
|
import iconImg1 from "@/assets/img/map/icon1.png";
|
|
|
import iconImg1Ac from "@/assets/img/map/icon1Ac.png";
|
|
|
import iconImg2 from "@/assets/img/map/icon2.png";
|
|
|
import iconImg2Ac from "@/assets/img/map/icon2Ac.png";
|
|
|
-import MapSon from "./MapSon";
|
|
|
-import { useSelector } from "react-redux";
|
|
|
-import { RootState } from "@/store";
|
|
|
-import { domShowFu } from "@/utils/domShow";
|
|
|
+import MapSon from "./Iframe";
|
|
|
+import ImgLoding from "@/components/ImgLoding";
|
|
|
+import { baseURL } from "@/utils/http";
|
|
|
|
|
|
type Props = {
|
|
|
type: number;
|
|
@@ -18,92 +17,52 @@ type Props = {
|
|
|
};
|
|
|
|
|
|
function A0Map({ type, sonChaneType }: Props) {
|
|
|
- // 进页面显示加载中
|
|
|
useEffect(() => {
|
|
|
- domShowFu("#AsyncSpinLoding", true);
|
|
|
- }, []);
|
|
|
-
|
|
|
- // 一级地图 图片的加载
|
|
|
- const imgLodingArr = useSelector(
|
|
|
- (state: RootState) => state.A0layout.imgLodingArr
|
|
|
- );
|
|
|
+ if (type !== 2) {
|
|
|
+ setSonPage(null);
|
|
|
+ setCheckedData1(null);
|
|
|
+ setMapSon(0);
|
|
|
+ }
|
|
|
+ }, [type]);
|
|
|
|
|
|
// 控制二级地图的显示
|
|
|
const [mapSon, setMapSon] = useState(0);
|
|
|
|
|
|
- // 大图片是否已经加载完
|
|
|
- const isImgLodingFu = useCallback(() => {
|
|
|
- let flag = false;
|
|
|
-
|
|
|
- if (imgLodingArr.includes(mapSon)) {
|
|
|
- domShowFu("#AsyncSpinLoding", false);
|
|
|
- flag = true;
|
|
|
- }
|
|
|
-
|
|
|
- return flag;
|
|
|
- }, [imgLodingArr, mapSon]);
|
|
|
-
|
|
|
- // 开场动画帧的变化
|
|
|
- const [moveInd, setMoveInd] = useState(0);
|
|
|
- const moveTime = useRef(-1);
|
|
|
- const moveYun = useCallback(() => {
|
|
|
- if (!isImgLodingFu()) {
|
|
|
- clearInterval(moveTime.current);
|
|
|
- let num = 0;
|
|
|
- moveTime.current = window.setInterval(() => {
|
|
|
- setMoveInd(num);
|
|
|
- num++;
|
|
|
- if (num > 30 || isImgLodingFu()) {
|
|
|
- clearInterval(moveTime.current);
|
|
|
- }
|
|
|
- }, 50);
|
|
|
- }
|
|
|
- }, [isImgLodingFu]);
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- moveYun();
|
|
|
-
|
|
|
- return () => {
|
|
|
- clearInterval(moveTime.current);
|
|
|
- };
|
|
|
- }, [moveYun]);
|
|
|
-
|
|
|
// 鼠标hover
|
|
|
const [isHover, setIsHover] = useState(0);
|
|
|
|
|
|
+ const [sonPage, setSonPage] = useState<string | null>(null);
|
|
|
+ const [checkedData1, setCheckedData1] = useState<MapType | null>(null);
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.A0Map}>
|
|
|
- {/* 开场动画帧 */}
|
|
|
- <div
|
|
|
- className={classNames(
|
|
|
- "videoBoxMove",
|
|
|
- isImgLodingFu() ? "videoBoxHide" : ""
|
|
|
- )}
|
|
|
- >
|
|
|
- <img src={`${envUrl}/yunMove/yan_${moveInd}.png`} alt="" />
|
|
|
- </div>
|
|
|
+ {/* 大图片加载中 */}
|
|
|
+ <ImgLoding id={mapSon} />
|
|
|
|
|
|
- {/* 一级地图 */}
|
|
|
+ {/* 一级地图盒子 */}
|
|
|
<div
|
|
|
+ style={{ opacity: mapSon ? "0" : "1" }}
|
|
|
className={classNames(
|
|
|
"mapMain",
|
|
|
type === 2 ? "mapMain2" : type === 3 ? "mapMain3" : ""
|
|
|
)}
|
|
|
>
|
|
|
{/* 定位大图标 */}
|
|
|
- {mapData1.map((v) => (
|
|
|
+ {mapData1.map((v, index) => (
|
|
|
<div
|
|
|
onMouseEnter={() => setIsHover(v.id)}
|
|
|
onMouseLeave={() => setIsHover(0)}
|
|
|
onClick={() => {
|
|
|
- setMapSon(v.id);
|
|
|
+ setCheckedData1(v);
|
|
|
+ setSonPage(v.filename);
|
|
|
+
|
|
|
sonChaneType(2);
|
|
|
}}
|
|
|
key={v.id}
|
|
|
className="A0iconBox"
|
|
|
style={{ top: v.y, left: v.x, zIndex: v.ind }}
|
|
|
>
|
|
|
- <div className="iconNum">{v.id}</div>
|
|
|
+ <div className="iconNum">{index + 1}</div>
|
|
|
|
|
|
<img className="iconImg1" src={iconImg1} alt="" />
|
|
|
<img className="iconImg2" src={iconImg1Ac} alt="" />
|
|
@@ -134,14 +93,16 @@ function A0Map({ type, sonChaneType }: Props) {
|
|
|
{maoData2.map((v) => (
|
|
|
<div
|
|
|
onClick={() => {
|
|
|
- window.open(v.link);
|
|
|
- // setMapSon(v.id);
|
|
|
+ window.open(
|
|
|
+ v.link.startsWith("http") ? v.link : baseURL + v.link
|
|
|
+ );
|
|
|
+ // setMapSon(v.imgId);
|
|
|
sonChaneType(3);
|
|
|
}}
|
|
|
key={v.id}
|
|
|
className={classNames(
|
|
|
"A0iconSmBox",
|
|
|
- v.type === "right" ? "A0iconSmBoxR" : ""
|
|
|
+ v.loc === "顶部" ? "A0iconSmBoxR" : ""
|
|
|
)}
|
|
|
style={{
|
|
|
top: v.y,
|
|
@@ -163,7 +124,11 @@ function A0Map({ type, sonChaneType }: Props) {
|
|
|
<div
|
|
|
className={classNames(
|
|
|
"ic2HoverBox",
|
|
|
- v.type === "right" ? "ic2HoverBox2" : ""
|
|
|
+ v.type === "right"
|
|
|
+ ? "ic2HoverBox2"
|
|
|
+ : v.type === "center"
|
|
|
+ ? "ic2HoverBox3"
|
|
|
+ : ""
|
|
|
)}
|
|
|
>
|
|
|
<div className="ic2HoverBoxll">{v.name}</div>
|
|
@@ -174,6 +139,7 @@ function A0Map({ type, sonChaneType }: Props) {
|
|
|
</div>
|
|
|
))}
|
|
|
|
|
|
+ {/* 一级地图 图片 */}
|
|
|
<div className="mapBac">
|
|
|
<img
|
|
|
onLoad={() => imgLodingFu(0)}
|
|
@@ -184,7 +150,9 @@ function A0Map({ type, sonChaneType }: Props) {
|
|
|
</div>
|
|
|
|
|
|
{/* 二级地图 */}
|
|
|
- {mapSon ? <MapSon sId={mapSon} /> : null}
|
|
|
+ {sonPage && checkedData1 ? (
|
|
|
+ <MapSon title={checkedData1.name} filename={sonPage} />
|
|
|
+ ) : null}
|
|
|
|
|
|
{/* <div className="yunBox">
|
|
|
<div className="yunSon1"></div>
|