|
@@ -14,8 +14,37 @@ import ImageLazy from "@/ImageLazy";
|
|
|
import { Input, Select } from "antd";
|
|
|
import classNames from "classnames";
|
|
|
import GoodsInfo from "../GoodsInfo";
|
|
|
+import { CloseOutlined } from "@ant-design/icons";
|
|
|
+import curImg from "@/assets/img/goods/cur.png";
|
|
|
+import curAcImg from "@/assets/img/goods/curAc.png";
|
|
|
|
|
|
function GoodsSw() {
|
|
|
+ // 滚轮提示
|
|
|
+ const [curTit, setCurTit] = useState(true);
|
|
|
+
|
|
|
+ const curTimeRef = useRef(0);
|
|
|
+ const [curCut, setCurCut] = useState(true);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (!curTit) {
|
|
|
+ localStorage.setItem("YPZZ_CUR", "1");
|
|
|
+ clearInterval(curTimeRef.current);
|
|
|
+ }
|
|
|
+ }, [curTit]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // 开启滚轮提升 图片更换 定时器
|
|
|
+ clearInterval(curTimeRef.current);
|
|
|
+ curTimeRef.current = window.setInterval(() => {
|
|
|
+ setCurCut(!curCut);
|
|
|
+ }, 2000);
|
|
|
+ }, [curCut]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const isFlag = localStorage.getItem("YPZZ_CUR");
|
|
|
+ if (isFlag) setCurTit(false);
|
|
|
+ }, []);
|
|
|
+
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -183,6 +212,9 @@ function GoodsSw() {
|
|
|
const dom = document.querySelector("#goddsSwBox1") as HTMLDivElement;
|
|
|
// 监听鼠标滚轮
|
|
|
dom.onwheel = (e) => {
|
|
|
+ // 使用过滚轮
|
|
|
+ setCurTit(false);
|
|
|
+
|
|
|
e.preventDefault();
|
|
|
const num = dom.scrollLeft;
|
|
|
if (dom.scrollLeft + dom.clientWidth >= dom.scrollWidth)
|
|
@@ -204,6 +236,9 @@ function GoodsSw() {
|
|
|
dom.scrollLeft = dom.scrollWidth - dom.clientWidth;
|
|
|
// 监听鼠标滚轮
|
|
|
dom.onwheel = (e) => {
|
|
|
+ // 使用过滚轮
|
|
|
+ setCurTit(false);
|
|
|
+
|
|
|
e.preventDefault();
|
|
|
const num = dom.scrollLeft;
|
|
|
if (num <= 0) dom.scrollLeft = dom.scrollWidth - dom.clientWidth;
|
|
@@ -276,13 +311,17 @@ function GoodsSw() {
|
|
|
>
|
|
|
<div className="goddsSw" style={{ width: goddsSw1 + "px" }}>
|
|
|
{list1.map((v, i) => (
|
|
|
- <div key={i} className="goddsRow" title={v.name}>
|
|
|
+ <div key={i} className="goddsRow">
|
|
|
<div className="name">
|
|
|
{v.name.length > 10
|
|
|
? v.name.substring(0, 10) + "..."
|
|
|
: v.name}
|
|
|
</div>
|
|
|
- <div className="goddsImg" onClick={() => clickGoodFu(v.id)}>
|
|
|
+ <div
|
|
|
+ title={v.name}
|
|
|
+ className="goddsImg"
|
|
|
+ onClick={() => clickGoodFu(v.id)}
|
|
|
+ >
|
|
|
<ImageLazy
|
|
|
src={v.thumb}
|
|
|
width="100%"
|
|
@@ -353,7 +392,7 @@ function GoodsSw() {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- {/* 当个藏品详情盒子 */}
|
|
|
+ {/* 单个藏品详情盒子 */}
|
|
|
<div className={classNames("goodsInfoBox", open ? "goodsInfoBoxAc" : "")}>
|
|
|
{open ? (
|
|
|
<GoodsInfo
|
|
@@ -363,6 +402,20 @@ function GoodsSw() {
|
|
|
/>
|
|
|
) : null}
|
|
|
</div>
|
|
|
+
|
|
|
+ {/* 滚轮提示 */}
|
|
|
+ {curTit ? (
|
|
|
+ <div className="curTitBox" hidden={open}>
|
|
|
+ <div className="curClose" onClick={() => setCurTit(false)}>
|
|
|
+ <CloseOutlined />
|
|
|
+ </div>
|
|
|
+ <div className="curImg">
|
|
|
+ <img src={curImg} alt="" style={{ opacity: curCut ? 1 : 0 }} />
|
|
|
+ <img src={curAcImg} alt="" style={{ opacity: curCut ? 0 : 1 }} />
|
|
|
+ </div>
|
|
|
+ <p>鼠标滚轮可控制图片滚动</p>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
);
|
|
|
}
|