ShareRoom.jsx 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React from 'react'
  2. import Popup from '@/components/Popup'
  3. import Taro from '@tarojs/taro'
  4. import { Input, Button, View, Picker, Label } from '@tarojs/components'
  5. import { shareRoom } from '@/services/landlord'
  6. import './ShareRoom.less'
  7. import { useState } from 'react'
  8. export default (props) => {
  9. const { showCutover, onClose, room, onFinish } = props
  10. const [startDate, setStartDate] = useState('')
  11. const [endDate, setEndDate] = useState('')
  12. const [roomNum, setRoomNum] = useState('')
  13. const handelStartDate = (e) => {
  14. setStartDate(e.detail.value)
  15. }
  16. const handelEndDate = (e) => {
  17. setEndDate(e.detail.value)
  18. }
  19. const handelShare = () => {
  20. var myDate = new Date();
  21. shareRoom({
  22. hotelId: room.hotelId,
  23. personNum: roomNum == '' ? 0 : roomNum, roomId: room.roomId,
  24. startDate: startDate == '' ? myDate.toLocaleDateString() : startDate,
  25. endDate: endDate == '' ? myDate.toLocaleDateString() : endDate
  26. }).then((res) => {
  27. onFinish(res)
  28. setStartDate('')
  29. setEndDate('')
  30. setRoomNum()
  31. })
  32. }
  33. return (
  34. <Popup show={showCutover} onClose={onClose}>
  35. <View className='from-room srl'>
  36. <View style={{ marginBottom: '25px' }}>
  37. <View className='rzline' /><Label className='srl mg'>请输入入住人信息</Label><View className='rzline' />
  38. </View>
  39. <View className='srleft'>
  40. <Label>入住人数:</Label>
  41. <Input onInput={(e) => setRoomNum(e.detail.value)} value={roomNum} type='number' placeholder='请输入入住人数' />
  42. </View>
  43. <View className='srleft'>
  44. <Label >入住开始时间:</Label>
  45. <Picker className='picker' mode='date' onChange={handelStartDate}>
  46. {startDate == '' ? '请选择入住开始时间' : startDate}
  47. </Picker>
  48. </View>
  49. <View className='srleft'>
  50. <Label>入住结束时间:</Label>
  51. <Picker className='picker' mode='date' onChange={handelEndDate}>
  52. {endDate == '' ? '请选择入住结束时间' : endDate}
  53. </Picker>
  54. </View>
  55. <View>
  56. <Button className='cancel' onClick={onClose}>取消</Button>
  57. <Button className='btn' onClick={handelShare}>分享</Button>
  58. </View>
  59. {/* <mp-form >
  60. <Label style={{color:'black'}}>请输入入住人信息</Label>
  61. <mp-cells footer=' ' >
  62. <mp-cell title='入住人数:' extClass='font'>
  63. <Input focus dataField='nm' onInput={(e) => setRoomNum(e.detail.value)} value={roomNum} type='number' placeholder='请输入入住人数' />
  64. </mp-cell>
  65. <mp-cell title='入住开始时间:' extClass='font'>
  66. <Picker mode='date' onChange={handelStartDate}>
  67. {startDate == '' ? '请选择入住开始时间' : startDate}
  68. </Picker>
  69. </mp-cell>
  70. <mp-cell title='入住结束时间:' extClass='font'>
  71. <Picker mode='date' onChange={handelEndDate}>
  72. {endDate == '' ? '请选择入住结束时间' : endDate}
  73. </Picker>
  74. </mp-cell>
  75. <mp-cell>
  76. <Button className='cancel' onClick={onClose}>取消</Button><Button className='btn' onClick={handelShare}>分享</Button>
  77. </mp-cell>
  78. </mp-cells>
  79. </mp-form> */}
  80. </View>
  81. {/* <View className='from-room'>
  82. <Label style={{ color: 'black' }}>请输入入住人信息</Label>
  83. <View className='flex'>
  84. <Label>入住人数:</Label><Input focus dataField='nm' onInput={(e) => setRoomNum(e.detail.value)} value={roomNum} type='number' placeholder='请输入入住人数' /></View>
  85. <View className='flex'>
  86. <Label>入住开始时间:</Label>
  87. <Picker mode='date' className='picker' onChange={handelStartDate}>
  88. {startDate == '' ? '请选择入住开始时间' : startDate}
  89. </Picker>
  90. </View>
  91. <View className='flex'>
  92. <Label>入住结束时间:</Label>
  93. <Picker className='picker' mode='date' onChange={handelEndDate}>
  94. {endDate == '' ? '请选择入住结束时间' : endDate}
  95. </Picker>
  96. </View>
  97. <View><Button className='cancel' onClick={onClose}>取消</Button><Button className='btn' onClick={handelShare}>分享</Button></View>
  98. </View> */}
  99. </Popup>
  100. )
  101. }