瀏覽代碼

Merge branch 'master' of http://git.ycjcjy.com/nanyang/machinery-admin

李志伟 3 年之前
父節點
當前提交
eb41ab8586

二進制
src/assets/images/screen/map-bg-header.png 查看文件


二進制
src/assets/images/screen/map-bg-lbt.png 查看文件


二進制
src/assets/images/screen/map-bg-mbt.png 查看文件


二進制
src/assets/images/screen/map-bg-rbt.png 查看文件


二進制
src/assets/images/screen/map-bg.png 查看文件


二進制
src/assets/images/screen/map-marker.png 查看文件


二進制
src/assets/images/screen/statis-bg.png 查看文件


二進制
src/assets/images/screen/statis-icon1.png 查看文件


二進制
src/assets/images/screen/statis-icon2.png 查看文件


二進制
src/assets/images/screen/statis-icon3.png 查看文件


二進制
src/assets/images/screen/statis-icon4.png 查看文件


+ 2
- 2
src/components/AMap/loader.js 查看文件

@@ -1,7 +1,7 @@
1 1
 import AMapLoader from '@amap/amap-jsapi-loader';
2 2
 
3
-const WEB_KEY = '29259f677b42900507074fd92ecb628a';
4
-const SERVER_KEY = '3be0a9567a794d2690d378476f057a6f';
3
+const WEB_KEY = '7c02d93b855ab284c12911c231aa2233';
4
+const SERVER_KEY = 'a30b66a26ea1890fd656cf11cb2647fb';
5 5
 
6 6
 export default (plugins, uiPlugins) => {
7 7
   return AMapLoader.load({

+ 6
- 6
src/components/GeoMap/geoPolygon.js 查看文件

@@ -12,13 +12,13 @@ export default (AMap, map) => {
12 12
   const pathArray = [outer, holes];
13 13
 
14 14
   const polygon = new AMap.Polygon({
15
-    pathL: pathArray,
16
-    strokeColor: '#3D81F0',
15
+    zIndex: 6,
16
+    path: pathArray,
17
+    strokeColor: '#001024',
17 18
     strokeWeight: 1,
18
-    strokeOpacity: 0.1,
19
-    fillColor: '#3D81F0',
20
-    fillOpacity: 0.5,
19
+    strokeOpacity: 0.5,
20
+    fillColor: '#061E3F',
21
+    fillOpacity: 1,
21 22
   });
22
-  polygon.setPath(pathArray);
23 23
   map.add(polygon);
24 24
 };

+ 44
- 7
src/components/GeoMap/index.jsx 查看文件

@@ -1,27 +1,64 @@
1
-import React, { useEffect, useRef } from 'react';
1
+import React, { useEffect, useRef, useState } from 'react';
2 2
 import loader from '@/components/AMap/loader';
3
+import getMarker from './marker';
3 4
 import geoPolygon from './geoPolygon';
5
+import Styles from './style.less';
4 6
 
5 7
 const plugins = [];
6 8
 
7 9
 export default (props) => {
8 10
   const container = useRef();
11
+  const amapRef = useRef();
12
+  const [map, setMap] = useState();
9 13
 
10 14
   useEffect(() => {
11 15
     loader(plugins).then((AMap) => {
12
-      const map = new AMap.Map(container.current, {
13
-        mapStyle: 'amap://styles/darkblue',
16
+      amapRef.current = AMap;
17
+      const mapInst = new AMap.Map(container.current, {
18
+        // mapStyle: 'amap://styles/669a7d8709a9bab0945747a1a1db3327',
19
+        mapStyle: 'amap://styles/blue',
14 20
         zoom: 10,
15 21
         resizeEnable: true,
16 22
         center: [112.092716, 32.681642],
17 23
       });
18 24
 
19
-      map.setFeatures(['road', 'bg']); // 只显示道路
20
-
21 25
       // 遮罩层;
22
-      geoPolygon(AMap, map);
26
+      geoPolygon(AMap, mapInst);
27
+
28
+      //
29
+      setMap(mapInst);
23 30
     });
24 31
   }, []);
25 32
 
26
-  return <div ref={container} style={{ height: '100%' }} />;
33
+  useEffect(() => {
34
+    if (!map) return;
35
+
36
+    // 先搞一个 marker demo
37
+    getMarker(amapRef.current, map, {
38
+      position: [112.092716, 32.681642],
39
+      extData: { value: '68辆' },
40
+    });
41
+  }, [map]);
42
+
43
+  return (
44
+    <div className={Styles['geo-map-container']}>
45
+      {/* 占位图片 */}
46
+      <div className={Styles['geo-map-header']}>
47
+        <div />
48
+        <div />
49
+        <div />
50
+      </div>
51
+
52
+      <div className={Styles['geo-map-body']}>
53
+        <div ref={container} />
54
+      </div>
55
+
56
+      {/* 占位图片 */}
57
+      <div className={Styles['geo-map-footer']}>
58
+        <div />
59
+        <div />
60
+        <div />
61
+      </div>
62
+    </div>
63
+  );
27 64
 };

+ 36
- 0
src/components/GeoMap/marker.js 查看文件

@@ -0,0 +1,36 @@
1
+import markerImg from '@/assets/images/screen/map-marker.png';
2
+
3
+export default (AMap, map, opts = {}) => {
4
+  const marker = new AMap.Marker({
5
+    map,
6
+    icon: markerImg,
7
+    anchor: 'top-center',
8
+    offset: new AMap.Pixel(0, 0),
9
+    ...opts,
10
+  });
11
+
12
+  let show = false;
13
+  const content = opts?.extData?.value;
14
+
15
+  marker.on('click', () => {
16
+    if (show) {
17
+      marker.setLabel({ content: '' });
18
+      show = false;
19
+      return;
20
+    }
21
+
22
+    if (!content) {
23
+      marker.setLabel({ content: '' });
24
+    } else {
25
+      marker.setLabel({
26
+        direction: 'top',
27
+        offset: new AMap.Pixel(0, 0),
28
+        content: `<div class='geo-map-marker-label'><div class='geo-map-marker-label-text'>${content}</div></div>`,
29
+      });
30
+    }
31
+
32
+    show = true;
33
+  });
34
+
35
+  return marker;
36
+};

+ 71
- 0
src/components/GeoMap/style.less 查看文件

@@ -0,0 +1,71 @@
1
+.geo-map-container {
2
+  width: 100%;
3
+  height: 100%;
4
+  overflow: hidden;
5
+  border-top-left-radius: 12px;
6
+  border-top-right-radius: 12px;
7
+
8
+  .geo-map-body {
9
+    height: calc(100% - 54px);
10
+    padding: 0 20px;
11
+    background-color: #061e3f;
12
+    border-right: 1px solid rgba(61, 129, 240, 0.5);
13
+    border-left: 1px solid rgba(61, 129, 240, 0.5);
14
+
15
+    & > div {
16
+      height: 100%;
17
+    }
18
+  }
19
+
20
+  .geo-map-header {
21
+    display: flex;
22
+    background-color: #061e3f;
23
+    & > div {
24
+      &:first-child {
25
+        flex: 1;
26
+        height: 37px;
27
+        border-top: 1px solid rgba(61, 129, 240, 0.5);
28
+        border-left: 1px solid rgba(61, 129, 240, 0.5);
29
+        border-top-left-radius: 12px;
30
+      }
31
+      &:last-child {
32
+        flex: 1;
33
+        height: 37px;
34
+        border-top: 1px solid rgba(61, 129, 240, 0.5);
35
+        border-right: 1px solid rgba(61, 129, 240, 0.5);
36
+        border-top-right-radius: 12px;
37
+      }
38
+      &:nth-child(2) {
39
+        flex: none;
40
+        width: 326px;
41
+        height: 37px;
42
+        background: #061e3f url('~@/assets/images/screen/map-bg-header.png') no-repeat center 100%;
43
+      }
44
+    }
45
+  }
46
+
47
+  .geo-map-footer {
48
+    display: flex;
49
+    height: 17px;
50
+
51
+    & > div {
52
+      &:first-child {
53
+        flex: none;
54
+        width: 99px;
55
+        height: 17px;
56
+        background: url('~@/assets/images/screen/map-bg-lbt.png') no-repeat 100% 100%;
57
+      }
58
+      &:last-child {
59
+        flex: none;
60
+        width: 99px;
61
+        height: 17px;
62
+        background: url('~@/assets/images/screen/map-bg-rbt.png') no-repeat 100% 100%;
63
+      }
64
+      &:nth-child(2) {
65
+        flex: 1;
66
+        height: 17px;
67
+        background: url('~@/assets/images/screen/map-bg-mbt.png') repeat-x;
68
+      }
69
+    }
70
+  }
71
+}

+ 32
- 0
src/components/ScreenBox/StatisCard/index.jsx 查看文件

@@ -0,0 +1,32 @@
1
+import React, { useMemo } from 'react';
2
+
3
+import icon1 from '@/assets/images/screen/statis-icon1.png';
4
+import icon2 from '@/assets/images/screen/statis-icon2.png';
5
+import icon3 from '@/assets/images/screen/statis-icon3.png';
6
+import icon4 from '@/assets/images/screen/statis-icon4.png';
7
+import Styles from './style.less';
8
+
9
+const icon = {
10
+  icon1,
11
+  icon2,
12
+  icon3,
13
+  icon4,
14
+};
15
+
16
+export default (props) => {
17
+  const titleStyle = useMemo(() => ({ color: props.color || '#23E8AE' }), [props.color]);
18
+
19
+  return (
20
+    <div className={Styles['statis-card']}>
21
+      <div>
22
+        <div className={Styles['statis-title']} style={titleStyle}>
23
+          <span>
24
+            <img src={icon[props.icon]} alt="" />
25
+          </span>
26
+          <span>{props.value}</span>
27
+        </div>
28
+        <div className={Styles['statis-subtitle']}>{props.title}</div>
29
+      </div>
30
+    </div>
31
+  );
32
+};

+ 41
- 0
src/components/ScreenBox/StatisCard/style.less 查看文件

@@ -0,0 +1,41 @@
1
+.statis-card {
2
+  display: grid;
3
+  width: 100%;
4
+
5
+  height: 96px;
6
+  border: 6px solid #fff;
7
+  border-image: url('~@/assets/images/screen/statis-bg.png');
8
+  border-image-slice: 3 6 4 fill;
9
+  border-image-repeat: repeat;
10
+  place-items: center;
11
+
12
+  & + .statis-card {
13
+    margin-left: 30px;
14
+  }
15
+
16
+  .statis-title {
17
+    color: #23e8ae;
18
+    font-size: 28px;
19
+    line-height: 28px;
20
+    letter-spacing: 2px;
21
+
22
+    span + span {
23
+      display: inline-block;
24
+      margin-left: 4px;
25
+    }
26
+
27
+    img {
28
+      width: 24px;
29
+      height: 24px;
30
+      margin-bottom: 2px; // line-height: 28px;
31
+    }
32
+  }
33
+
34
+  .statis-subtitle {
35
+    margin-top: 1em;
36
+    color: rgba(255, 255, 255, 0.7);
37
+    font-weight: bold;
38
+    font-size: 12px;
39
+    letter-spacing: 2px;
40
+  }
41
+}

+ 19
- 0
src/global.less 查看文件

@@ -55,3 +55,22 @@ ol {
55 55
     min-height: 100vh;
56 56
   }
57 57
 }
58
+
59
+.amap-marker-label {
60
+  background: transparent;
61
+  border: none;
62
+}
63
+
64
+.geo-map-marker-label {
65
+  display: inline-block;
66
+  padding: 20px;
67
+  background: rgba(0, 0, 0, 0.4);
68
+}
69
+
70
+.geo-map-marker-label-text {
71
+  font-size: 24px;
72
+  line-height: 24px;
73
+  background-image: linear-gradient(180deg, #fca790 0%, #e63404 93.84765625%);
74
+  background-clip: text;
75
+  -webkit-text-fill-color: transparent;
76
+}

+ 9
- 4
src/pages/MonitoringScreen/index.jsx 查看文件

@@ -13,6 +13,7 @@ import DateCommponetsBottomRight from './DateCommponetsBottomRight';
13 13
 import DateCommponetsBottomLeft from './DateCommponetsBottomLeft';
14 14
 
15 15
 import Styles from './style.less';
16
+import StatisCard from '@/components/ScreenBox/StatisCard';
16 17
 export default (props) => {
17 18
   const screenRef = useRef();
18 19
   const [height, setHeight] = useState('auto');
@@ -44,20 +45,24 @@ export default (props) => {
44 45
           <div className={Styles['grail-header']}>
45 46
             <ScreenHeader weather="多云 21-28 °C" />
46 47
           </div>
47
-          <div className={classNames(Styles['grail-container'], Styles['mg-tp-40'])}>
48
+          <div className={classNames(Styles['grail-container'], Styles['pd-tp-40'])}>
48 49
             <div className={Styles['grail-left']}>
49 50
               <DateCommponetsLeft />
50
-              <div className={Styles['mg-tp-40']}>{/* 占位 */}</div>
51
-              <DateCommponetsBottomLeft />
52 51
             </div>
53 52
             <div className={classNames(Styles['grail-content'], Styles['pd-lr-40'])}>
53
+              <div className={Styles['statis-container']}>
54
+                <StatisCard color="#23E8AE" icon="icon1" value={2346} title="农机总数(台)" />
55
+                <StatisCard color="#0BDAFF" icon="icon2" value={528} title="农机使用数(台)" />
56
+                <StatisCard color="#F5CC5C" icon="icon3" value={168} title="总预约数(台)" />
57
+                <StatisCard color="#C579FF" icon="icon4" value={1568} title="总服务数(台)" />
58
+              </div>
54 59
               <GeoMap></GeoMap>
55 60
             </div>
56 61
             <div className={Styles['grail-right']}>
57 62
               <DateCommponetsBottomRight />
58 63
             </div>
59 64
           </div>
60
-          <div className={classNames(Styles['grail-footer'], Styles['mg-tp-40'])}></div>
65
+          <div className={classNames(Styles['grail-footer'], Styles['pd-tp-40'])}></div>
61 66
         </div>
62 67
       </div>
63 68
     </PageHeaderWrapper>

+ 23
- 3
src/pages/MonitoringScreen/style.less 查看文件

@@ -16,15 +16,18 @@
16 16
   }
17 17
 
18 18
   .grail-layout {
19
+    display: flex;
20
+    flex-direction: column;
19 21
     height: 100%;
20 22
 
21 23
     .grail-header,
22 24
     .grail-footer {
23
-      //
25
+      flex: none;
24 26
     }
25 27
 
26 28
     .grail-container {
27 29
       display: flex;
30
+      flex: 1;
28 31
       height: 100%;
29 32
 
30 33
       .grail-left,
@@ -33,10 +36,27 @@
33 36
       }
34 37
 
35 38
       .grail-content {
39
+        display: flex;
36 40
         flex: 2;
41
+        flex-direction: column;
42
+
43
+        & > div {
44
+          &:first-child {
45
+            flex: none;
46
+          }
47
+
48
+          &:last-child {
49
+            flex: 1;
50
+          }
51
+        }
37 52
       }
38 53
     }
39 54
   }
55
+
56
+  .statis-container {
57
+    display: flex;
58
+    margin-bottom: 30px;
59
+  }
40 60
 }
41 61
 
42 62
 .pd-lr-40 {
@@ -44,6 +64,6 @@
44 64
   padding-left: 40px;
45 65
 }
46 66
 
47
-.mg-tp-40 {
48
-  margin-top: 40px;
67
+.pd-tp-40 {
68
+  padding-top: 40px;
49 69
 }