selectRoom.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="container">
  3. <view class="room" v-for="item in roomList" :key="item.room" @click="confirmSelect(item)">
  4. <text v-text="item.room"></text>
  5. </view>
  6. </view>
  7. </template>
  8. <script setup>
  9. import {
  10. onLoad
  11. } from '@dcloudio/uni-app'
  12. import {
  13. onMounted,
  14. reactive
  15. } from 'vue'
  16. import {
  17. useHotelStore
  18. } from '../../store/hotelStore'
  19. import {
  20. useOrderStore
  21. } from '../../store/orderStore'
  22. let roomType
  23. let hotel = useHotelStore().hotel
  24. let order = useOrderStore()
  25. let roomList = reactive([])
  26. async function getRoom() {
  27. let res = await uni.request({
  28. url: '/hotel/room',
  29. method: 'POST',
  30. data: {
  31. hotelId: hotel.hotelId,
  32. roomType: roomType,
  33. startTime: order.orderInfo.startTime,
  34. endTime: order.orderInfo.endTime,
  35. pageNo: 1,
  36. pageSize: 999
  37. }
  38. })
  39. roomList.push(...res.data.data.records)
  40. }
  41. function confirmSelect(item) {
  42. uni.showModal({
  43. title: '确认选择' + item.room + '房间?',
  44. success: (res) => {
  45. if (res.confirm) {
  46. order.updateOrderInfo({
  47. ...order.orderInfo,
  48. building: item.building,
  49. floor: item.floor,
  50. room: item.room,
  51. status: 'ROOM_SELECTED'
  52. })
  53. uni.navigateTo({
  54. url: '/subpkg_checkin/addGuest/addGuest'
  55. })
  56. }
  57. }
  58. })
  59. }
  60. onLoad(async (options) => {
  61. roomType = options.roomType
  62. })
  63. onMounted(async () => {
  64. await getRoom()
  65. if (roomList.length === 0) {
  66. uni.showModal({
  67. title: '该房型无可用房间可供选择,请选择其它房型',
  68. showCancel: false,
  69. success() {
  70. uni.navigateBack()
  71. }
  72. })
  73. }
  74. })
  75. </script>
  76. <style lang="scss">
  77. .container {
  78. display: flex;
  79. // justify-content: space-between;
  80. width: 600rpx;
  81. margin: 0 auto;
  82. flex-wrap: wrap;
  83. .room {
  84. width: 180rpx;
  85. height: 180rpx;
  86. margin: 10rpx 10rpx;
  87. color: #FFFFFF;
  88. background-color: #a09cc4;
  89. border-radius: 15rpx;
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. }
  94. }
  95. </style>