detail.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 omit">
  8. <text>{{ item.addres }}</text>
  9. </view>
  10. <view class="dh" @click="dh()"><text class="icon">&#xe64a;</text></view>
  11. <view class="clear"></view>
  12. </view>
  13. <view class="address">
  14. <view class="dz">
  15. <text>{{ item.bossPhone }}</text>
  16. </view>
  17. <view class="dh" @click="phone()"><text class="icon">&#xe634;</text></view>
  18. <view class="clear"></view>
  19. </view>
  20. </view>
  21. <view class="hotel_item" v-if="item.shopType == 2">
  22. <view class="v_title">
  23. <image src="../../static/lo.png" class="lo" mode="widthFix"></image>
  24. <view class="hd">预订房间</view>
  25. </view>
  26. <view v-if="item.rooms.length > 0 && item.enableFlag == 0">
  27. <view class="r_item" v-for="(it, index) in item.rooms" :key="index" @click="popup(it)">
  28. <image :src="ip + it.pic" mode="aspectFill" class="pic"></image>
  29. <view class="con">
  30. <view class="title omit bol">{{ it.title }}</view>
  31. <view class="rooms">{{ it.nums }}间房</view>
  32. <view class="ms" style="padding-top:7px;">
  33. <text class="rmb">¥</text>
  34. <text class="price">{{ it.price }}</text>
  35. <text class="qi">起</text>
  36. </view>
  37. <view class="btn" style="margin-top: -63px;">
  38. <text class="icon">&#xe61a;</text>
  39. <text>预订</text>
  40. </view>
  41. </view>
  42. <view class="clear"></view>
  43. </view>
  44. </view>
  45. <view class="noLogin" v-else>
  46. <image class="u-error-icon" src="../../static/sj.png" mode="widthFix"></image>
  47. <view class="dll" style="border: 0px;padding-bottom: 20px;">暂无服务</view>
  48. </view>
  49. </view>
  50. <!--预订房间-->
  51. <u-popup v-model="popup_show" :mask-close-able="false" mode="center" border-radius="14" width="90%" height="auto" :closeable="true">
  52. <view class="u-popup">
  53. <view class="tttt" style="font-weight: bolder;">预订房间</view>
  54. <view class="tk" style="background-color: #F9EFD2;color: #FF9D1D;margin-bottom: 10px;">仅作基本的订房操作,实际情况以酒店方为准</view>
  55. <u-steps :list="numList" mode="number" :current="0" active-color="#c74547" style="margin: 20px 0px 20px 0px;"></u-steps>
  56. <view class="form_group hr">
  57. <view class="lable">房型</view>
  58. <input :value="book.room + '(¥' + book.price + '起)'" :disabled="true" />
  59. </view>
  60. <view class="form_group hr">
  61. <view class="lable">姓名</view>
  62. <input placeholder="请输入姓名" v-model="book.name" />
  63. </view>
  64. <view class="form_group hr">
  65. <view class="lable">手机号</view>
  66. <input type="number" placeholder="请输入手机号" v-model="book.phone" />
  67. </view>
  68. <view class="form_group">
  69. <view class="lable">入住日期</view>
  70. <input placeholder="请选择入住日期" v-model="book.day" :disabled="true" @click="calendar_show = true" />
  71. <text class="day" v-if="book.days">{{ book.days }}天</text>
  72. </view>
  73. <button class="btn" @click="add()">确认</button>
  74. </view>
  75. </u-popup>
  76. <u-calendar v-model="calendar_show" mode="range" :start-text="'入住'" :end-text="'退房'" @change="change" max-date="2050" :min-date="min_date"></u-calendar>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. ip: this.$http.urls.ip,
  84. numList: [{ name: '资料填写' }, { name: '酒店确认' }, { name: '登记入住' }],
  85. item: {}, //酒店信息
  86. book: {}, //预订房间
  87. min_date: this.$util.getDate('day'),
  88. popup_show: false,
  89. calendar_show: false
  90. };
  91. },
  92. onLoad(e) {
  93. this.$http.request({
  94. url: this.$http.urls.hotelDetail,
  95. data: { shopId: e.shopId },
  96. success: res => {
  97. this.item = res.data.data;
  98. this.item.imgs = []; //轮播图
  99. this.item.showPictures = this.item.showPictures.split(',');
  100. this.item.showPictures.forEach(item => {
  101. this.item.imgs.push({ image: this.ip + item });
  102. });
  103. }
  104. });
  105. },
  106. methods: {
  107. //导航
  108. dh() {
  109. uni.openLocation({
  110. latitude: Number(this.item.lat),
  111. longitude: Number(this.item.lng),
  112. address: this.item.addres,
  113. success: res => {},
  114. fail: error => {
  115. console.log(error);
  116. }
  117. });
  118. },
  119. //拨打电话
  120. phone() {
  121. uni.makePhoneCall({
  122. phoneNumber: this.item.bossPhone
  123. });
  124. },
  125. change(e) {
  126. this.book.day = e.startMonth + '-' + e.startDay + ' 至 ' + e.endMonth + '-' + e.endDay;
  127. this.book.min = e.startDate;
  128. this.book.max = e.endDate;
  129. this.book.days = this.$util.getDaysBetween(e.startDate, e.endDate);
  130. },
  131. popup(item) {
  132. this.book = {};
  133. this.book.room = item.title;
  134. this.book.price = item.price;
  135. this.book.roomId = item.id;
  136. this.popup_show = true;
  137. },
  138. //房间预定
  139. add() {
  140. let rule = [
  141. { name: 'name', checkType: 'notnull', errorMsg: '请输入你的姓名' },
  142. { name: 'phone', checkType: 'phoneno', errorMsg: '请输入正确手机号' },
  143. { name: 'day', checkType: 'notnull', errorMsg: '请选择入住日期' }
  144. ];
  145. if (!this.$verify.check(this.book, rule)) {
  146. uni.showModal({ content: this.$verify.error, showCancel: false });
  147. return;
  148. }
  149. this.book.memberId = this.$getUser().memberId;
  150. this.book.openid = this.$getUser().openid;
  151. //订阅通知
  152. uni.requestSubscribeMessage({
  153. tmplIds: ['n8RXfziuC2B1UmBThhxNuo45QufO8xd5QepzghBfVJc', '-7bgeC4AoVA-GHLmVCVnPB6Ja_1Tru54qsYnQK4baOE'],
  154. complete: c => {
  155. this.$http.request({
  156. method: 'POST',
  157. url: this.$http.urls.hotelBook,
  158. data: this.book,
  159. success: res => {
  160. uni.showToast({ title: '操作成功' });
  161. this.popup_show = false;
  162. uni.redirectTo({
  163. url: '/pages/order/my'
  164. });
  165. }
  166. });
  167. }
  168. });
  169. }
  170. }
  171. };
  172. </script>
  173. <style lang="scss">
  174. .page {
  175. padding: 12px;
  176. .r_item {
  177. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0);
  178. border-radius: 0px;
  179. }
  180. .day {
  181. position: absolute;
  182. color: orange;
  183. right: 12px;
  184. }
  185. }
  186. </style>