|
@@ -1,14 +1,82 @@
|
|
-import React from "react";
|
|
|
|
|
|
+import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
- function H5Code() {
|
|
|
|
-
|
|
|
|
|
|
+import H5Logo from "@/assets/img/H5Logo.png";
|
|
|
|
+import { useLocation } from "react-router";
|
|
|
|
+import { urlParameter } from "@/utils/history";
|
|
|
|
+import { useDispatch, useSelector } from "react-redux";
|
|
|
|
+import { getH5InfoAPI } from "@/store/action/h5code";
|
|
|
|
+import { RootState } from "@/store";
|
|
|
|
+import { baseURL } from "@/utils/http";
|
|
|
|
+
|
|
|
|
+function H5Code() {
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ const root: any = document.querySelector("#root");
|
|
|
|
+ root.style.overflow = "hidden";
|
|
|
|
+ root.style.overflow = "hidden";
|
|
|
|
+ root.style.minHeight = "100vh";
|
|
|
|
+ root.style.minWidth = "100vw";
|
|
|
|
+ }, []);
|
|
|
|
+
|
|
|
|
+ // 获取地址栏参数
|
|
|
|
+ const dispatch = useDispatch();
|
|
|
|
+ const location = useLocation();
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ const obj = urlParameter(location.search);
|
|
|
|
+ if (obj.id) dispatch(getH5InfoAPI(obj.id));
|
|
|
|
+ }, [dispatch, location.search]);
|
|
|
|
+
|
|
|
|
+ // 从仓库获取详情
|
|
|
|
+ const info = useSelector((state: RootState) => state.h5codeReducer.h5info);
|
|
|
|
+
|
|
|
|
+ // 点击下载海报
|
|
|
|
+ const [donImg, setDonImg] = useState(false);
|
|
|
|
+ const donImgFu = useCallback(() => {
|
|
|
|
+ setDonImg(!donImg);
|
|
|
|
+ }, [donImg]);
|
|
|
|
+
|
|
|
|
+ const infoTxt = useMemo(() => {
|
|
|
|
+ let txt = info.description ? info.description : "-";
|
|
|
|
+ if (txt.length >= 60 && donImg) txt = txt.substring(0, 60) + "...";
|
|
|
|
+ return txt;
|
|
|
|
+ }, [donImg, info.description]);
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<div className={styles.H5Code}>
|
|
<div className={styles.H5Code}>
|
|
- <h1>H5Code</h1>
|
|
|
|
|
|
+ <div className="H5MainBox">
|
|
|
|
+ <div className="H5MainBoxInfo">
|
|
|
|
+ <div className="H5Img">
|
|
|
|
+ {info.thumb ? <img src={baseURL + info.thumb} alt="" /> : null}
|
|
|
|
+ </div>
|
|
|
|
+ {/* 占位盒子 */}
|
|
|
|
+ <div className="H5Loc"></div>
|
|
|
|
+ {/* 文字信息 */}
|
|
|
|
+ <div className="H5TxtBox">
|
|
|
|
+ {/* 名字 */}
|
|
|
|
+ <div className="name">
|
|
|
|
+ <div>{info.name}</div>
|
|
|
|
+ </div>
|
|
|
|
+ {/* 简介信息 */}
|
|
|
|
+ <div className="txtMain">
|
|
|
|
+ <p>类别:{info.dictTexture}</p>
|
|
|
|
+ <p>年代:{info.dictAge}</p>
|
|
|
|
+ <p>级别:{info.dictLevel}</p>
|
|
|
|
+ <div>简介:{infoTxt}</div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ {/* logo */}
|
|
|
|
+ <div className="H5Logo">
|
|
|
|
+ <img src={H5Logo} alt="" />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div className="H5MainBoxButton">
|
|
|
|
+ <div onClick={donImgFu}>下载海报</div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
const MemoH5Code = React.memo(H5Code);
|
|
const MemoH5Code = React.memo(H5Code);
|
|
|
|
|
|
-export default MemoH5Code;
|
|
|
|
|
|
+export default MemoH5Code;
|