reservation.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="reservation-index form-box">
  3. <uni-forms label-position="top" :modelValue="formData">
  4. <uni-forms-item label="姓名" name="name">
  5. <uni-easyinput type="text" v-model="formData.name" placeholder="请输入姓名" disabled />
  6. </uni-forms-item>
  7. <uni-forms-item label="联系方式" name="phone">
  8. <uni-easyinput type="tel" v-model="formData.phone" placeholder="请输入姓名" disabled />
  9. </uni-forms-item>
  10. <uni-forms-item label="预约时间" name="date">
  11. <view class="select-box" @click="open">
  12. <text class="select-text" v-if="formData.date">{{formData.date}}</text>
  13. <text class="select-label" v-else>请选择日期</text>
  14. <uni-icons class="form-icon" type="down" size="12" color="#8c8c8c"></uni-icons>
  15. </view>
  16. </uni-forms-item>
  17. </uni-forms>
  18. <uv-datetime-picker ref="dateTimePicker" v-model="nowTime" mode="datetime" @confirm="confirm"
  19. :minDate="nowTime">
  20. </uv-datetime-picker>
  21. <view class="hui-button-box">
  22. <view class="hui-button-view">
  23. <view class="hui-button" @click="submit">提交预约</view>
  24. </view>
  25. <uv-safe-bottom></uv-safe-bottom>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import lotusCalendar from "@/components/Winglau14-lotusCalendar/Winglau14-lotusCalendar.vue";
  31. import {
  32. insertReservation
  33. } from '@/request/api/house.js'
  34. export default {
  35. data() {
  36. return {
  37. formData: {
  38. name: '',
  39. phone: '',
  40. date: ''
  41. },
  42. houseId: '',
  43. projectId: '',
  44. chargePersonId: '',
  45. nowTime: Number(new Date())
  46. }
  47. },
  48. onLoad(body) {
  49. if (body.houseId) this.houseId = body.houseId;
  50. if (body.projectId) this.projectId = body.projectId;
  51. if (body.chargePersonId) this.chargePersonId = body.chargePersonId;
  52. },
  53. onShow() {
  54. this.formData.date = this.$dayjs().format('YYYY-MM-DD HH:mm');
  55. this.formData['name'] = this.$store.getters.user.userName;
  56. this.formData['phone'] = this.$store.getters.user.phone;
  57. },
  58. methods: {
  59. open() {
  60. this.$refs.dateTimePicker.open();
  61. },
  62. confirm(e) {
  63. let date = this.$dayjs(e.value).format('YYYY-MM-DD HH:mm');
  64. this.formData.date = date;
  65. },
  66. submit() {
  67. insertReservation({
  68. userId: this.$store.getters.user.userId,
  69. projectItemTargetRoomId: this.houseId,
  70. date: this.formData.date,
  71. projectId: this.projectId,
  72. chargePersonId: this.chargePersonId
  73. }).then(res => {
  74. if (res.code == 200) {
  75. this.$toast('预约成功');
  76. setTimeout(() => {
  77. this.$navigateBack();
  78. }, 1000);
  79. }
  80. })
  81. }
  82. },
  83. components: {
  84. lotusCalendar
  85. },
  86. }
  87. </script>
  88. <style lang="scss">
  89. .reservation-index {
  90. padding: 30rpx;
  91. }
  92. </style>