selectRoom.vue 3.6 KB

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