李志伟 преди 3 години
родител
ревизия
5e7a167e40
променени са 4 файла, в които са добавени 146 реда и са изтрити 16 реда
  1. 11
    11
      src/components/MyCard/index.jsx
  2. 13
    1
      src/pages/index/components/order/index.jsx
  3. 71
    4
      src/pages/orderDetail/index.jsx
  4. 51
    0
      src/pages/orderDetail/style.less

+ 11
- 11
src/components/MyCard/index.jsx Целия файл

@@ -5,38 +5,38 @@ import MyButton from "../MyButton"
5 5
 import './style.less'
6 6
 
7 7
 export default (props) => {
8
-  const { detail, order, job, value, onClick,goDetail } = props
8
+  const { detail, order, job, value, onClick, goDetail } = props
9 9
   return (
10 10
     <View className='card'>
11
-      <Jianbian status={job?value?.status:value?.workStatus} />
11
+      <Jianbian status={job ? value?.status : value?.workStatus} />
12 12
       <View className='cardHead'>
13 13
         {
14 14
           //首页作业列表卡片
15
-          job &&!detail&& <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>{value?.appointmentDate?.substr(0,10)}</MyCell>
15
+          job && !detail && <MyCell header='需求时间' job action='详情>>' handleAction={goDetail}>{value?.appointmentDate?.substr(0, 10)}</MyCell>
16 16
         }
17 17
         {
18
-          (!job||job&&detail) && <MyCell header='需求时间'>{value?.appointmentDate?.substr(0,10)}</MyCell>
18
+          (!job || job && detail) && <MyCell header='需求时间'>{value?.appointmentDate?.substr(0, 10)}</MyCell>
19 19
         }
20 20
       </View>
21 21
       <View className='line' />
22 22
       <MyCell header='订单号'>{value?.orderNo}</MyCell>
23 23
       {
24
-        job?
25
-        <MyCell header='农机名称'>{value?.machineryName}</MyCell>:
26
-        <MyCell header='农机类型'>{value?.typeName}</MyCell>
24
+        job ?
25
+          <MyCell header='农机名称'>{value?.machineryName}</MyCell> :
26
+          <MyCell header='农机类型'>{value?.typeName}</MyCell>
27 27
       }
28 28
       <MyCell header='下单人'>{value?.personName}</MyCell>
29 29
       <MyCell header='手机号'>{value?.phone}</MyCell>
30
-      <MyCell header='订单时间'>{value?.createDate.substr(0,10)}</MyCell>
30
+      <MyCell header='订单时间'>{value?.createDate.substr(0, 10)}</MyCell>
31 31
       {
32 32
         detail && <MyCell header='服务地址'>{value?.address}</MyCell>
33 33
       }
34 34
       {
35
-        job&&<MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
35
+        job && <MyCell header='作业时间'><View>{value?.startDate}</View><View>{value?.endDate}</View></MyCell>
36 36
       }
37
-      <MyCell header='订单费用'>{(value?.charges&&value.charges/100)||600}元</MyCell>
37
+      <MyCell header='订单费用'>{(value?.charges && value.charges / 100) || 600}元</MyCell>
38 38
       {
39
-        job &&value?.status!=3&&!detail&& <MyButton value={value?.status==0?'开始作业':'完成作业'} onClick={onClick} />
39
+        job && value?.status != 3 && <MyButton value={value?.status == 0 ? '开始作业' : '完成作业'} onClick={onClick} />
40 40
       }
41 41
       {
42 42
         order && <View className='line' />

+ 13
- 1
src/pages/index/components/order/index.jsx Целия файл

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from "react"
2
-import Taro from "@tarojs/taro";
2
+import Taro, { useDidShow } from "@tarojs/taro";
3 3
 import { View, Input, Swiper, Image, SwiperItem, Text, ScrollView, Button } from "@tarojs/components"
4 4
 import { Popup } from "@antmjs/vantui";
5 5
 import Footer from "@/components/Footer";
@@ -16,6 +16,7 @@ import OverPop from '../OverPop'
16 16
 import './style.less'
17 17
 
18 18
 
19
+
19 20
 export default (props) => {
20 21
   const [imgList, setImgList] = useState([])
21 22
   const [jobList, setJobList] = useState([])
@@ -95,6 +96,17 @@ export default (props) => {
95 96
       })
96 97
     }
97 98
   }
99
+  useDidShow(()=>{
100
+    getJobList({ pageNum: currentPage }).then(res => {
101
+      const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])
102
+      //长列表加载当下一页没有数据时
103
+      if (res.records.length == 0 && currentPage != 1) {
104
+        setIsMore(true)
105
+        return
106
+      }
107
+      setJobList(lst)
108
+    })
109
+  })
98 110
   useEffect(() => {
99 111
     getJobList({ pageNum: currentPage }).then(res => {
100 112
       const lst = currentPage === 1 ? res.records || [] : jobList.concat(res.records || [])

+ 71
- 4
src/pages/orderDetail/index.jsx Целия файл

@@ -1,16 +1,70 @@
1
-import { View } from "@tarojs/components"
1
+import Taro from "@tarojs/taro";
2
+import { Popup } from "@antmjs/vantui";
3
+import { View, Image, Button } from "@tarojs/components"
2 4
 import CustomNav from "@/components/CustomNav"
3 5
 import MyCard from "@/components/MyCard"
4 6
 import withLayout from '@/layouts'
7
+import { useModel } from "@/store";
5 8
 import { useEffect, useState } from "react"
6 9
 import { getOrderDetail } from "@/services/order"
7
-import { getJobDetail } from '@/services/job'
10
+import { getJobDetail, toggleJob, overJob } from '@/services/job'
11
+import PositionImg from '@/assets/job/positionImg.png'
12
+import OverPop from '../index/components/OverPop'
13
+import './style.less'
8 14
 
9 15
 
10 16
 export default withLayout((props) => {
11 17
   const { router } = props
12 18
   let { id, job } = router.params
13 19
   const [value, setValue] = useState()
20
+
21
+  const { address } = useModel('location')
22
+  const [show, setShow] = useState(false)
23
+  const [area, setArea] = useState()
24
+  const [showOver, setShowOver] = useState(false)
25
+
26
+  const handleWork = () => {
27
+    if (value.status == 0) {
28
+      setShow(true)
29
+    } else {
30
+      setShowOver(true)
31
+    }
32
+  }
33
+  const onClose = () => {
34
+    getJobDetail(id).then(res => {
35
+      setValue(res)
36
+    })
37
+    setShow(false)
38
+  }
39
+  const handleOk = () => {
40
+    toggleJob(value.jobId, { mode: true }).then(() => {
41
+      onClose()
42
+    })
43
+  }
44
+  const onOverClose = () => {
45
+    getJobDetail(id).then(res => {
46
+      setValue(res)
47
+    })
48
+    setShowOver(false)
49
+  }
50
+  const handleOverOk = () => {
51
+    //正整数或两位小数
52
+    if (!isNaN(area)) {
53
+      overJob(value.jobId, { ...value, area: area }).then(res => {
54
+        Taro.showToast({
55
+          title: '恭喜完成作业',
56
+          icon: 'none',
57
+        })
58
+        onOverClose()
59
+      })
60
+    }
61
+    else {
62
+      Taro.showToast({
63
+        title: '请输入正确的面积整数或最多两位小数',
64
+        icon: 'none',
65
+      })
66
+    }
67
+  }
14 68
   useEffect(() => {
15 69
     if (job) {
16 70
       getJobDetail(id).then(res => {
@@ -25,13 +79,26 @@ export default withLayout((props) => {
25 79
   return (
26 80
     <View className='page-index'>
27 81
       <View className='index-navbar'>
28
-        <CustomNav title='更多' />
82
+        <CustomNav title='详情' />
29 83
       </View>
30 84
       <View className='index-container'>
31 85
         {
32
-          job?<MyCard detail job value={value} />:<MyCard detail value={value} />
86
+          job ? <MyCard detail job value={value} onClick={handleWork} /> : <MyCard detail value={value} />
33 87
         }
34 88
       </View>
89
+      <Popup
90
+        show={show}
91
+        onClose={onClose}
92
+        className='tanchuang'
93
+      >
94
+        <Image src={PositionImg} className='pImg' />
95
+        <View>当前位置在</View>
96
+        <View>{address}</View>
97
+        <Button className='btn' onClick={handleOk}>确认</Button>
98
+      </Popup>
99
+
100
+      <OverPop showOver={showOver} onOverClose={onOverClose} area={area} setArea={setArea} handleOverOk={handleOverOk} />
101
+
35 102
     </View>
36 103
   )
37 104
 })

+ 51
- 0
src/pages/orderDetail/style.less Целия файл

@@ -0,0 +1,51 @@
1
+.tanchuang{
2
+  text-align: center;
3
+  font-size: 34px;
4
+  font-weight: 800;
5
+  color: #323232;
6
+  width: calc(100vw - 60px);
7
+  padding: 142px 130px;
8
+  box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
9
+  border-radius: 40px;
10
+  .bankInput{
11
+    background: #FFF;
12
+    border: 2px solid #F2F2F2;
13
+    border-radius: 40px;
14
+    display: flex;
15
+    align-items: center;
16
+    padding: 36px 30px;
17
+    margin-top: 30px;
18
+    height: 108px;
19
+    box-sizing: border-box;
20
+    .header{
21
+      font-size: 48px;
22
+      font-weight: 500;
23
+      color: #333;
24
+      flex: none;
25
+      margin-right: 20px;
26
+    }
27
+    .body{
28
+      flex: 1;
29
+      font-size: 32px;
30
+      font-weight: 400;
31
+    }
32
+  }
33
+  .pImg{
34
+    width: 80px;
35
+    height: 77px;
36
+    margin-bottom: 52px;
37
+  }
38
+  view{
39
+    text-align: left;
40
+    line-height: 46px;
41
+  }
42
+  .btn{
43
+    width: 200px;
44
+    height: 88px;
45
+    background: linear-gradient(0deg, #00AE39, #A0E067);
46
+    border-radius: 34px;
47
+    font-size: 32px;
48
+    color: #FFFFFF;  
49
+    margin-top: 100px;  
50
+  }
51
+}