|
@@ -1,40 +1,87 @@
|
|
|
-import React, { useEffect } from "react";
|
|
|
+import React, { useEffect, useState } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
import { baseUrl } from "@/index";
|
|
|
|
|
|
-// import Swiper from "./swiperCard/swiper-bundle.min.js";
|
|
|
+import Swiper from "./swiperCard/swiper-bundle.min.js";
|
|
|
|
|
|
-// import "./swiperCard/swiper-bundle.min.css";
|
|
|
+import "./swiperCard/swiper-bundle.min.css";
|
|
|
+import { useSelector } from "react-redux";
|
|
|
+import { RootState } from "@/store";
|
|
|
+import classNames from "classnames";
|
|
|
|
|
|
type Props = {
|
|
|
- isShow: boolean;
|
|
|
closeFu: () => void;
|
|
|
clickCardFu: (id: number) => void;
|
|
|
};
|
|
|
|
|
|
-function B1CardM({ isShow, closeFu, clickCardFu }: Props) {
|
|
|
+function B1CardM({ closeFu, clickCardFu }: Props) {
|
|
|
+ const data = useSelector(
|
|
|
+ (state: RootState) => state.A0Layout.dataAll.village
|
|
|
+ );
|
|
|
+
|
|
|
+ // 改变的 轮播图 索引 用来 显示顶部 名字
|
|
|
+ const [ind, setInd] = useState(0);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- // new Swiper(".mySwiper", {
|
|
|
- // effect: "cards",
|
|
|
- // grabCursor: true,
|
|
|
- // // loop:true
|
|
|
- // });
|
|
|
+ let num = 0;
|
|
|
+
|
|
|
+ const temp = window.location.hash;
|
|
|
+ if (temp.includes("#/village?id=")) {
|
|
|
+ const url = temp.split("?id=")[1];
|
|
|
+ num = Number(url) - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ new Swiper(".mySwiper", {
|
|
|
+ effect: "cards",
|
|
|
+ grabCursor: true,
|
|
|
+ // 初始高亮
|
|
|
+ initialSlide: num,
|
|
|
+ // loop:true
|
|
|
+ on: {
|
|
|
+ slideChange: function (swiper: any) {
|
|
|
+ setInd(swiper.activeIndex);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
}, []);
|
|
|
|
|
|
return (
|
|
|
- <div hidden={isShow} className={styles.B1CardM}>
|
|
|
+ <div className={styles.B1CardM}>
|
|
|
{/* 右上角的按钮 */}
|
|
|
<div className="B1Cback" onClick={closeFu}>
|
|
|
<img src={`${baseUrl}/A1Home/mobile/icon_cancel.png`} alt="" />
|
|
|
</div>
|
|
|
|
|
|
{/* 卡片sw */}
|
|
|
- {/* <div className="swiper mySwiper">
|
|
|
+ <div className="swiper mySwiper">
|
|
|
<div className="swiper-wrapper">
|
|
|
- <div>1</div>
|
|
|
- <div>2</div>
|
|
|
+ {data.map((v, i) => (
|
|
|
+ <div className="swiper-slide" key={v.id}>
|
|
|
+ <img src={`${baseUrl}/B1Village/mobile/${v.id}.jpg`} alt="" />
|
|
|
+ <p
|
|
|
+ dangerouslySetInnerHTML={{
|
|
|
+ __html:
|
|
|
+ v.infoTxt.length >= 80
|
|
|
+ ? v.infoTxt.substring(0, 80) + "..."
|
|
|
+ : v.infoTxt,
|
|
|
+ }}
|
|
|
+ ></p>
|
|
|
+ {/* 背景图 */}
|
|
|
+ <div
|
|
|
+ className={classNames(
|
|
|
+ "slideBac",
|
|
|
+ ind === i ? "slideBacAc" : ""
|
|
|
+ )}
|
|
|
+ style={{
|
|
|
+ backgroundImage: `url(${baseUrl}/B1Village/mobile/${
|
|
|
+ ind === i ? "bacAc" : "bac"
|
|
|
+ }.png)`,
|
|
|
+ }}
|
|
|
+ ></div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
</div>
|
|
|
- </div> */}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
);
|
|
|
}
|