李志伟 3 gadus atpakaļ
vecāks
revīzija
4ca92d0c4d

+ 24
- 0
project.private.config.json Parādīt failu

@@ -0,0 +1,24 @@
1
+{
2
+  "condition": {
3
+    "plugin": {
4
+      "list": []
5
+    },
6
+    "game": {
7
+      "list": []
8
+    },
9
+    "gamePlugin": {
10
+      "list": []
11
+    },
12
+    "miniprogram": {
13
+      "list": [
14
+        {
15
+          "name": "",
16
+          "pathName": "pages/machineryList/index",
17
+          "query": "",
18
+          "scene": null,
19
+          "launchMode": "default"
20
+        }
21
+      ]
22
+    }
23
+  }
24
+}

+ 7
- 5
src/components/Jianbian/index.jsx Parādīt failu

@@ -2,16 +2,18 @@ import { View } from '@tarojs/components'
2 2
 import './style.less'
3 3
 
4 4
 export default (props) => {
5
-  const { status } = props
5
+  const { status, value, type } = props
6 6
   return (
7 7
     <View className={['jianbian',
8
-      status == 1 ? 'waitClass' :
9
-        status == 2 ? 'workingClass' :
10
-          status == 3 ? 'overClass' : ''
8
+      type == 'machinery' ?
9
+        (value ? 'workingClass' : 'waitClass') :
10
+        status == 1 ? 'waitClass' :
11
+          status == 2 ? 'workingClass' :
12
+            status == 3 ? 'overClass' : ''
11 13
     ]}
12 14
     >
13 15
       <View className='text'>
14
-        {status == 1 ? '待作业' : status == 2 ? '进行中' : status == 3 ? '已完成' : ''}
16
+        {type == 'machinery' ? (value ? '使用中' : '空闲中') : status == 1 ? '待作业' : status == 2 ? '进行中' : status == 3 ? '已完成' : ''}
15 17
       </View>
16 18
     </View>
17 19
   )

+ 2
- 2
src/pages/index/index.jsx Parādīt failu

@@ -18,7 +18,7 @@ import "./index.less";
18 18
 
19 19
 export default withLayout((props) => {
20 20
   const { router } = props
21
-  let { tab, isLogin } = router.params
21
+  let { tab } = router.params
22 22
   const { location,setLocation } = useModel('location')
23 23
   const [currentTab, setCurrentTab] = useState(0);
24 24
   const handleClick = (val) => {
@@ -47,7 +47,7 @@ export default withLayout((props) => {
47 47
       <View className='index-container'>
48 48
         {currentTab === 0 && <Order />}
49 49
         {currentTab === 1 && <Job />}
50
-        {currentTab === 2 && <User isLogin={isLogin} />}
50
+        {currentTab === 2 && <User />}
51 51
       </View>
52 52
       <View className='index-tabbar'>
53 53
         <View

+ 1
- 1
src/pages/login/index.jsx Parādīt failu

@@ -89,7 +89,7 @@ export default (props) => {
89 89
           icon: 'none',
90 90
           duration: 1000
91 91
         })
92
-        Taro.reLaunch({ url: '/pages/index/index?tab=2&&isLogin=true' });
92
+        Taro.reLaunch({ url: '/pages/index/index?tab=2' });
93 93
       }).catch((e) => {
94 94
         Taro.showToast({
95 95
           title: '手机号或者验证码不正确',

+ 23
- 25
src/pages/machineryDetail/index.jsx Parādīt failu

@@ -1,28 +1,24 @@
1
+import { useEffect, useState } from "react"
1 2
 import { View, Image, ScrollView, Swiper, SwiperItem } from "@tarojs/components"
2 3
 import CustomNav from "@/components/CustomNav"
3 4
 import Jianbian from "@/components/Jianbian"
4 5
 import withLayout from '@/layouts'
5
-import banner1 from '@/assets/banner/1.jpg'
6
-import banner2 from '@/assets/banner/2.jpg'
6
+import { useModel } from "@/store"
7
+import { getMachineryDetail } from '@/services/machinery'
7 8
 import clockImg from '@/assets/machinery/date.png'
8 9
 import micon from '@/assets/machinery/micon2.png'
9 10
 import './style.less'
10 11
 
11 12
 export default withLayout((props) => {
12
-  const imgList = [
13
-    {
14
-      thumb: banner1
15
-    },
16
-    {
17
-      thumb: banner1
18
-    },
19
-    {
20
-      thumb: banner1
21
-    },
22
-    {
23
-      thumb: banner1
24
-    }
25
-  ]
13
+  const { router } = props
14
+  const { id } = router.params
15
+  const { location } = useModel('location')
16
+  const [machinery, setMachinery] = useState()
17
+  useEffect(() => {
18
+    getMachineryDetail(id, { location: location, attached: true }).then((res) => {
19
+      setMachinery(res)
20
+    })
21
+  }, [])
26 22
   return (
27 23
     <View className='page-index'>
28 24
       <View className='index-navbar'>
@@ -35,29 +31,31 @@ export default withLayout((props) => {
35 31
             autoplay
36 32
             className='swiper'
37 33
           >
38
-            {imgList.map((item, inx) => (
34
+            {machinery?.imagesList?.map((item, inx) => (
39 35
               <SwiperItem key={inx}>
40
-                <Image src={item.thumb} mode='widthFix' className='storeImage' />
36
+                <Image src={item.url} mode='widthFix' className='storeImage' />
41 37
               </SwiperItem>
42 38
             ))}
43 39
           </Swiper>
44 40
           <View className='detailContent'>
45
-            <Jianbian status='1' />
46
-            <View className='detialName'>收割机001--S001</View>
41
+            <Jianbian value={machinery?.jobStatus} type='machinery' />
42
+            <View className='detialName'>{machinery?.name}</View>
47 43
             <View className='detailTime'>
48 44
               <Image src={clockImg} className='clockImg' />
49 45
               距离上次使用时间为三天
50 46
             </View>
51 47
             <View className='title'>
52 48
               <Image src={micon} className='detailIcon' />
53
-              作业详情
49
+              农机详情
54 50
               <Image src={micon} className='detailIcon' />
55 51
             </View>
56 52
             <View>
57
-              <Image src={banner1} className='contentImg' />
58
-              <View className='contentText'>6666666</View>
59
-              <Image src={banner2} className='contentImg' />
60
-              <Image src={banner1} className='contentImg' />
53
+              {machinery?.contentList?.map(item => {
54
+                return (item.contentType === 'image' ?
55
+                  <Image src={item.content} className='contentImg' /> :
56
+                  <View className='contentText'>{item.content}</View>
57
+                )
58
+              })}
61 59
             </View>
62 60
           </View>
63 61
         </ScrollView>

+ 10
- 11
src/pages/machineryList/Card/index.jsx Parādīt failu

@@ -1,18 +1,17 @@
1
-import { View,Image } from "@tarojs/components"
1
+import { View, Image } from "@tarojs/components"
2 2
 import Jianbian from "@/components/Jianbian"
3
-import banner1 from '@/assets/banner/2.jpg'
4 3
 import './style.less'
5 4
 
6 5
 export default (props) => {
7
-  const {onClick,goMap}=props
6
+  const { value, onClick, goMap } = props
8 7
   return (
9
-  <View className='machineryCard'>
10
-    <Jianbian status='1' />
11
-    <Image src={banner1} mode='aspectFill' onClick={onClick} />
12
-    <View className='info'>
13
-      <View className='machineryName' onClick={onClick} >收割机001--S01</View>
14
-      <View className='goMap' onClick={goMap}>进入地图 {">"}{">"}</View>
15
-    </View>    
16
-  </View>
8
+    <View className='machineryCard'>
9
+      <Jianbian value={value.jobStatus} type='machinery' />
10
+      <Image src={value.thumb}  mode='aspectFill' onClick={onClick} />
11
+      <View className='info'>
12
+        <View className='machineryName' onClick={onClick} >{value.name}</View>
13
+        <View className='goMap' onClick={goMap}>进入地图 {">"}{">"}</View>
14
+      </View>
15
+    </View>
17 16
   )
18 17
 }

+ 15
- 13
src/pages/machineryList/index.jsx Parādīt failu

@@ -1,27 +1,27 @@
1
-import { useEffect } from "react"
1
+import { useEffect, useState } from "react"
2 2
 import Taro from "@tarojs/taro"
3 3
 import { View, ScrollView } from "@tarojs/components"
4 4
 import CustomNav from "@/components/CustomNav"
5 5
 import withLayout from '@/layouts'
6
-import {getMachineryList} from '@/services/machinery'
6
+import { getMachineryList } from '@/services/machinery'
7 7
 import { useModel } from "@/store"
8 8
 import MachineryCard from './Card'
9 9
 import './style.less'
10 10
 
11 11
 export default withLayout((props) => {
12 12
   const { location } = useModel('location')
13
-
14
-  const goDetail=()=>{
15
-    Taro.navigateTo({ url: '/pages/machineryDetail/index' });
13
+  const [machinery, setMachinery] = useState([])
14
+  const goDetail = (val) => {
15
+    Taro.navigateTo({ url: `/pages/machineryDetail/index?id=${val}` });
16 16
   }
17
-  const goMap=()=>{
17
+  const goMap = () => {
18 18
     Taro.navigateTo({ url: '/pages/machineryMap/index' });
19 19
   }
20
-  useEffect(()=>{
21
-    getMachineryList({location:location}).then((res)=>{
22
-      
20
+  useEffect(() => {
21
+    getMachineryList({ location: location }).then((res) => {
22
+      setMachinery(res.records)
23 23
     })
24
-  },[])
24
+  }, [])
25 25
   return (
26 26
     <View className='page-index'>
27 27
       <View className='index-navbar'>
@@ -29,9 +29,11 @@ export default withLayout((props) => {
29 29
       </View>
30 30
       <View className='index-container machineryListContent'>
31 31
         <ScrollView scrollY style={{ height: '100%' }}>
32
-          <MachineryCard onClick={()=>goDetail()}  goMap={()=>goMap()} />
33
-          <MachineryCard />
34
-          <MachineryCard />
32
+          {
33
+            machinery?.map((item) => {
34
+              return <MachineryCard value={item} onClick={() => goDetail(item.machineryId)} goMap={() => goMap()} />
35
+            })
36
+          }
35 37
         </ScrollView>
36 38
       </View>
37 39
     </View>

+ 69
- 22
src/pages/machineryMap/index.jsx Parādīt failu

@@ -1,43 +1,90 @@
1 1
 import Taro from "@tarojs/taro"
2
-import { useState } from "react"
2
+import { useState, useEffect } from "react"
3 3
 import { View, Map, Image } from "@tarojs/components"
4 4
 import withLayout from '@/layouts'
5
+import { getMachineryList } from '@/services/machinery'
6
+import { useModel } from "@/store"
5 7
 import CustomNav from "@/components/CustomNav"
6 8
 import m1 from '@/assets/machinery/greenMachinery.png'
7 9
 import m2 from '@/assets/machinery/orangeMachinery.png'
8 10
 import picon from '@/assets/comm/position.png'
9 11
 import './style.less'
10 12
 
13
+
11 14
 export default withLayout((props) => {
12 15
   const [show, setShow] = useState(false)
13
-  const markers = [
16
+  const { location } = useModel('location')
17
+  const [machineryList, setMachineryList] = useState([])
18
+  const [markerList, setMarkerList] = useState([])
19
+  const [current, setCurrent] = useState()
20
+
21
+  const locList = [
22
+    {
23
+      longitude: 112.106514,
24
+      latitude: 32.685927
25
+    },
26
+    {
27
+      longitude: 112.100406,
28
+      latitude: 32.673406
29
+    },
30
+    {
31
+      longitude: 112.06397,
32
+      latitude: 32.670488
33
+    },
34
+    {
35
+      longitude: 112.05434,
36
+      latitude: 32.685684
37
+    },
14 38
     {
15
-      id: 1,
16
-      longitude: 112.105348,
17
-      latitude: 32.697352,
18
-      iconPath: m1,
19
-      width: 50,
20
-      height: 50
39
+      longitude: 112.058724,
40
+      latitude: 32.701302
21 41
     },
22 42
     {
23
-      id: 2,
24
-      longitude: 112.120295,
25
-      latitude: 32.686656,
26
-      iconPath: m2,
27
-      width: 50,
28
-      height: 50
29
-    }
43
+      longitude: 112.015102,
44
+      latitude: 32.665504
45
+    },
46
+    {
47
+      longitude: 112.010503,
48
+      latitude: 32.685502
49
+    },
50
+    {
51
+      longitude: 112.097747,
52
+      latitude: 32.651764
53
+    },
54
+    {
55
+      longitude: 112.149705,
56
+      latitude: 32.664957
57
+    },
58
+    {
59
+      longitude: 112.16185,
60
+      latitude: 32.701241
61
+    },
30 62
   ]
31 63
   const handleClick = (e) => {
32
-    console.log(e.markerId)
64
+    setCurrent(machineryList[e.markerId])
33 65
     setShow(true)
34 66
   }
35
-  const goDetail = () => {
36
-    Taro.navigateTo({ url: '/pages/machineryDetail/index' });
67
+  const goDetail = (val) => {
68
+    Taro.navigateTo({ url: `/pages/machineryDetail/index?id=${val}` });
37 69
   }
38
-  const goList=()=>{
70
+  const goList = () => {
39 71
     Taro.navigateTo({ url: '/pages/machineryList/index' });
40 72
   }
73
+  useEffect(() => {
74
+    getMachineryList({ location: location }).then((res) => {
75
+      setMachineryList(res.records)
76
+      setMarkerList(res.records.map((item, index) => {
77
+        return {
78
+          id: index,
79
+          longitude: locList[index % 10].longitude,
80
+          latitude: locList[index % 10].latitude,
81
+          iconPath: item.jobStatus?m1:m2,
82
+          width: 50,
83
+          height: 50
84
+        }
85
+      }))
86
+    })
87
+  }, [])
41 88
   return (
42 89
     <View className='page-index'>
43 90
       <View className='index-navbar'>
@@ -47,7 +94,7 @@ export default withLayout((props) => {
47 94
         <Map
48 95
           longitude={112.092716}
49 96
           latitude={32.681642}
50
-          markers={markers}
97
+          markers={markerList}
51 98
           className='map'
52 99
           onMarkerTap={handleClick}
53 100
           onRegionChange={() => setShow(false)}
@@ -57,8 +104,8 @@ export default withLayout((props) => {
57 104
           <View className='showModel'>
58 105
             <View className='goList' onClick={goList}>{'<'}{'<'} 农机列表</View>
59 106
             <View className='title'>
60
-              <View className='name'>收割机001--S001</View>
61
-              <View className='action' onClick={goDetail}>详情 {">"}{">"}</View>
107
+              <View className='name'>{current.name}</View>
108
+              <View className='action' onClick={() => goDetail(current.machineryId)}>详情 {">"}{">"}</View>
62 109
             </View>
63 110
             <View className='position'>
64 111
               <Image src={picon} className='picon' />

+ 1
- 1
src/services/machinery.js Parādīt failu

@@ -5,7 +5,7 @@ import request from '@/utils/request'
5 5
  * @param {*} id 
6 6
  * @returns 
7 7
  */
8
- export const getMachineryDetail = (id, params) => request(`/machinery-sunmmary/${id}`, { params })
8
+ export const getMachineryDetail = (id, params) => request(`/machinery-summary/${id}`, { params })
9 9
 
10 10
 
11 11
  /**