import React, { useEffect, useMemo, useState } from "react"; import styles from "./index.module.scss"; import { baseUrl } from "@/index"; import { useSelector } from "react-redux"; import { RootState } from "@/store"; import classNames from "classnames"; import btnImg from "@/assets/img/tab2/btn_m.png"; import { SwapRightOutlined } from "@ant-design/icons"; import Swiper from "./swiperCard/swiper-bundle.min.js"; import "./swiperCard/swiper-bundle.min.css"; type Props = { closeFu: () => void; clickCardFu: (id: number) => void; }; function B1CardM({ closeFu, clickCardFu }: Props) { const data = useSelector( (state: RootState) => state.A0Layout.dataAll.village ); // 改变的 轮播图 索引 用来 显示顶部 名字 const [ind, setInd] = useState(0); useEffect(() => { 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); }, }, }); }, []); // 当前选中的卡片信息 const acItem = useMemo(() => { let info = { id: 0, name: "" }; const infoRes = data.find((v, i) => i === ind); if (infoRes) info = { id: infoRes.id, name: infoRes.name }; return info; }, [data, ind]); return (
= 80 ? v.infoTxt.substring(0, 80) + "..." : v.infoTxt, }} >
{/* 背景图 */}