xujing 5 年 前
コミット
f46d014e47
共有5 個のファイルを変更した254 個の追加1 個の削除を含む
  1. 2
    0
      package.json
  2. バイナリ
      src/assets/close.png
  3. 3
    1
      src/pages/Welcome.jsx
  4. 147
    0
      src/pages/swiper/index.jsx
  5. 102
    0
      src/pages/swiper/style.less

+ 2
- 0
package.json ファイルの表示

@@ -62,8 +62,10 @@
62 62
     "react-copy-to-clipboard": "^5.0.1",
63 63
     "react-document-title": "^2.0.3",
64 64
     "react-dom": "^16.8.6",
65
+    "react-slick": "^0.25.2",
65 66
     "react-zmage": "^0.8.5",
66 67
     "redux": "^4.0.1",
68
+    "swiper": "^5.3.6",
67 69
     "umi": "^2.13.3",
68 70
     "umi-plugin-pro-block": "^1.3.2",
69 71
     "umi-plugin-react": "^1.9.5",

バイナリ
src/assets/close.png ファイルの表示


+ 3
- 1
src/pages/Welcome.jsx ファイルの表示

@@ -3,6 +3,7 @@ import { Card, Typography, Alert, Row, Col } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import EchartsTest from '../components/EchartsTest';
5 5
 import IndexEcharts from './indexEcharts/index';
6
+import Swiper from './swiper/index';
6 7
 import router from 'umi/router';
7 8
 import request from '../utils/request';
8 9
 import apis from '../services/apis';
@@ -63,11 +64,12 @@ const welcome = (props) => {
63 64
             boxShadow: '0px  0.106rem 14px -15px rgba(107,130,230,1)',
64 65
             borderRadius: '12px', width: '32%',
65 66
           }}>
66
-            <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0',cursor: 'pointer' }}>最近7天新增 </span>
67
+            <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0', cursor: 'pointer' }}>最近7天新增 </span>
67 68
             <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount || '0'}</span>
68 69
           </div>
69 70
         }
70 71
       </div>
72
+      <Swiper />
71 73
       <IndexEcharts style={{ width: '100%' }} onReData={(e) => redata(e)} checkData={checkData}></IndexEcharts>
72 74
     </>
73 75
   )

+ 147
- 0
src/pages/swiper/index.jsx ファイルの表示

@@ -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

+ 102
- 0
src/pages/swiper/style.less ファイルの表示

@@ -0,0 +1,102 @@
1
+.mask{
2
+    width: 100vw;
3
+    height: 100vh;
4
+    background-color: rgba(0,0,0,0.32);
5
+    position: fixed;
6
+    z-index: 999;
7
+    top: 0;
8
+    left: 0;
9
+}
10
+
11
+.content{
12
+    width: 36vw;
13
+    min-width: 757px;
14
+    height: 21.3vw;
15
+    min-height: 435.6px;
16
+    position: absolute;
17
+    left: 50%;
18
+    top: 110px;
19
+    transform: translateX(-50%);
20
+    border-radius: 10px;
21
+    .close{
22
+        width: 40px;
23
+        height: 40px;
24
+        position: absolute;
25
+        top: -22px;
26
+        right: -22px;
27
+        z-index: 9;
28
+    }
29
+}
30
+
31
+.dots{
32
+    position: absolute;
33
+    bottom: 11px;
34
+    width: 100%;
35
+    padding: 0;
36
+    margin: 0;
37
+    list-style: none;
38
+    text-align: center;
39
+    li {
40
+        position: relative;
41
+        display: inline-block;
42
+        width: 12px;
43
+        height: 2px;
44
+        margin: 0 4px;
45
+        padding: 0;
46
+        cursor: pointer;
47
+        background: #fff;
48
+        opacity: 0.6;
49
+        &.active{
50
+            width: 16px;
51
+            height: 3px;
52
+            background: #fff;
53
+            opacity: 1;
54
+        }
55
+        button {
56
+            display: block;
57
+            width: 14px;
58
+            height: 2px;
59
+            padding: 0;
60
+            font-size: 0;
61
+            background: #fff;
62
+            border: 0;
63
+            border-radius: 1px;
64
+            outline: none;
65
+            cursor: pointer;
66
+            opacity: 0.6;
67
+            transition: all 0.5s;
68
+        }
69
+    }
70
+}
71
+.carousel {
72
+    width: 36vw;
73
+    min-width: 757px;
74
+    height: 21.3vw;
75
+    min-height: 435.6px;
76
+    border-radius: 10px;
77
+    // overflow: hidden;
78
+    
79
+    .carouselItem{
80
+        width: 36vw;
81
+        min-width: 757px;
82
+        height: 21.3vw;
83
+        min-height: 435.6px;
84
+        position: relative;
85
+        display: inline-block;
86
+        .title{
87
+            font-size: 0.12rem;
88
+            color: #fff;
89
+            position: absolute;
90
+            display: block;
91
+            width: 100%;
92
+            height: 0.16rem;
93
+            bottom: 30px ;
94
+            padding: 0 40px;
95
+            text-align: center;
96
+            overflow: hidden;
97
+            white-space: nowrap;
98
+            text-overflow: ellipsis;
99
+
100
+        }
101
+    }
102
+}