|
@@ -0,0 +1,147 @@
|
|
1
|
+import React, { useState, useRef } from "react";
|
|
2
|
+import Swiper from 'swiper';
|
|
3
|
+import router from 'umi/router';
|
|
4
|
+import request from '../../utils/request'
|
|
5
|
+import apis from '../../services/apis';
|
|
6
|
+import styles from './style.less'
|
|
7
|
+import closeImg from '../../assets/close.png';
|
|
8
|
+import classNames from 'classnames';
|
|
9
|
+import 'swiper/css/swiper.min.css';
|
|
10
|
+
|
|
11
|
+class swiper extends React.Component {
|
|
12
|
+ constructor(props) {
|
|
13
|
+ super(props);
|
|
14
|
+ this.state = {
|
|
15
|
+ visible: true,
|
|
16
|
+ }
|
|
17
|
+
|
|
18
|
+ this.slider = null
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ componentDidMount() {
|
|
22
|
+ this.swiper = new Swiper('.swiper-container', {
|
|
23
|
+ slidesPerView: 1,
|
|
24
|
+ loop: true,
|
|
25
|
+ autoplay: true,
|
|
26
|
+ touchRatio: 2,
|
|
27
|
+ pagination: {
|
|
28
|
+ el: '.swiper-pagination',
|
|
29
|
+ tyrp: 'custom',
|
|
30
|
+ clickable: true,
|
|
31
|
+ },
|
|
32
|
+ observer: true,//修改swiper自己或子元素时,自动初始化swiper
|
|
33
|
+ observeParents: true,
|
|
34
|
+ })
|
|
35
|
+ }
|
|
36
|
+ // const [visible, setVisible] = useState(true)
|
|
37
|
+
|
|
38
|
+ handleSwiperItem(item) {
|
|
39
|
+ console.log(item, "item")
|
|
40
|
+ }
|
|
41
|
+ closeSwiper() {
|
|
42
|
+ // setVisible(false)
|
|
43
|
+ this.setState({
|
|
44
|
+ visible: false
|
|
45
|
+ })
|
|
46
|
+ }
|
|
47
|
+ render() {
|
|
48
|
+ const swpierData = [
|
|
49
|
+ { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592534834&di=2f2329437f205799e8be6abcc8fdb495&imgtype=0&src=http%3A%2F%2Fpic4.zhimg.com%2F50%2Fv2-7fece9a613445edb78271216c8c20c6d_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或' },
|
|
50
|
+ { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592534903&di=70fbf6793ff7e80ec38eb6204898fa35&imgtype=0&src=http%3A%2F%2Fpic2.zhimg.com%2F50%2Fv2-ba9d3691d1438e4fe4fef84faf3e7e33_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或嘻嘻嘻嘻嘻嘻' },
|
|
51
|
+ { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592674824&di=ebc27c383e5a402f8d0dfd2457b29c9d&imgtype=0&src=http%3A%2F%2Fpic1.zhimg.com%2F50%2Fv2-03d53b468e27ddc99f1ffcd17eec9700_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或嘻嘻嘻嘻嘻嘻' },
|
|
52
|
+ { img: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1813762643,1914315241&fm=26&gp=0.jpg', title: '啦啦啦啦啦啦啦啦啦啦啦啦啦啦' },
|
|
53
|
+ { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592745048&di=e30a13762d0823ac5c1e3945a35ed55d&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201711%2F09%2F20171109195545_M2Bk3.jpeg', title: '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' },
|
|
54
|
+ ]
|
|
55
|
+ const { visible } = this.state
|
|
56
|
+ return (
|
|
57
|
+ <>
|
|
58
|
+ {<div className={styles.mask}>
|
|
59
|
+ <div className={styles.content}>
|
|
60
|
+ <img src={closeImg} alt="" className={styles.close} onClick={() => this.closeSwiper()} />
|
|
61
|
+ <div className={classNames(['swiper-container', styles.carousel])} >
|
|
62
|
+ <div className={classNames(['swiper-wrapper', styles.carousel])} >
|
|
63
|
+ {swpierData.map((item, index) =>
|
|
64
|
+ <div key={'swiper' + index} className={classNames(['swiper-slide', styles.carouselItem])} onClick={() => this.handleSwiperItem(item)}>
|
|
65
|
+ <img style={{ width: '100%', height: '100%', borderRadius: '10px' }} src={item.img} alt="" />
|
|
66
|
+ <div className={styles.title}>{item.title}</div>
|
|
67
|
+ </div>
|
|
68
|
+ )}
|
|
69
|
+ </div>
|
|
70
|
+ <div class="swiper-pagination"></div>
|
|
71
|
+ </div>
|
|
72
|
+ </div>
|
|
73
|
+ </div>}
|
|
74
|
+ </>
|
|
75
|
+ )
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+export default swiper
|
|
82
|
+// import React, { useState, useRef } from "react";
|
|
83
|
+// import Slider from "react-slick";
|
|
84
|
+// import router from 'umi/router';
|
|
85
|
+// import request from '../../utils/request'
|
|
86
|
+// import apis from '../../services/apis';
|
|
87
|
+// import styles from './style.less'
|
|
88
|
+// import closeImg from '../../assets/close.png';
|
|
89
|
+// import "slick-carousel/slick/slick.css";
|
|
90
|
+// import "slick-carousel/slick/slick-theme.css";
|
|
91
|
+// import classNames from 'classnames';
|
|
92
|
+// import { Carousel } from 'antd';
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+// const swiper = props => {
|
|
96
|
+// const [current, setCurrent] = useState(0)
|
|
97
|
+// const slider = useRef(null)
|
|
98
|
+
|
|
99
|
+// const settings = {
|
|
100
|
+// dots: true,
|
|
101
|
+// dotsClass: styles.dots,
|
|
102
|
+// infinite: true,
|
|
103
|
+// speed: 500,
|
|
104
|
+// arrows: false,
|
|
105
|
+// slidesToShow: 1,
|
|
106
|
+// slidesToScroll: 1,
|
|
107
|
+// appendDots: dots => <ul>{dots.map((_, inx) => {
|
|
108
|
+// return <li className={classNames({ [`${styles.active}`]: inx == current })} onClick={() => slider.current.slickGoTo(inx)} />
|
|
109
|
+// })}</ul>,
|
|
110
|
+// afterChange: inx => setCurrent(inx),
|
|
111
|
+// autoplay: true,
|
|
112
|
+// };
|
|
113
|
+// const [visible, setVisible] = useState(true)
|
|
114
|
+// const swpierData = [
|
|
115
|
+// { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592534834&di=2f2329437f205799e8be6abcc8fdb495&imgtype=0&src=http%3A%2F%2Fpic4.zhimg.com%2F50%2Fv2-7fece9a613445edb78271216c8c20c6d_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或' },
|
|
116
|
+// { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592534903&di=70fbf6793ff7e80ec38eb6204898fa35&imgtype=0&src=http%3A%2F%2Fpic2.zhimg.com%2F50%2Fv2-ba9d3691d1438e4fe4fef84faf3e7e33_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或嘻嘻嘻嘻嘻嘻' },
|
|
117
|
+// { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592674824&di=ebc27c383e5a402f8d0dfd2457b29c9d&imgtype=0&src=http%3A%2F%2Fpic1.zhimg.com%2F50%2Fv2-03d53b468e27ddc99f1ffcd17eec9700_hd.jpg', title: '哈哈哈哈哈哈哈哈哈哈或或或嘻嘻嘻嘻嘻嘻' },
|
|
118
|
+// { img: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1813762643,1914315241&fm=26&gp=0.jpg', title: '啦啦啦啦啦啦啦啦啦啦啦啦啦啦' },
|
|
119
|
+// { img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584592745048&di=e30a13762d0823ac5c1e3945a35ed55d&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201711%2F09%2F20171109195545_M2Bk3.jpeg', title: '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' },
|
|
120
|
+// ]
|
|
121
|
+// function handleSwiperItem(item) {
|
|
122
|
+// console.log(item, "item")
|
|
123
|
+// }
|
|
124
|
+// function closeSwiper() {
|
|
125
|
+// setVisible(false)
|
|
126
|
+// }
|
|
127
|
+// return (
|
|
128
|
+// <>
|
|
129
|
+// {visible && <div className={styles.mask}>
|
|
130
|
+// <div className={styles.content}>
|
|
131
|
+// <img src={closeImg} alt="" className={styles.close} onClick={() => closeSwiper()} />
|
|
132
|
+// <Carousel autoplay className={styles.carousel} >
|
|
133
|
+// {swpierData.map((item, index) =>
|
|
134
|
+// <div key={'swiper' + index} className={styles.carouselItem} onClick={() => handleSwiperItem(item)}>
|
|
135
|
+// <img style={{ width: '100%', height: '100%', borderRadius: '10px' }} src={item.img} alt="" />
|
|
136
|
+// <div className={styles.title}>{item.title}</div>
|
|
137
|
+// </div>
|
|
138
|
+// )}
|
|
139
|
+// </Carousel>
|
|
140
|
+// </div>
|
|
141
|
+// </div>}
|
|
142
|
+// </>
|
|
143
|
+// )
|
|
144
|
+// }
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+// export default swiper
|