李志伟 3 lat temu
rodzic
commit
1d20e65993

+ 2
- 9
project.private.config.json Wyświetl plik

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

BIN
src/assets/noData.png Wyświetl plik


+ 4
- 1
src/components/LoginModel/index.jsx Wyświetl plik

@@ -13,8 +13,8 @@ import unChecked from '@/assets/login/unChecked.png'
13 13
 import './style.less'
14 14
 
15 15
 export default (props) => {
16
+  const {path}=props
16 17
   const { person,setPerson } = useModel('person')
17
-
18 18
   const [agreement,setAgreement]=useState(false)
19 19
   const [phone,setPhone]=useState()
20 20
   const [qCode,setqCode]=useState()
@@ -89,6 +89,9 @@ export default (props) => {
89 89
           icon: 'none',
90 90
           duration: 1000
91 91
         })
92
+        if (path) {
93
+          Taro.reLaunch({ url: path });
94
+        }
92 95
       }).catch((e) => {
93 96
         Taro.showToast({
94 97
           title: '手机号或者验证码不正确',

+ 11
- 15
src/components/MyCard/index.jsx Wyświetl plik

@@ -6,35 +6,31 @@ import MyButton from "../MyButton"
6 6
 import './style.less'
7 7
 
8 8
 export default (props) => {
9
-  const { detail, order, job, onClick } = props
10
-  const handleDetail = () => {
11
-    Taro.navigateTo({ url: '/pages/orderDetail/index' });
12
-  }
9
+  const { detail, order, job, value, onClick,goDetail } = props
10
+  
13 11
   return (
14 12
     <View className='card'>
15 13
       <Jianbian status='1' />
16 14
       <View className='cardHead'>
17 15
         {
18
-          job && <MyCell header='需求时间' job action='详情>>' handleAction={handleDetail}>2022-06-02</MyCell>
16
+          job && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>2022-06-02</MyCell>
19 17
         }
20 18
         {
21
-          !job && <>
22
-            <MyCell header='需求时间'>2022-06-02</MyCell>
23
-            <Text className='price'><Text style={{ fontSize: '44rpx' }}>600</Text>元</Text>
24
-          </>
19
+          !job && <MyCell header='需求时间'>2022-06-02</MyCell>
25 20
         }
26 21
       </View>
27 22
       <View className='line' />
28
-      <MyCell header='农机名称'>收割机001</MyCell>
29
-      <MyCell header='下单人'>张三</MyCell>
23
+      <MyCell header='农机名称'>{value?.machineryName||'收割机001'}</MyCell>
24
+      <MyCell header='下单人'>{value?.personName}</MyCell>
30 25
       {
31
-        detail && <MyCell header='手机号'>13613949434</MyCell>
26
+        detail && <MyCell header='手机号'>{value?.phone||'13613949434'}</MyCell>
32 27
       }
33
-      <MyCell header='订单时间'>2022-03-08</MyCell>
28
+      <MyCell header='订单时间'>{value?.createDate.substr(0,10)||'2022-03-08'}</MyCell>
34 29
       {
35
-        detail && <MyCell header='服务地址'>河南省南阳市邓州市孟楼镇</MyCell>
30
+        detail && <MyCell header='服务地址'>{value?.address||'河南省南阳市邓州市孟楼镇'}</MyCell>
36 31
       }
37 32
       <MyCell header='作业时间'>上午06:00--晚上21:00</MyCell>
33
+      <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
38 34
       {
39 35
         job && <MyButton value='开始作业' onClick={onClick} />
40 36
       }
@@ -42,7 +38,7 @@ export default (props) => {
42 38
         order && <View className='line' />
43 39
       }
44 40
       {
45
-        order && <View className='footer' onClick={handleDetail}>详情{">"}{">"}</View>
41
+        order && <View className='footer' onClick={goDetail}>详情{">"}{">"}</View>
46 42
       }
47 43
     </View>
48 44
   )

+ 0
- 8
src/components/MyCard/style.less Wyświetl plik

@@ -9,14 +9,6 @@
9 9
     width: 100%;
10 10
     padding: 5px 0 0 38px;
11 11
     position: relative;
12
-    .price{
13
-      position: absolute;
14
-      right: 40px;
15
-      top: 14px;
16
-      font-size: 30px;
17
-      font-weight: bold;
18
-      color: #FF2525;
19
-    }
20 12
   }
21 13
   .line{
22 14
     width: 100%;

+ 13
- 0
src/components/NullCard/index.jsx Wyświetl plik

@@ -0,0 +1,13 @@
1
+import { View,Image } from "@tarojs/components"
2
+import NoDataImg from '@/assets/noData.png'
3
+import './style.less'
4
+
5
+export default (props)=>{
6
+  const {value}=props
7
+  return (
8
+    <View className='noDataCard'>
9
+      <Image className='NullImg' src={NoDataImg} />
10
+      <View>{value}</View>
11
+    </View>
12
+  )
13
+}

+ 17
- 0
src/components/NullCard/style.less Wyświetl plik

@@ -0,0 +1,17 @@
1
+.noDataCard{
2
+  margin: 30px;
3
+  box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
4
+  border-radius: 40px;
5
+  position: relative;
6
+  overflow: hidden;
7
+  padding: 78px;
8
+  font-size: 34px;
9
+  font-weight: bold;
10
+  color: #B4B4B4;
11
+  text-align: center;
12
+  .NullImg{
13
+    width: 220px;
14
+    height: 264px;
15
+    margin-bottom: 44px;
16
+  }
17
+}

+ 17
- 15
src/pages/index/components/order/index.jsx Wyświetl plik

@@ -4,21 +4,17 @@ import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView } from "@taroj
4 4
 import positionImg from '@/assets/comm/position.png'
5 5
 import searchImg from '@/assets/comm/search.png'
6 6
 import orderImg from '@/assets/comm/orderList.png'
7
-import LoginModel from "@/components/LoginModel";
8 7
 import Footer from "@/components/Footer";
9 8
 import MyCard from "@/components/MyCard";
10
-import { useModel } from "@/store";
11
-
12
-
9
+import NullCard from "@/components/NullCard";
13 10
 import { getBannerList } from "@/services/banner";
11
+import { getOrderList } from "@/services/order";
14 12
 import './style.less'
15 13
 
16 14
 
17 15
 export default (props) => {
18
-  const [imgList, setImgList] = useState([])  
19
-  const [show, setShow] = useState(false)
20
-  const [path, setPath] = useState()
21
-  const { person } = useModel('person')
16
+  const [imgList, setImgList] = useState([])
17
+  const [orderList, setOrderList] = useState([])
22 18
 
23 19
   const handleSearch = (e) => {
24 20
     console.log(e.detail.value)
@@ -26,6 +22,9 @@ export default (props) => {
26 22
   const handleMore = () => {
27 23
     Taro.navigateTo({ url: '/pages/moreOrder/index' });
28 24
   }
25
+  const handleDetail = (val) => {
26
+    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}` });
27
+  }
29 28
   useEffect(() => {
30 29
     getBannerList({ position: 'bannerWorker' })
31 30
       .then(res => {
@@ -36,12 +35,12 @@ export default (props) => {
36 35
           icon: 'none',
37 36
         })
38 37
       })
38
+    getOrderList().then((res) => {
39
+      setOrderList(res.records)
40
+    })
39 41
   }, [])
40 42
   return (
41 43
     <View className='orderIndex'>
42
-      {
43
-        show && <LoginModel path={path} close={() => setShow(false)} />
44
-      }
45 44
       <View className='top'>
46 45
         <View className='left'>
47 46
           <Image src={positionImg} className='pImg' />
@@ -73,10 +72,13 @@ export default (props) => {
73 72
             <Text className='title'>订单列表</Text>
74 73
             <Text className='more' onClick={handleMore}>更多{">"}{">"}</Text>
75 74
           </View>
76
-
77
-          <MyCard order />
78
-          <MyCard order />
79
-          <Footer />
75
+          {
76
+            orderList.length===0?<NullCard value='您还没有新的订单!' />:
77
+            orderList.map((item)=>{
78
+              return <MyCard order value={item} key={item.orderId} goDetail={()=>handleDetail(item.orderId)} />
79
+            })
80
+          }
81
+          {/* <Footer /> */}
80 82
         </View>
81 83
       </ScrollView>
82 84
     </View>

+ 36
- 17
src/pages/index/index.jsx Wyświetl plik

@@ -1,28 +1,39 @@
1
-import Taro, { useDidShow } from "@tarojs/taro";
2
-import { useState, useEffect } from "react";
1
+import Taro from "@tarojs/taro";
2
+import { useEffect, useState } from "react";
3 3
 import { View, Image } from "@tarojs/components"
4
+import { useModel } from "@/store";
5
+import withLayout from '@/layouts'
6
+import CustomNav from "@/components/CustomNav";
7
+import LoginModel from "@/components/LoginModel";
8
+import { setAmap } from '@/services/amap'
4 9
 import indexImg from "@/assets/comm/index.png";
5 10
 import indexActive from "@/assets/comm/indexActive.png";
6 11
 import job from "@/assets/comm/job.png";
7 12
 import jobActive from "@/assets/comm/jobActive.png";
8 13
 import user from "@/assets/comm/user.png";
9 14
 import userActive from "@/assets/comm/userActive.png";
10
-import CustomNav from "@/components/CustomNav";
11
-import { setAmap } from '@/services/amap'
12
-import withLayout from '@/layouts'
13
-import { useModel } from "@/store";
14 15
 import Order from './components/Order'
15 16
 import Job from './components/Job'
16 17
 import User from "./components/User";
17 18
 import "./index.less";
18 19
 
19 20
 
21
+
20 22
 export default withLayout((props) => {
21 23
   const { router } = props
22 24
   let { tab } = router.params
23 25
   const { location, setLocation } = useModel('location')
26
+  const { person } = useModel('person')
27
+  const [currentTab, setCurrentTab] = useState(0)
28
+  const [show, setShow] = useState(false)
29
+  const [path, setPath] = useState()
24 30
   const handleClick = (val) => {
25
-    Taro.reLaunch({ url: `/pages/index/index?tab=${val}` });
31
+    if (!person.phone && val != 0) {
32
+      setShow(true)
33
+      setPath(`/pages/index/index?tab=${val}`)
34
+    } else {
35
+      setCurrentTab(val)
36
+    }
26 37
   };
27 38
   useEffect(() => {
28 39
     if (!location) {
@@ -37,36 +48,44 @@ export default withLayout((props) => {
37 48
       setAmap({ params: 'location=' + location, path: '/v3/geocode/regeo' })
38 49
     }
39 50
   }, [])
51
+  useEffect(() => {
52
+    if (tab) {
53
+      setCurrentTab(tab - 0)
54
+    }
55
+  }, [tab])
40 56
   return (
41 57
     <View className='page-index'>
58
+      {
59
+        show && <LoginModel path={path} />
60
+      }
42 61
       <View className='index-navbar'>
43
-        <CustomNav home title={(!tab || tab == 0) ? '首页' : tab == 1 ? '作业管理' : '我的'} />
62
+        <CustomNav home title={currentTab == 0 ? '首页' : currentTab == 1 ? '作业管理' : '我的'} />
44 63
       </View>
45 64
       <View className='index-container'>
46
-        {(!tab || tab == 0) && <Order />}
47
-        {tab == 1 && <Job />}
48
-        {tab == 2 && <User />}
65
+        {currentTab == 0 && <Order />}
66
+        {currentTab == 1 && <Job />}
67
+        {currentTab == 2 && <User />}
49 68
       </View>
50 69
       <View className='index-tabbar'>
51 70
         <View
52
-          className={['tabberItem', (!tab || tab == 0) ? "activeTabber" : '']}
71
+          className={['tabberItem', currentTab == 0 ? "activeTabber" : '']}
53 72
           onClick={() => handleClick(0)}
54 73
         >
55
-          <Image className='tabberImg' src={(!tab || tab == 0) ? indexActive : indexImg}></Image>
74
+          <Image className='tabberImg' src={currentTab == 0 ? indexActive : indexImg}></Image>
56 75
           <View className='text'>首页</View>
57 76
         </View>
58 77
         <View
59
-          className={['tabberItem', tab === 1 ? "activeTabber" : '']}
78
+          className={['tabberItem', currentTab === 1 ? "activeTabber" : '']}
60 79
           onClick={() => handleClick(1)}
61 80
         >
62
-          <Image className='tabberImg' src={tab == 1 ? jobActive : job}></Image>
81
+          <Image className='tabberImg' src={currentTab == 1 ? jobActive : job}></Image>
63 82
           <View className='text'>作业管理</View>
64 83
         </View>
65 84
         <View
66
-          className={['tabberItem', tab === 2 ? "activeTabber" : '']}
85
+          className={['tabberItem', currentTab === 2 ? "activeTabber" : '']}
67 86
           onClick={() => handleClick(2)}
68 87
         >
69
-          <Image className='tabberImg' src={tab == 2 ? userActive : user}></Image>
88
+          <Image className='tabberImg' src={currentTab == 2 ? userActive : user}></Image>
70 89
           <View className='text'>个人中心</View>
71 90
         </View>
72 91
       </View>

+ 21
- 5
src/pages/moreOrder/index.jsx Wyświetl plik

@@ -1,15 +1,19 @@
1
-import { useState } from "react";
1
+import Taro from "@tarojs/taro";
2
+import { useState, useEffect } from "react";
2 3
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
3 4
 import CustomNav from "@/components/CustomNav";
4 5
 import searchImg from '@/assets/comm/search.png'
5 6
 import withLayout from '@/layouts'
7
+import NullCard from "@/components/NullCard";
6 8
 import MyCard from "@/components/MyCard";
7 9
 import Footer from "@/components/Footer";
10
+import { getOrderList } from "@/services/order";
8 11
 import './style.less'
9 12
 
10 13
 export default withLayout(() => {
11 14
   const [imageShow, setImageShow] = useState(true)
12 15
   const [currentTab, setCurrentTab] = useState(0);
16
+  const [orderList, setOrderList] = useState([])
13 17
   const handleSearch = (e) => {
14 18
     if (e.detail.value) {
15 19
       console.log(e.detail.value)
@@ -24,6 +28,15 @@ export default withLayout(() => {
24 28
   const handleChange = (val) => {
25 29
     setCurrentTab(val)
26 30
   }
31
+  const handleDetail = (val) => {
32
+    Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}` });
33
+  }
34
+  useEffect(() => {
35
+    getOrderList().then((res) => {
36
+      console.log(res.records)
37
+      setOrderList(res.records)
38
+    })
39
+  }, [])
27 40
   return (
28 41
     <View className='page-index'>
29 42
       <View className='index-navbar'>
@@ -75,10 +88,13 @@ export default withLayout(() => {
75 88
       <View className='index-container'>
76 89
         <ScrollView scrollY style={{ height: '100%' }}>
77 90
           {/* {currentTab} */}
78
-          <MyCard />
79
-          <MyCard />
80
-          <MyCard />
81
-          <Footer />
91
+          {
92
+            orderList.length===0?<NullCard value='您还没有新的订单!' />:
93
+            orderList.map((item)=>{
94
+              return <MyCard order value={item} key={item.orderId} goDetail={()=>handleDetail(item.orderId)} />
95
+            })
96
+          }
97
+          {/* <Footer /> */}
82 98
         </ScrollView>
83 99
         {/* {currentTab === 0 && <View>777</View>}
84 100
         {currentTab === 1 && <View>888</View>}

+ 13
- 2
src/pages/orderDetail/index.jsx Wyświetl plik

@@ -2,15 +2,26 @@ import { View } from "@tarojs/components"
2 2
 import CustomNav from "@/components/CustomNav"
3 3
 import MyCard from "@/components/MyCard"
4 4
 import withLayout from '@/layouts'
5
+import { useEffect , useState } from "react"
6
+import { getOrderDetail } from "@/services/order"
5 7
 
6
-export default withLayout(() => {
8
+
9
+export default withLayout((props) => {
10
+  const { router } = props
11
+  let { id } = router.params
12
+  const [value,setValue]=useState()
13
+  useEffect(()=>{
14
+    getOrderDetail(id).then((res)=>{
15
+      setValue(res)
16
+    })
17
+  },[id])
7 18
   return (
8 19
     <View className='page-index'>
9 20
       <View className='index-navbar'>
10 21
         <CustomNav title='更多' />
11 22
       </View>
12 23
       <View className='index-container'>
13
-        <MyCard detail />
24
+        <MyCard detail value={value} />
14 25
       </View>
15 26
     </View>
16 27
   )

+ 15
- 0
src/services/order.js Wyświetl plik

@@ -0,0 +1,15 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+  * 订单列表
5
+  * @returns 
6
+  * params 搜索条件放这里
7
+  */
8
+ export const getOrderList = (params) => request('/order', { params })
9
+
10
+/**
11
+  * 订单详情
12
+  * @returns 
13
+  * params 搜索条件放这里
14
+  */
15
+ export const getOrderDetail = (id,params) => request(`/order/${id}`, { params })

+ 1
- 1
src/store/models/person.js Wyświetl plik

@@ -8,7 +8,7 @@ export default () => {
8 8
   const login = (params) => {
9 9
     signIn(params).then((res) => {
10 10
       const { person: taPerson,  sessionKey: skey } = res;
11
-      taPerson.phone=null
11
+      // taPerson.phone=null
12 12
       setPerson(taPerson);
13 13
       setSessionKey(skey);
14 14
     })

+ 1
- 2
src/utils/hooks/useLogin.js Wyświetl plik

@@ -10,9 +10,8 @@ export default () => {
10 10
   const router = useRouter()
11 11
   const { person } = useModel('person')
12 12
   const [loginVisible, setLoginVisible] = useState(false)
13
-  let { tab } = router.params
14 13
 
15
-  const isInWhiteList = useMemo(() => whiteList.includes(router.path)&&(!tab||tab==0), [router.path, tab])
14
+  const isInWhiteList = useMemo(() => whiteList.includes(router.path), [router.path])
16 15
   const hasPhone = useMemo(() => !!person?.phone, [person?.phone])
17 16
   
18 17
   useEffect(() => {