lisenzhou 2 år sedan
förälder
incheckning
64c44d3f06

+ 0
- 191
src/pages/sample/home/components/AreaChart.jsx Visa fil

@@ -1,191 +0,0 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
3
-import * as echarts from 'echarts/core';
4
-import Chart from '@/components/chart';
5
-
6
-export default (props) => {
7
-  const option = {
8
-    color: ['#80FFA5', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'],
9
-    // title: {
10
-    //   text: 'Gradient Stacked Area Chart'
11
-    // },
12
-    tooltip: {
13
-      trigger: 'axis',
14
-      axisPointer: {
15
-        type: 'cross',
16
-        label: {
17
-          backgroundColor: '#6a7985'
18
-        }
19
-      }
20
-    },
21
-    legend: {
22
-      data: ['Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5']
23
-    },
24
-    grid: {
25
-      left: '3%',
26
-      right: '4%',
27
-      bottom: '3%',
28
-      containLabel: true
29
-    },
30
-    xAxis: [
31
-      {
32
-        type: 'category',
33
-        boundaryGap: false,
34
-        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
35
-      }
36
-    ],
37
-    yAxis: [
38
-      {
39
-        type: 'value'
40
-      }
41
-    ],
42
-    series: [
43
-      {
44
-        name: 'Line 1',
45
-        type: 'line',
46
-        stack: 'Total',
47
-        smooth: true,
48
-        lineStyle: {
49
-          width: 0
50
-        },
51
-        showSymbol: false,
52
-        areaStyle: {
53
-          opacity: 0.8,
54
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
55
-            {
56
-              offset: 0,
57
-              color: 'rgb(128, 255, 165)'
58
-            },
59
-            {
60
-              offset: 1,
61
-              color: 'rgb(1, 191, 236)'
62
-            }
63
-          ])
64
-        },
65
-        emphasis: {
66
-          focus: 'series'
67
-        },
68
-        data: [140, 232, 101, 264, 90, 340, 250]
69
-      },
70
-      {
71
-        name: 'Line 2',
72
-        type: 'line',
73
-        stack: 'Total',
74
-        smooth: true,
75
-        lineStyle: {
76
-          width: 0
77
-        },
78
-        showSymbol: false,
79
-        areaStyle: {
80
-          opacity: 0.8,
81
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
82
-            {
83
-              offset: 0,
84
-              color: 'rgb(0, 221, 255)'
85
-            },
86
-            {
87
-              offset: 1,
88
-              color: 'rgb(77, 119, 255)'
89
-            }
90
-          ])
91
-        },
92
-        emphasis: {
93
-          focus: 'series'
94
-        },
95
-        data: [120, 282, 111, 234, 220, 340, 310]
96
-      },
97
-      {
98
-        name: 'Line 3',
99
-        type: 'line',
100
-        stack: 'Total',
101
-        smooth: true,
102
-        lineStyle: {
103
-          width: 0
104
-        },
105
-        showSymbol: false,
106
-        areaStyle: {
107
-          opacity: 0.8,
108
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
109
-            {
110
-              offset: 0,
111
-              color: 'rgb(55, 162, 255)'
112
-            },
113
-            {
114
-              offset: 1,
115
-              color: 'rgb(116, 21, 219)'
116
-            }
117
-          ])
118
-        },
119
-        emphasis: {
120
-          focus: 'series'
121
-        },
122
-        data: [320, 132, 201, 334, 190, 130, 220]
123
-      },
124
-      {
125
-        name: 'Line 4',
126
-        type: 'line',
127
-        stack: 'Total',
128
-        smooth: true,
129
-        lineStyle: {
130
-          width: 0
131
-        },
132
-        showSymbol: false,
133
-        areaStyle: {
134
-          opacity: 0.8,
135
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
136
-            {
137
-              offset: 0,
138
-              color: 'rgb(255, 0, 135)'
139
-            },
140
-            {
141
-              offset: 1,
142
-              color: 'rgb(135, 0, 157)'
143
-            }
144
-          ])
145
-        },
146
-        emphasis: {
147
-          focus: 'series'
148
-        },
149
-        data: [220, 402, 231, 134, 190, 230, 120]
150
-      },
151
-      {
152
-        name: 'Line 5',
153
-        type: 'line',
154
-        stack: 'Total',
155
-        smooth: true,
156
-        lineStyle: {
157
-          width: 0
158
-        },
159
-        showSymbol: false,
160
-        label: {
161
-          show: true,
162
-          position: 'top'
163
-        },
164
-        areaStyle: {
165
-          opacity: 0.8,
166
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
167
-            {
168
-              offset: 0,
169
-              color: 'rgb(255, 191, 0)'
170
-            },
171
-            {
172
-              offset: 1,
173
-              color: 'rgb(224, 62, 76)'
174
-            }
175
-          ])
176
-        },
177
-        emphasis: {
178
-          focus: 'series'
179
-        },
180
-        data: [220, 302, 181, 234, 210, 290, 150]
181
-      }
182
-    ]
183
-  };
184
-  
185
-
186
-  return (
187
-    <Card title='Gradient Stacked Area Chart'>
188
-      <Chart option={option} style={props.style}></Chart>
189
-    </Card>
190
-  )
191
-}

+ 124
- 41
src/pages/sample/home/components/Banner.jsx Visa fil

@@ -1,44 +1,127 @@
1
-import React from 'react';
2
-import { Row, Col, Card, Statistic } from 'antd';
3
-import { ArrowDownOutlined, ArrowUpOutlined, LikeOutlined } from '@ant-design/icons';
1
+import { Row, Col, Card, Statistic, Carousel } from "antd";
2
+import {
3
+  ArrowDownOutlined,
4
+  ArrowUpOutlined,
5
+  LikeOutlined,
6
+} from "@ant-design/icons";
7
+import React, { useState } from "react";
8
+import { getBannerList } from "@/services/rotationChart";
9
+
10
+import { useRef } from "react";
11
+import { useEffect } from "react";
12
+import moment from "moment";
13
+import VideoPlay from "./VideoPlay.jsx";
14
+import { floatDivide } from "@/utils";
15
+
16
+const contentStyle = {
17
+  height: "760px",
18
+  margin: "0 auto",
19
+  width: "100%",
20
+  // color: "#fff",
21
+  // lineHeight: "160px",
22
+  // textAlign: "center",
23
+  // background: "#364d79",
24
+};
4 25
 
5 26
 export default (props) => {
27
+  const [autoPlay, setAutoPlay] = useState(true);
28
+  const [current, setCurrent] = useState(0);
29
+  const [mouse, setMouse] = useState(false);
30
+  const [mediaList, setMediaList] = useState([]);
31
+
32
+  const ref = useRef();
33
+
34
+  const mouseRef = useRef(false);
35
+  const isVideoRef = useRef(false);
36
+  const isVideoPlayRef = useRef(false);
37
+  useEffect(() => {
38
+    getBannerList().then((res) => {
39
+   
40
+
41
+      setMediaList(
42
+        res?.records?.map((x) => {
43
+          if (x.type === "2") {
44
+            return {
45
+              ...x,
46
+              type: "video",
47
+              url: x.video,
48
+            };
49
+          } else {
50
+            return {
51
+              ...x,
52
+              type: "image",
53
+              url: x.image,
54
+            };
55
+          }
56
+        })
57
+      );
58
+    });
59
+    handNext();
60
+  }, []);
61
+
62
+  const handNext = () => {
63
+    setTimeout(() => {
64
+
65
+      if (!mouseRef.current && !isVideoRef.current && !isVideoPlayRef.current) {
66
+        ref.current?.next();
67
+      }
68
+      handNext();
69
+    }, 3000);
70
+  };
71
+
72
+  const onMouseEnter = () => {
73
+   
74
+    mouseRef.current = true;
75
+  };
76
+  const onMouseLeave = () => {
77
+    mouseRef.current = false;
78
+  };
79
+
6 80
   return (
7
-    <Row gutter={24}>
8
-      <Col span={6}>
9
-        <Card>
10
-          <Statistic title="Feedback" value={1128} prefix={<LikeOutlined />} />
11
-        </Card>
12
-      </Col>
13
-      <Col span={6}>
14
-        <Card>
15
-          <Statistic title="Unmerged" value={93} suffix="/ 100" />
16
-        </Card>
17
-      </Col>
18
-      <Col span={6}>
19
-        <Card>
20
-          <Statistic
21
-            title="Active"
22
-            value={11.28}
23
-            precision={2}
24
-            valueStyle={{ color: '#3f8600' }}
25
-            prefix={<ArrowUpOutlined />}
26
-            suffix="%"
27
-          />
28
-        </Card>
29
-      </Col>
30
-      <Col span={6}>
31
-        <Card>
32
-          <Statistic
33
-            title="Idle"
34
-            value={9.3}
35
-            precision={2}
36
-            valueStyle={{ color: '#cf1322' }}
37
-            prefix={<ArrowDownOutlined />}
38
-            suffix="%"
39
-          />
40
-        </Card>
41
-      </Col>
42
-    </Row>
43
-  )
44
-}
81
+    <>
82
+      <div
83
+        onMouseEnter={onMouseEnter}
84
+        onMouseLeave={onMouseLeave}
85
+        style={{ height: 800 }}
86
+      >
87
+        <Carousel
88
+          ref={ref}
89
+          afterChange={(cur) => {
90
+            setCurrent(cur);
91
+          }}
92
+        >
93
+          {mediaList?.map((x, index) => {
94
+            if (x.type === "image") {
95
+              return (
96
+                <div className="abc" key={index}>
97
+                  <div style={{ overflow: "hidden" }}>
98
+                    <img src={x.url} style={contentStyle}></img>
99
+                  </div>
100
+                </div>
101
+              );
102
+            }
103
+            if (x.type === "video") {
104
+
105
+              return (
106
+                <div key={index}>
107
+                  <VideoPlay
108
+                    url={x.url}
109
+                    isVideoPlayRef={isVideoPlayRef}
110
+                    index={index}
111
+                    current={current}
112
+                    contentStyle={contentStyle}
113
+                  ></VideoPlay>
114
+                </div>
115
+              );
116
+            }
117
+          })}
118
+        </Carousel>
119
+      </div>
120
+
121
+      {/* <div>
122
+
123
+        <video autoPlay src={video2} ></video>
124
+      </div> */}
125
+    </>
126
+  );
127
+};

+ 0
- 37
src/pages/sample/home/components/BarChart.jsx Visa fil

@@ -1,37 +0,0 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
3
-import Chart from '@/components/chart';
4
-
5
-export default (props) => {
6
-
7
-  const option = {
8
-    legend: {},
9
-    tooltip: {},
10
-    dataset: {
11
-      source: [
12
-        ['product', '2015', '2016', '2017'],
13
-        ['Matcha Latte', 43.3, 85.8, 93.7],
14
-        ['Milk Tea', 83.1, 73.4, 55.1],
15
-        ['Cheese Cocoa', 86.4, 65.2, 82.5],
16
-        ['Walnut Brownie', 72.4, 53.9, 39.1]
17
-      ]
18
-    },
19
-    xAxis: { type: 'category' },
20
-    yAxis: {},
21
-    grid: {
22
-      left: '3%',
23
-      right: '4%',
24
-      bottom: '3%',
25
-      containLabel: true
26
-    },
27
-    // Declare several bar series, each will be mapped
28
-    // to a column of dataset.source by default.
29
-    series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }]
30
-  };
31
-
32
-  return (
33
-    <Card title='Bar Chart'>
34
-      <Chart option={option} style={props.style}></Chart>
35
-    </Card>
36
-  )
37
-}

+ 0
- 112
src/pages/sample/home/components/PictorialBar.jsx Visa fil

@@ -1,112 +0,0 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
3
-import * as echarts from 'echarts/core';
4
-import Chart from '@/components/chart';
5
-
6
-
7
-export default (props) => {
8
-  let category = [];
9
-  let dottedBase = +new Date();
10
-  let lineData = [];
11
-  let barData = [];
12
-  for (let i = 0; i < 20; i++) {
13
-    let date = new Date((dottedBase += 3600 * 24 * 1000));
14
-    category.push(
15
-      [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-')
16
-    );
17
-    let b = Math.random() * 200;
18
-    let d = Math.random() * 200;
19
-    barData.push(b);
20
-    lineData.push(d + b);
21
-  }
22
-
23
-  const option = {
24
-    backgroundColor: '#0f375f',
25
-    tooltip: {
26
-      trigger: 'axis',
27
-      axisPointer: {
28
-        type: 'shadow'
29
-      }
30
-    },
31
-    legend: {
32
-      data: ['line', 'bar'],
33
-      textStyle: {
34
-        color: '#ccc'
35
-      }
36
-    },
37
-    xAxis: {
38
-      data: category,
39
-      axisLine: {
40
-        lineStyle: {
41
-          color: '#ccc'
42
-        }
43
-      }
44
-    },
45
-    yAxis: {
46
-      splitLine: { show: false },
47
-      axisLine: {
48
-        lineStyle: {
49
-          color: '#ccc'
50
-        }
51
-      }
52
-    },
53
-    series: [
54
-      {
55
-        name: 'line',
56
-        type: 'line',
57
-        smooth: true,
58
-        showAllSymbol: true,
59
-        symbol: 'emptyCircle',
60
-        symbolSize: 15,
61
-        data: lineData
62
-      },
63
-      {
64
-        name: 'bar',
65
-        type: 'bar',
66
-        barWidth: 10,
67
-        itemStyle: {
68
-          borderRadius: 5,
69
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
70
-            { offset: 0, color: '#14c8d4' },
71
-            { offset: 1, color: '#43eec6' }
72
-          ])
73
-        },
74
-        data: barData
75
-      },
76
-      {
77
-        name: 'line',
78
-        type: 'bar',
79
-        barGap: '-100%',
80
-        barWidth: 10,
81
-        itemStyle: {
82
-          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
83
-            { offset: 0, color: 'rgba(20,200,212,0.5)' },
84
-            { offset: 0.2, color: 'rgba(20,200,212,0.2)' },
85
-            { offset: 1, color: 'rgba(20,200,212,0)' }
86
-          ])
87
-        },
88
-        z: -12,
89
-        data: lineData
90
-      },
91
-      {
92
-        name: 'dotted',
93
-        type: 'pictorialBar',
94
-        symbol: 'rect',
95
-        itemStyle: {
96
-          color: '#0f375f'
97
-        },
98
-        symbolRepeat: true,
99
-        symbolSize: [12, 4],
100
-        symbolMargin: 1,
101
-        z: -10,
102
-        data: lineData
103
-      }
104
-    ]
105
-  };
106
-
107
-  return (
108
-    <Card title='Pictorial Chart'>
109
-      <Chart option={option} style={props.style}></Chart>
110
-    </Card>
111
-  )
112
-}

+ 0
- 48
src/pages/sample/home/components/PieChart.jsx Visa fil

@@ -1,48 +0,0 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
3
-import Chart from '@/components/chart';
4
-
5
-export default (props) => {
6
-
7
-  const option = {
8
-    // title: {
9
-    //   text: 'Referer of a Website',
10
-    //   subtext: 'Fake Data',
11
-    //   left: 'center'
12
-    // },
13
-    tooltip: {
14
-      trigger: 'item'
15
-    },
16
-    legend: {
17
-      orient: 'vertical',
18
-      left: 'left'
19
-    },
20
-    series: [
21
-      {
22
-        name: 'Access From',
23
-        type: 'pie',
24
-        radius: '50%',
25
-        data: [
26
-          { value: 1048, name: 'Search Engine' },
27
-          { value: 735, name: 'Direct' },
28
-          { value: 580, name: 'Email' },
29
-          { value: 484, name: 'Union Ads' },
30
-          { value: 300, name: 'Video Ads' }
31
-        ],
32
-        emphasis: {
33
-          itemStyle: {
34
-            shadowBlur: 10,
35
-            shadowOffsetX: 0,
36
-            shadowColor: 'rgba(0, 0, 0, 0.5)'
37
-          }
38
-        }
39
-      }
40
-    ]
41
-  };
42
-
43
-  return (
44
-    <Card title='Basic Pie Chart'>
45
-      <Chart option={option} style={props.style}></Chart>
46
-    </Card>
47
-  )
48
-}

+ 0
- 48
src/pages/sample/home/components/RadarChart.jsx Visa fil

@@ -1,48 +0,0 @@
1
-import React from 'react';
2
-import { Card } from 'antd';
3
-import Chart from '@/components/chart';
4
-
5
-export default (props) => {
6
-
7
-  const option = {
8
-    // title: {
9
-    //   text: 'Basic Radar Chart'
10
-    // },
11
-    legend: {
12
-      data: ['Allocated Budget', 'Actual Spending']
13
-    },
14
-    radar: {
15
-      // shape: 'circle',
16
-      indicator: [
17
-        { name: 'Sales', max: 6500 },
18
-        { name: 'Administration', max: 16000 },
19
-        { name: 'Information Technology', max: 30000 },
20
-        { name: 'Customer Support', max: 38000 },
21
-        { name: 'Development', max: 52000 },
22
-        { name: 'Marketing', max: 25000 }
23
-      ]
24
-    },
25
-    series: [
26
-      {
27
-        name: 'Budget vs spending',
28
-        type: 'radar',
29
-        data: [
30
-          {
31
-            value: [4200, 3000, 20000, 35000, 50000, 18000],
32
-            name: 'Allocated Budget'
33
-          },
34
-          {
35
-            value: [5000, 14000, 28000, 26000, 42000, 21000],
36
-            name: 'Actual Spending'
37
-          }
38
-        ]
39
-      }
40
-    ]
41
-  };
42
-
43
-  return (
44
-    <Card title='Basic Radar Chart'>
45
-      <Chart option={option} style={props.style}></Chart>
46
-    </Card>
47
-  )
48
-}

+ 55
- 0
src/pages/sample/home/components/VideoPlay.jsx Visa fil

@@ -0,0 +1,55 @@
1
+import { Row, Col, Card, Statistic, Carousel } from "antd";
2
+import {
3
+  ArrowDownOutlined,
4
+  ArrowUpOutlined,
5
+  LikeOutlined,
6
+} from "@ant-design/icons";
7
+import React, { useState } from "react";
8
+
9
+import { useRef } from "react";
10
+import { useEffect } from "react";
11
+
12
+// https://image.baidu.com/search/albumsdetail?tn=albumsdetail&word=%E5%AE%A0%E7%89%A9%E5%9B%BE%E7%89%87&fr=albumslist&album_tab=%E5%8A%A8%E7%89%A9&album_id=688&rn=30
13
+
14
+// https://image.baidu.com/search/albumsdetail?tn=albumsdetail&word=%E5%9F%8E%E5%B8%82%E5%BB%BA%E7%AD%91%E6%91%84%E5%BD%B1%E4%B8%93%E9%A2%98&fr=searchindex_album%20&album_tab=%E5%BB%BA%E7%AD%91&album_id=7&rn=30
15
+const VideoPlay = (props) => {
16
+  const { url, index, current, isVideoPlayRef, contentStyle } = props;
17
+
18
+  const ref = useRef();
19
+
20
+  useEffect(() => {
21
+    if (current == index) {
22
+      ref.current
23
+        ?.play()
24
+        .then((res) => {
25
+          isVideoPlayRef.current = true;
26
+        })
27
+        .catch((err) => {
28
+          console.log(err)
29
+          isVideoPlayRef.current = false;
30
+        });
31
+    } else {
32
+      ref.current.pause();
33
+      isVideoPlayRef.current = false;
34
+    }
35
+  }, [current, index]);
36
+
37
+  useEffect(() => {}, []);
38
+
39
+  return (
40
+    <>
41
+      <div style={contentStyle}>
42
+        <video
43
+          ref={ref}
44
+          autoPlay={false}
45
+          src={url}
46
+          onEnded={() => {
47
+            isVideoPlayRef.current = false;
48
+          }}
49
+          style={{ width: "100%", height: "100%", objectFit: "fill" }}
50
+        ></video>
51
+      </div>
52
+    </>
53
+  );
54
+};
55
+export default VideoPlay;

+ 0
- 22
src/pages/sample/home/index.jsx Visa fil

@@ -2,11 +2,6 @@ import React from 'react';
2 2
 import { Row, Col, Card, Space, Statistic } from 'antd';
3 3
 import Container from '@/components/page/Container';
4 4
 import Banner from './components/Banner';
5
-import AreaChart from './components/AreaChart';
6
-import BarChart from './components/BarChart';
7
-import PictorialBar from './components/PictorialBar';
8
-import RadarChart from './components/RadarChart';
9
-import PieChart from './components/PieChart';
10 5
 
11 6
 export default (props) => {
12 7
 
@@ -19,23 +14,6 @@ export default (props) => {
19 14
     <Container>
20 15
       <Banner />
21 16
 
22
-      <Row gutter={24} style={{ marginTop: '24px' }}>
23
-        <Col span={16}>
24
-          <AreaChart style={chartStyle}/>
25
-        </Col>
26
-        <Col span={8}>
27
-          <RadarChart style={chartStyle}/>
28
-        </Col>
29
-      </Row>
30
-
31
-      <Row gutter={24} style={{ marginTop: '24px' }}>
32
-        <Col span={8}>
33
-          <PieChart style={chartStyle}/>
34
-        </Col>
35
-        <Col span={16}>
36
-          <BarChart style={chartStyle}/>
37
-        </Col>
38
-      </Row>
39 17
     </Container>
40 18
   )
41 19
 }

+ 12
- 7
src/services/rotationChart.js Visa fil

@@ -1,25 +1,27 @@
1
-import request from '@/utils/request';
1
+import request from "@/utils/request";
2 2
 
3 3
 /**
4 4
  * 查询列表
5 5
  * @param {*} params
6 6
  * @returns
7 7
  */
8
-export const getBannerList = (params) => request('/banner', { params });
8
+export const getBannerList = (params) =>
9
+  request("/banner", { params, successTip: false });
9 10
 
10 11
 /**
11 12
  * 详情
12 13
  * @param {*} id
13 14
  * @returns
14 15
  */
15
-export const getBannerdById = (id) => request(`/banner/${id}`);
16
+export const getBannerdById = (id) =>
17
+  request(`/banner/${id}`, { successTip: false });
16 18
 
17 19
 /**
18 20
  * 新增
19 21
  * @param {*} data
20 22
  * @returns
21 23
  */
22
-export const addBanner = (data) => request('/banner', { method: 'post', data });
24
+export const addBanner = (data) => request("/banner", { method: "post", data });
23 25
 
24 26
 /**
25 27
  * 新增
@@ -27,18 +29,21 @@ export const addBanner = (data) => request('/banner', { method: 'post', data });
27 29
  * @param {*} data
28 30
  * @returns
29 31
  */
30
-export const updataBanner = (id, data) => request(`/banner/${id}`, { method: 'put', data });
32
+export const updataBanner = (id, data) =>
33
+  request(`/banner/${id}`, { method: "put", data });
31 34
 
32 35
 /**
33 36
  * 删除
34 37
  * @param {*} id
35 38
  * @returns
36 39
  */
37
-export const deleteBanner = (id) => request(`/banner/${id}`, { method: 'delete' });
40
+export const deleteBanner = (id) =>
41
+  request(`/banner/${id}`, { method: "delete" });
38 42
 
39 43
 /**
40 44
  * 上传文件
41 45
  * @param {*} id
42 46
  * @returns
43 47
  */
44
- export const uploadFile = (data) => request(`/upload`, { method: 'POST', data });
48
+export const uploadFile = (data) =>
49
+  request(`/upload`, { method: "POST", data });