selectRoom.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view>
  3. <u-picker :show="showBuilding" :columns="buildings" @confirm="confirmBuilding"
  4. @cancel="showBuilding=false"></u-picker>
  5. <u-picker :show="showFloor" :columns="floors" @confirm="confirmFloor" @cancel="showFloor=false"></u-picker>
  6. <view class="select">
  7. <view class="select-building">
  8. <view class="select-floor-left">
  9. <text>{{building}}栋</text>
  10. </view>
  11. <view class="select-floor-right">
  12. <u-button @click="showBuilding = true">选择楼栋</u-button>
  13. </view>
  14. </view>
  15. <view class="select-floor">
  16. <view class="select-floor-left">
  17. <text>{{floor}}F</text>
  18. </view>
  19. <view class="select-floor-right">
  20. <u-button @click="showFloor = true">选择楼层</u-button>
  21. </view>
  22. </view>
  23. </view>
  24. <u-modal :show="modalShow" :title="modalText" :content='content' showCancelButton="true"
  25. @confirm="confirmSelectRoom" @cancel="modalShow=false"></u-modal>
  26. <view class="select-room">
  27. <view class="room-item" v-for="item in roomInfos" @click="select(item)" id="item.room"
  28. :style="{'background':' #'+item.color}">
  29. <view class="room-item-inner">
  30. <view class="">
  31. <text>{{item.room}}</text>
  32. </view>
  33. <view class="">
  34. <text>({{item.text}})</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState,
  44. mapMutations
  45. } from 'vuex'
  46. export default {
  47. data() {
  48. return {
  49. showBuilding: false,
  50. showFloor: false,
  51. buildings: [
  52. []
  53. ],
  54. floors: [
  55. []
  56. ],
  57. building: '',
  58. floor: '',
  59. roomInfos: [],
  60. modalShow: false,
  61. modalText: '',
  62. selectedRoom: '',
  63. roomType: ''
  64. };
  65. },
  66. computed: {
  67. ...mapState('m_user', ['userInfo']),
  68. ...mapState('m_business', ['currentHotelName', 'currentHotelId', 'reservationInfo']),
  69. },
  70. methods: {
  71. ...mapMutations('m_business', ['updateReservationInfo']),
  72. confirmBuilding(building) {
  73. this.building = building.value[0]
  74. this.showBuilding = false;
  75. this.getFloor(this.currentHotelId, this.building)
  76. },
  77. confirmFloor(floor) {
  78. this.floor = floor.value[0]
  79. this.showFloor = false;
  80. this.getRoomInfo(this.currentHotelId, this.building, this.floor)
  81. },
  82. async getBuilding() {
  83. let buildingRes = await uni.$http.post('/building', {
  84. hotelId: this.currentHotelId,
  85. roomType: this.roomType
  86. });
  87. this.buildings[0] = buildingRes.data.data
  88. this.building = this.buildings[0][0]
  89. this.getFloor(this.currentHotelId, this.building)
  90. },
  91. async getFloor(hotelId, building) {
  92. let floorRes = await uni.$http.post('/floor', {
  93. hotelId: hotelId,
  94. building: building,
  95. roomType: this.roomType
  96. });
  97. this.floors[0] = floorRes.data.data
  98. this.floor = this.floors[0][0]
  99. this.getRoomInfo(this.currentHotelId, this.building, this.floor)
  100. },
  101. async getRoomInfo(hotelId, building, floor) {
  102. let res = await uni.$http.post('/roomInfo', {
  103. hotelId: hotelId,
  104. building: building,
  105. floor: floor,
  106. roomType: this.roomType,
  107. pageNo: 1,
  108. pageSize: 999
  109. })
  110. this.roomInfos = res.data.data.records
  111. this.roomInfos?.forEach(info => {
  112. if (info.status == 0) {
  113. info.text = '可选'
  114. info.color = '7098F6'
  115. } else {
  116. info.text = '不可预订'
  117. info.color = '999999'
  118. }
  119. })
  120. },
  121. select(item) {
  122. if (item.status !== 0) {
  123. uni.$showMsg('该房间不可预订!')
  124. } else {
  125. this.selectedRoom = item.room
  126. this.modalText = "确认选择" + item.room + '房间?'
  127. this.modalShow = true
  128. }
  129. },
  130. confirmSelectRoom() {
  131. let temp = this.reservationInfo
  132. temp.orderInfo.building = this.building
  133. temp.orderInfo.floor = this.floor
  134. temp.orderInfo.room = this.selectedRoom
  135. console.log('temp', temp)
  136. this.modalShow = false;
  137. this.updateReservationInfo(temp)
  138. uni.navigateTo({
  139. url: '/subpkg_checkin/addGuest/addGuest'
  140. })
  141. }
  142. },
  143. onLoad(options) {
  144. console.log(options.roomType)
  145. this.roomType = options.roomType
  146. this.getBuilding();
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .select {
  152. display: flex;
  153. margin-top: 20rpx;
  154. margin-bottom: 20rpx;
  155. .select-floor,
  156. .select-building {
  157. display: flex;
  158. width: 50%;
  159. button {
  160. background-color: #DCDCDC;
  161. }
  162. .select-floor-left {
  163. width: 50%;
  164. text-align: center;
  165. text {
  166. line-height: 80rpx;
  167. }
  168. }
  169. }
  170. }
  171. .select-room {
  172. display: flex;
  173. flex-wrap: wrap;
  174. width: 600rpx;
  175. margin: 0 auto;
  176. .room-item {
  177. width: 180rpx;
  178. height: 180rpx;
  179. margin: 10rpx 10rpx;
  180. text-align: center;
  181. color: #FFFFFF;
  182. border-radius: 15rpx;
  183. .room-item-inner {
  184. margin-top: 40rpx;
  185. }
  186. }
  187. }
  188. </style>