|
|
@@ -1,9 +1,10 @@
|
|
|
-import React, { useEffect, useMemo, useState } from 'react'
|
|
|
+import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { duiHuaSonType } from '@/types'
|
|
|
import { baseUrl } from '@/utils/http'
|
|
|
import classNames from 'classnames'
|
|
|
import { Swiper } from 'antd-mobile'
|
|
|
+import { Image } from 'antd-mobile'
|
|
|
|
|
|
type Props = {
|
|
|
arr: duiHuaSonType[]
|
|
|
@@ -18,10 +19,16 @@ function A7arr({ arr }: Props) {
|
|
|
|
|
|
const [imgInd, setImgInd] = useState(0)
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (swiperRef.current) swiperRef.current.swipeTo(imgInd)
|
|
|
+ }, [imgInd])
|
|
|
+
|
|
|
const info = useMemo(() => {
|
|
|
return arr.find((v, i) => i === topInd)!
|
|
|
}, [arr, topInd])
|
|
|
|
|
|
+ const swiperRef = useRef<any>(null)
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.A7arr}>
|
|
|
<div className='A7A1' style={{ backgroundImage: `url(${baseUrl}main/duiHua/arrBg.jpg)` }}>
|
|
|
@@ -45,12 +52,17 @@ function A7arr({ arr }: Props) {
|
|
|
|
|
|
<div className='A7A3'>
|
|
|
<Swiper
|
|
|
- style={{
|
|
|
- '--track-padding': '0 0 16px'
|
|
|
- }}
|
|
|
+ allowTouchMove={false}
|
|
|
+ ref={swiperRef}
|
|
|
indicator={(total: number, current: number) => (
|
|
|
<div className='A7A3IndBox'>
|
|
|
- {total},{current}
|
|
|
+ {info.imgArr.map((_, ii) => (
|
|
|
+ <div
|
|
|
+ key={ii}
|
|
|
+ onClick={() => setImgInd(ii)}
|
|
|
+ className={classNames('A7zRow', ii === current ? 'A7zRowAc' : '')}
|
|
|
+ ></div>
|
|
|
+ ))}
|
|
|
</div>
|
|
|
)}
|
|
|
>
|
|
|
@@ -58,11 +70,32 @@ function A7arr({ arr }: Props) {
|
|
|
<Swiper.Item key={index2}>
|
|
|
<div className='A7A3box'>
|
|
|
<div className='A7A3_1'>{item.name}</div>
|
|
|
- <img className='A7A3Img' src={baseUrl + item.url} alt='' />
|
|
|
+ <Image
|
|
|
+ lazy={true}
|
|
|
+ src={baseUrl + item.url}
|
|
|
+ placeholder={<div className='A7loding'>加载中...</div>}
|
|
|
+ />
|
|
|
</div>
|
|
|
</Swiper.Item>
|
|
|
))}
|
|
|
</Swiper>
|
|
|
+
|
|
|
+ {/* 左右按钮 */}
|
|
|
+ <img
|
|
|
+ onClick={() => setImgInd(imgInd - 1)}
|
|
|
+ className={classNames('A2y1Left', imgInd === 0 ? 'A2y1LeftNo' : '')}
|
|
|
+ src={`${baseUrl}main/diao/left.png`}
|
|
|
+ alt=''
|
|
|
+ />
|
|
|
+ <img
|
|
|
+ onClick={() => setImgInd(imgInd + 1)}
|
|
|
+ className={classNames(
|
|
|
+ 'A2y1Left A2y1Right',
|
|
|
+ imgInd >= info.imgArr.length - 1 ? 'A2y1LeftNo' : ''
|
|
|
+ )}
|
|
|
+ src={`${baseUrl}main/diao/right.png`}
|
|
|
+ alt=''
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|