selectRoom.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. if (this.roomList.length === 0) {
  98. uni.showModal({
  99. title: '该房型无可用房间可供选择,请选择其它房型',
  100. showCancel: false,
  101. success() {
  102. uni.navigateBack()
  103. }
  104. })
  105. }
  106. },
  107. // #ifdef MP-WEIXIN
  108. onShareAppMessage(info) {
  109. return {
  110. title: '源享住',
  111. path: 'pages/login/login',
  112. imageUrl: "/static/logo.png"
  113. }
  114. }
  115. // #endif
  116. }
  117. </script>
  118. <style lang="scss">
  119. page {
  120. background: #EFEFF4;
  121. width: 100%;
  122. display: flex;
  123. flex-direction: column;
  124. .container {
  125. .sticky {
  126. position: sticky;
  127. background-color: #fff;
  128. width: 100%;
  129. top: 0;
  130. z-index: 999;
  131. }
  132. .select-room {
  133. display: flex;
  134. flex-wrap: wrap;
  135. width: 600rpx;
  136. margin: 0 auto;
  137. .room-item {
  138. width: 180rpx;
  139. height: 180rpx;
  140. margin: 10rpx 10rpx;
  141. text-align: center;
  142. color: #FFFFFF;
  143. background-color: #a09cc4;
  144. border-radius: 15rpx;
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. }
  149. }
  150. }
  151. }
  152. </style>