|
@@ -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
|
})
|