123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { View, Image, Form, Input, Picker } from "@tarojs/components"
  2. import Taro from "@tarojs/taro"
  3. import { useEffect, useState } from "react"
  4. import withLayout from '@/layouts'
  5. import { useModel } from "@/store"
  6. import addresss from '@/assets/mineImgaes/addresss.png'//地址
  7. import timeImage from '@/assets/icons/comm/timeImage.png'//日期图片
  8. import CustomNav from '@/components/CustomNav'
  9. import ButtontWX from '@/components/ButtontWX'
  10. import { generateOrder } from "@/services/order"
  11. // import BottomMoadl from '@/components/BottomMoadl/index'
  12. import { getMachineryInfo } from "@/services/homes"
  13. import './style.less'
  14. //为了调试,删除了withLayout 记得加上 如果我忘记的话
  15. export default withLayout((props) => {
  16. //底部弹窗
  17. // const [showFrame, setShowFrame] = useState(false)
  18. // const setRecommend = () => {
  19. // setShowFrame(!showFrame)
  20. // }
  21. const $instance = Taro.getCurrentInstance()
  22. const { id } = $instance.router.params
  23. const { sserLocation, setUserLocation } = useModel('userData')
  24. const [timeSel, setTimeSel] = useState('')
  25. const [carsInfo, setCarsInfo] = useState({})
  26. const formSubmit = (e) => {
  27. console.log('表单输入', e?.detail?.value);
  28. const { amount, appontmentDate, address } = e?.detail?.value
  29. // Taro.navigateTo({ url: `/pages/OrderInfo/index?goOrder=${id}` })
  30. generateOrder({
  31. charges: carsInfo?.price * amount,
  32. price: carsInfo?.price,
  33. amount: amount || '',
  34. machineryId: carsInfo?.machineryId,
  35. machineryName: carsInfo?.name,
  36. machineryType: carsInfo?.typeId,
  37. typeName: carsInfo?.typeName,
  38. address: address || '',
  39. orgId: carsInfo?.orgId,
  40. // appontmentDate: appontmentDate || '',
  41. appontmentDate: '2022-03-25 08:00:00',
  42. }).then((es) => {
  43. Taro.redirectTo({ url: `/pages/OrderInfo/index?orderId=${es.orderId}` })
  44. })
  45. }
  46. useEffect(() => {
  47. if (id) {
  48. getMachineryInfo(id, { location: sserLocation, attached: true }).then((e) => {
  49. setCarsInfo(e)
  50. console.log('e', e);
  51. })
  52. }
  53. }, [id, sserLocation])
  54. const onTimeChange = (e) => {
  55. console.log('时间选择器', e);
  56. setTimeSel(e?.detail?.value)
  57. }
  58. const cancelPay = () => {
  59. Taro.navigateBack({
  60. delta: 1
  61. })
  62. }
  63. return (
  64. <View className='page-index'>
  65. <View className='index-navbar'>
  66. <CustomNav title='订单确认' />
  67. </View>
  68. {/* <BottomMoadl frameTitle='支付方式' flag={showFrame} onRecommend={setRecommend} /> */}
  69. <View className='pagesBox'>
  70. <Form onSubmit={formSubmit} >
  71. <View className='example-body-WorkingArea'>
  72. <View>作业面积/公顷</View>
  73. <Input name='amount' type='number' className='aTextareaCentent' placeholder='请输入地址信息' />
  74. </View>
  75. <View className='example-body-WorkingTime'>
  76. <View>作业时间:</View>
  77. <View className='example-body-WorkingTime-TimePicker'>
  78. <Image src={timeImage} />
  79. {/* <mp-pickerTime tips='请选择时间' isChinese={1} onChange={myevent} /> */}
  80. <Picker mode='date' name='appontmentDate' onChange={onTimeChange}>
  81. <View className='picker' >
  82. {timeSel || '请选择日期'}
  83. </View>
  84. </Picker>
  85. </View>
  86. </View>
  87. <View className='example-body-WorkingLocation'>
  88. <View>作业位置:</View>
  89. <View className='example-body-WorkingLocation-info' onClick={() => { console.log('111111',); }}>
  90. <Image src={addresss} />
  91. <Input name='address' disabled className='aTextareaCentent' value='1111111' placeholder='请输入地址信息' />
  92. </View>
  93. </View>
  94. <View className='BottomtBut-box'>
  95. <ButtontWX onClick={formSubmit} formType='submit' butText='确定' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
  96. <ButtontWX onClick={cancelPay} formType='submit' styleType butText='取消' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
  97. </View>
  98. </Form>
  99. </View>
  100. </View>
  101. )
  102. })