detail.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="page">
  3. <u-swiper :list="item.imgs" :effect3d="true" :height="300"></u-swiper>
  4. <view class="hotel_item">
  5. <view class="name">{{ item.name }}</view>
  6. <view class="address">
  7. <view class="dz">{{ item.addres }}</view>
  8. <view class="dh" @click="dh()">导航</view>
  9. </view>
  10. <map class="map" :latitude="item.lat" :longitude="item.lng" :markers="[{ latitude: item.lat, longitude: item.lng }]"></map>
  11. </view>
  12. <view class="hotel_item">
  13. <view class="v_title">
  14. <image src="../../static/lo.png" class="lo" mode="widthFix"></image>
  15. <view class="hd">预订房间</view>
  16. </view>
  17. <view class="r_item" v-for="(it, index) in item.rooms" :key="index">
  18. <image :src="ip + it.pic" mode="aspectFill" class="pic"></image>
  19. <view class="con">
  20. <view class="title omit">{{ it.title }}</view>
  21. <view class="ms">
  22. <text class="rmb">¥{{ it.price }}</text>
  23. <text>起</text>
  24. </view>
  25. <view class="ms">还剩13间房</view>
  26. <view class="btn" @click="popup(it)">预订</view>
  27. </view>
  28. <view class="clear"></view>
  29. </view>
  30. </view>
  31. <!--预订房间-->
  32. <u-popup v-model="popup_show" :mask-close-able="false" mode="center" border-radius="14" width="90%" height="auto" :closeable="true">
  33. <view class="u-popup">
  34. <view class="tttt" style="font-weight: bolder;">预订房间</view>
  35. <u-steps :list="numList" mode="number" :current="0" active-color="#c74547" style="margin: 20px 0px 20px 0px;"></u-steps>
  36. <view class="form_group hr">
  37. <view class="lable">房型</view>
  38. <input :value="book.room + '(¥' + book.price + '起)'" :disabled="true" />
  39. </view>
  40. <view class="form_group hr">
  41. <view class="lable">姓名</view>
  42. <input placeholder="请输入姓名" v-model="book.name" />
  43. </view>
  44. <view class="form_group hr">
  45. <view class="lable">手机号</view>
  46. <input type="number" placeholder="请输入手机号" v-model="book.phone" />
  47. </view>
  48. <view class="form_group">
  49. <view class="lable">入住日期</view>
  50. <input placeholder="请选择入住日期" v-model="book.day" :disabled="true" @click="show = true" />
  51. <text class="day" v-if="book.days">{{ book.days }}天</text>
  52. <u-calendar v-model="show" mode="range" :start-text="'入住'" :end-text="'退房'" @change="change" max-date="2050" :min-date="min_date"></u-calendar>
  53. </view>
  54. <button class="btn" @click="add()">确认</button>
  55. </view>
  56. </u-popup>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. ip: this.$http.urls.ip,
  64. numList: [{ name: '资料填写' }, { name: '酒店确认' }, { name: '登记入住' }],
  65. item: {}, //酒店信息
  66. book: {}, //预订房间
  67. min_date: this.$util.getDate('day'),
  68. popup_show: false,
  69. show: false
  70. };
  71. },
  72. onLoad(e) {
  73. this.$http.request({
  74. url: this.$http.urls.hotelDetail,
  75. data: { shopId: e.shopId },
  76. success: res => {
  77. this.item = res.data.data;
  78. this.item.imgs = []; //轮播图
  79. this.item.showPictures = this.item.showPictures.split(',');
  80. this.item.showPictures.forEach(item => {
  81. this.item.imgs.push({ image: this.ip + item });
  82. });
  83. }
  84. });
  85. },
  86. methods: {
  87. //导航
  88. dh() {
  89. uni.openLocation({
  90. latitude: Number(this.item.lat),
  91. longitude: Number(this.item.lng),
  92. address: this.item.addres,
  93. success: res => {},
  94. fail: error => {
  95. console.log(error);
  96. }
  97. });
  98. },
  99. change(e) {
  100. this.book.day = e.startMonth + '-' + e.startDay + ' 至 ' + e.endMonth + '-' + e.endDay;
  101. this.book.min = e.startDate;
  102. this.book.max = e.endDate;
  103. this.book.days = this.$util.getDaysBetween(e.startDate, e.endDate);
  104. },
  105. popup(item) {
  106. this.book = {};
  107. this.book.room = item.title;
  108. this.book.price = item.price;
  109. this.book.roomId = item.id;
  110. this.popup_show = true;
  111. },
  112. add() {
  113. let rule = [
  114. { name: 'name', checkType: 'notnull', errorMsg: '请输入你的姓名' },
  115. { name: 'phone', checkType: 'notnull', errorMsg: '请输入你的手机号' },
  116. { name: 'day', checkType: 'notnull', errorMsg: '请选择入住日期' }
  117. ];
  118. if (!this.$verify.check(this.book, rule)) {
  119. uni.showModal({ content: this.$verify.error, showCancel: false });
  120. return;
  121. }
  122. this.book.memberId = this.$getUser().memberId;
  123. this.$http.request({
  124. method: 'POST',
  125. url: this.$http.urls.hotelBook,
  126. data: this.book,
  127. success: res => {
  128. uni.showToast({ title: '操作成功' });
  129. this.popup_show = false;
  130. }
  131. });
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. .page {
  138. padding: 12px;
  139. .map {
  140. width: 100%;
  141. height: 100px;
  142. margin-top: 20px;
  143. border-radius: 5px;
  144. }
  145. .r_item {
  146. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0);
  147. .btn {
  148. float: right;
  149. margin-top: -54px;
  150. padding: 5px 25px;
  151. border-radius: 20px;
  152. background-color: orange;
  153. margin-right: -34px;
  154. }
  155. }
  156. .day {
  157. position: absolute;
  158. color: orange;
  159. right: 12px;
  160. }
  161. }
  162. </style>