selectRoom.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="container">
  3. <view class="sticky">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <NavigateBar title="房间选择" control="back" bgcolor="#a09cc4"></NavigateBar>
  6. <!-- #endif -->
  7. <!-- #ifdef MP-ALIPAY -->
  8. <NavigateBar title="房间选择" bgcolor="#a09cc4"></NavigateBar>
  9. <!-- #endif -->
  10. </view>
  11. <u-modal :show="modalShow" :title="modalTitle" :showCancelButton="true" @confirm="confirmSelectRoom"
  12. @cancel="modalShow=false"></u-modal>
  13. <view class="select-room">
  14. <view class="room-item" v-for="(item,index) in roomList" :key=item.room @click="select(item)">
  15. <view class="room-item-inner">
  16. <text>{{item.room}}</text>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapState,
  25. mapMutations
  26. } from 'vuex'
  27. import NavigateBar from "../../components/navigateBar/navigate-bar.vue";
  28. export default {
  29. components: {
  30. NavigateBar
  31. },
  32. data() {
  33. return {
  34. room: ',',
  35. building: '',
  36. floor: '',
  37. roomList: [],
  38. modalShow: false,
  39. modalTitle: '',
  40. roomType: ''
  41. };
  42. },
  43. computed: {
  44. ...mapState('m_business', ['currentHotel', 'order']),
  45. },
  46. methods: {
  47. ...mapMutations('m_business', ['updateOrder']),
  48. async getRoomInfo() {
  49. let res = await uni.$http.post('/hotel/room', {
  50. hotelId: this.currentHotel.hotelId,
  51. roomType: this.roomType,
  52. startTime: this.order.startTime,
  53. endTime: this.order.endTime,
  54. pageNo: 1,
  55. pageSize: 10
  56. })
  57. this.roomList = res.data.data.records
  58. },
  59. select(item) {
  60. if (item.text === '不可预订') {
  61. uni.$showMsg('该房间不可预订!')
  62. } else {
  63. this.modalTitle = "确认选择" + item.room + '房间?'
  64. this.building = item.building
  65. this.floor = item.floor
  66. this.room = item.room
  67. this.modalShow = true
  68. }
  69. },
  70. confirmSelectRoom() {
  71. let info = {
  72. building: this.building,
  73. floor: this.floor,
  74. room: this.room,
  75. status: 'ROOM_SELECTED'
  76. }
  77. if (this.order.orderSource === 'MINI_APP') {
  78. info.isResv = false
  79. }
  80. let order = {
  81. ...this.order,
  82. ...info
  83. }
  84. console.log("confirm order:", order)
  85. this.updateOrder(order)
  86. uni.navigateTo({
  87. url: '/subpkg_checkin/addGuest/addGuest'
  88. })
  89. this.modalShow = false;
  90. }
  91. },
  92. async onLoad(options) {
  93. //获取从选择房间类型页面传过来的房间类型
  94. this.roomType = options.roomType
  95. //查询该房间类型在订单时间段内可用的所有房间
  96. await this.getRoomInfo();
  97. },
  98. // #ifdef MP-WEIXIN
  99. onShareAppMessage(info) {
  100. return {
  101. title: '源享住',
  102. path: 'pages/login/login',
  103. imageUrl: "/static/logo.png"
  104. }
  105. }
  106. // #endif
  107. }
  108. </script>
  109. <style lang="scss">
  110. page {
  111. background: #EFEFF4;
  112. width: 100%;
  113. display: flex;
  114. flex-direction: column;
  115. .container {
  116. .sticky {
  117. position: sticky;
  118. background-color: #fff;
  119. width: 100%;
  120. top: 0;
  121. z-index: 999;
  122. }
  123. .select-room {
  124. display: flex;
  125. flex-wrap: wrap;
  126. width: 600rpx;
  127. margin: 0 auto;
  128. .room-item {
  129. width: 180rpx;
  130. height: 180rpx;
  131. margin: 10rpx 10rpx;
  132. text-align: center;
  133. color: #FFFFFF;
  134. background-color: #a09cc4;
  135. border-radius: 15rpx;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. }
  140. }
  141. }
  142. }
  143. </style>