reservation.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-calendar ref="calendar" @confirm="confirm"></uv-calendar>
  19. <view class="hui-button-box">
  20. <view class="hui-button" @click="submit">提交预约</view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import lotusCalendar from "@/components/Winglau14-lotusCalendar/Winglau14-lotusCalendar.vue";
  26. import {
  27. insertReservation
  28. } from '@/request/api/house.js'
  29. export default {
  30. data() {
  31. return {
  32. formData: {
  33. name: '',
  34. phone: '',
  35. date: ''
  36. },
  37. houseId: 15
  38. }
  39. },
  40. onLoad(body) {
  41. console.log(body);
  42. if (body.houseId) this.houseId = body.houseId;
  43. },
  44. onShow() {
  45. this.formData.date = this.$dayjs().format('YYYY-MM-DD');
  46. this.formData['name'] = this.$store.getters.user.userName;
  47. this.formData['phone'] = this.$store.getters.user.phone;
  48. },
  49. methods: {
  50. open() {
  51. this.$refs.calendar.open();
  52. },
  53. confirm(e) {
  54. this.formData.date = e[0];
  55. },
  56. submit() {
  57. insertReservation({
  58. userId: this.$store.getters.user.userId,
  59. projectItemTargetRoomId: this.houseId,
  60. date: this.formData.date
  61. }).then(res => {
  62. if (res.code == 200) {
  63. this.$toast('预约成功');
  64. setTimeout(() => {
  65. this.$navigateBack();
  66. }, 1000);
  67. }
  68. })
  69. }
  70. },
  71. components: {
  72. lotusCalendar
  73. },
  74. }
  75. </script>
  76. <style lang="scss">
  77. .reservation-index {
  78. padding: 30rpx;
  79. }
  80. </style>