hotelDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div class="hotelDetail">
  3. <div class="hotelinnfo">
  4. <div class="p p1 flex_r flex_js flex_ac">
  5. <div class="day">
  6. <span>{{ daydate(roomInfo.checkInDate) }}</span>
  7. <span class="teg">{{ getThatDay(roomInfo.checkInDate) }}</span>
  8. </div>
  9. <div class="daynum">{{ numberdays }} 晚</div>
  10. <div class="day">
  11. <span>{{ daydate(roomInfo.checkOutDate) }}</span>
  12. <span class="teg">{{ getThatDay(roomInfo.checkOutDate) }}</span>
  13. </div>
  14. </div>
  15. <div class="p p2 iconfont">{{roomInfo.roomName}}&#xe605;{{roomInfo.ratePlanName}}</div>
  16. <div class="p p3">
  17. <span>{{ roomInfo.bedType }}</span>
  18. <span>{{ roomInfo.windowType }}</span>
  19. <span>{{ roomInfo.breakfast }}</span>
  20. <span>可入住{{ roomInfo.capacity }}人</span>
  21. </div>
  22. <div class="p4">
  23. <span class="iconfont">&#xe636;</span>
  24. <span>{{ roomInfo.cancelRule.desc }}</span>
  25. </div>
  26. </div>
  27. <div class="userinfo">
  28. <div class="tit">入住信息</div>
  29. <div class="p flex_r flex_js flex_ac">
  30. <span class="label">房间数量</span>
  31. <scroll-view class="scroll_H" :scroll-x="true">
  32. <div class="rommnum">
  33. <template v-for="i in 8">
  34. <div :class="{'r_num':true,'active':qda.roomNum==i}" :key="i" v-if="i>0" @click="roomNumf(i)">{{ i }} 间</div>
  35. </template>
  36. </div>
  37. </scroll-view>
  38. </div>
  39. <div class="p flex_r flex_jb flex_ac">
  40. <span class="label">住客姓名</span>
  41. <input v-model="qda.contactName" />
  42. </div>
  43. <div class="p flex_r flex_jb flex_ac">
  44. <span class="label">联系电话</span>
  45. <input v-model="qda.contactMobile" />
  46. </div>
  47. <div class="p flex_r flex_js flex_ac">
  48. <span class="label">最晚到店</span>
  49. <scroll-view class="scroll_H" :scroll-x="true">
  50. <div class="rommnum">
  51. <div v-for="(a,b) in Timearr" :key="b" class="r_num" :class="[a.active?'active':'']" @click="Timeitem(b,a.t)">{{ a.v }}</div>
  52. </div>
  53. </scroll-view>
  54. </div>
  55. <div class="p flex_r flex_jb flex_ac">
  56. <span class="label">备注</span>
  57. <input v-model="qda.orderRemark" />
  58. </div>
  59. </div>
  60. <div class="money card">
  61. <div class="li flex_r flex_jb">
  62. <span>消费金额</span>
  63. <span>¥{{ cartTotal || 0 }}</span>
  64. </div>
  65. <div class="li flex_r flex_jb">
  66. <span>消费金抵扣<span class="corg">{{Integral}}%</span></span>
  67. <span class="corg">-¥{{ deduction || 0 }}</span>
  68. </div>
  69. <div class="li flex_r flex_jb">
  70. <span>实付金额</span>
  71. <span>¥{{ actuallypaid || 0 }}</span>
  72. </div>
  73. </div>
  74. <div class="money card">
  75. <div class="li flex_r flex_jb">
  76. <span>赠送茶宝</span>
  77. <span>{{ chabao || 0 }}</span>
  78. </div>
  79. </div>
  80. <div class="footbtn" @click="onpay">立即支付</div>
  81. </div>
  82. </template>
  83. <script>
  84. import { ToPayOpre } from "@/utils/reqTools.js";
  85. let toPayOpre = new ToPayOpre();
  86. import { getCache } from "@/utils/storage.js";
  87. import { post } from "@/request/api.js";
  88. import { getThatDay, getDaysBetween } from "@/utils/myfun.js"
  89. export default {
  90. name: "hotelDetail",
  91. props: {},
  92. components: {},
  93. data() {
  94. return {
  95. numberdays: 1,
  96. qda: {},
  97. roomInfo: getCache("roomInfo"),
  98. userinfo: uni.getStorageSync("userinfo"),
  99. ratio: {},
  100. cartTotal: 0,
  101. Integral: 0,
  102. deduction: 0,
  103. actuallypaid: 0,
  104. chabao: 0,
  105. Timearr: [], //最晚时间数组
  106. guestNames: [], // 房客姓名,每个房间预留一个房客姓名。长度需和房间数量保持一致
  107. };
  108. },
  109. methods: {
  110. getThatDay,
  111. getDaysBetween,
  112. getIntegral() {
  113. post("local/getIntegral", { type: 4 }).then(res => {
  114. if (res.code == 0) {
  115. this.ratio = res.data;
  116. this.computef();
  117. }
  118. })
  119. },
  120. computef() {
  121. let { integral, chabao } = this.ratio
  122. let i1 = integral,
  123. i2 = chabao;
  124. let Total = this.$h.Mul(this.roomInfo.aveOriginalPrice, this.numberdays);
  125. this.cartTotal = this.$h.Mul(Total, this.qda.roomNum);
  126. this.Integral = this.$h.Mul(i1, 100);
  127. this.deduction = this.$h.Mul(this.cartTotal, i1);
  128. this.actuallypaid = this.$h.Sub(this.cartTotal, this.deduction);
  129. this.chabao = this.$h.Mul(this.actuallypaid, i2).toFixed(2);
  130. },
  131. arriveTimearr(){
  132. let tim = this.$day(this.roomInfo.checkInDate + " 18:00:00"), arr = [];
  133. for (let a = 0; a < 9; a++) {
  134. let t = tim.add(a,"h")
  135. arr.push({
  136. t: t.format("YYYY-MM-DD HH:mm"),
  137. v: t.format("HH:mm"),
  138. active: false
  139. })
  140. }
  141. this.Timearr = arr;
  142. this.qda.arriveTime = arr[2].t
  143. this.Timearr[2].active = true
  144. },
  145. daydate(va) {
  146. return this.$day(va).format("M月DD日")
  147. },
  148. roomNumf(va) {
  149. this.qda.roomNum = va
  150. this.computef();
  151. this.guestNames = []
  152. for (let a = 0; a < va; a++) {
  153. this.guestNames.push(this.qda.contactName)
  154. }
  155. },
  156. Timeitem(inx,va){
  157. for (let i of this.Timearr) {
  158. i.active = false
  159. }
  160. this.$set(this.Timearr[inx],"active",true)
  161. this.qda.arriveTime = va
  162. },
  163. onpay() {
  164. let RI = Object.assign({},this.roomInfo)
  165. let da = {
  166. ...this.qda,
  167. hotelID: RI.hotelID,
  168. ratePlanID: RI.ratePlanId,
  169. checkInDate: RI.checkInDate,
  170. checkOutDate: RI.checkOutDate,
  171. guestNames: this.guestNames,
  172. // orderAmount: this.actuallypaid
  173. }
  174. delete RI.ratePlans;
  175. delete RI.ratePlanId;
  176. da.attachment = JSON.stringify(RI);
  177. post("local/hotel/addOrder", da).then(res => {
  178. if (res.code == 0 && res.data.prepayid) {
  179. toPayOpre.toPay(res.data, (rea) => {
  180. if (!rea) {
  181. // 支付成功
  182. this.goto("/pagesB/orderingfood/orderlist")
  183. } else {
  184. // 支付失败
  185. }
  186. });
  187. }
  188. })
  189. }
  190. },
  191. onLoad(da) {
  192. // this.roomInfo = getCache("roomInfo");
  193. this.getIntegral();
  194. this.qda = {
  195. roomNum: 1,
  196. contactName: this.userinfo.nickname,
  197. contactMobile: this.userinfo.mobile
  198. }
  199. this.roomNumf(1);
  200. this.numberdays = getDaysBetween(this.roomInfo.checkInDate, this.roomInfo.checkOutDate);
  201. this.arriveTimearr();
  202. },
  203. onShow() {},
  204. mounted() {},
  205. };
  206. </script>
  207. <style scoped lang='scss'>
  208. .hotelDetail {
  209. padding: 28rpx 32rpx;
  210. }
  211. .hotelinnfo {
  212. background-color: #fff;
  213. border-radius: 16rpx;
  214. padding: 26rpx 30rpx;
  215. box-shadow: 4rpx 4rpx 16rpx 10rpx rgba($color: #000, $alpha: 0.15);
  216. .daynum {
  217. margin: 0 36rpx;
  218. font-size: 32rpx;
  219. padding: 3rpx 16rpx;
  220. border-radius: 8rpx;
  221. background-color: rgba($color: #000, $alpha: 0.06);
  222. }
  223. .day {
  224. font-size: 36rpx;
  225. font-weight: 600;
  226. span {
  227. vertical-align: middle;
  228. }
  229. }
  230. .teg {
  231. font-weight: 400;
  232. font-size: 26rpx;
  233. margin-left: 10rpx;
  234. }
  235. .p2 {
  236. font-size: 34rpx;
  237. font-weight: 600;
  238. }
  239. .p3 {
  240. font-size: 28rpx;
  241. span {
  242. margin-right: 16rpx;
  243. :last-child {
  244. margin-right: 0;
  245. }
  246. }
  247. }
  248. .p4 {
  249. color: #00B76C;
  250. font-size: 26rpx;
  251. .iconfont {
  252. margin-right: 16rpx;
  253. color: #00B76C;
  254. }
  255. }
  256. .p {
  257. margin-bottom: 16rpx;
  258. &:last-child {
  259. margin-bottom: 0;
  260. }
  261. }
  262. }
  263. .userinfo {
  264. background-color: #fff;
  265. border-radius: 16rpx;
  266. padding: 26rpx 30rpx;
  267. margin: 30rpx 0;
  268. box-shadow: 4rpx 4rpx 16rpx 10rpx rgba($color: #000, $alpha: 0.15);
  269. .tit {
  270. font-size: 34rpx;
  271. font-weight: 600;
  272. margin-bottom: 16rpx;
  273. }
  274. .p {
  275. padding: 10rpx 0;
  276. margin-bottom: 6rpx;
  277. border-bottom: 1px solid rgba($color: #000, $alpha: 0.05);
  278. &:last-child {
  279. margin-bottom: 0;
  280. border-bottom: none;
  281. }
  282. .label {
  283. display: inline-block;
  284. width: 136rpx;
  285. font-size: 28rpx;
  286. color: #999;
  287. }
  288. .scroll_H {
  289. width: calc(100% - 136rpx);
  290. }
  291. input {
  292. font-size: 30rpx;
  293. width: calc(100% - 136rpx);
  294. padding-left: 12rpx;
  295. }
  296. }
  297. .rommnum {
  298. white-space: nowrap;
  299. .r_num {
  300. display: inline-block;
  301. margin-right: 18rpx;
  302. padding: 10rpx 20rpx;
  303. font-size: 26rpx;
  304. border-radius: 8rpx;
  305. border: 1rpx solid rgba($color: #000, $alpha: 0.032);
  306. background-color: rgba($color: #000, $alpha: 0.032);
  307. &:last-child {
  308. margin-right: 0;
  309. }
  310. &.active {
  311. border-color: rgba($color: #00B76C, $alpha: 0.36);
  312. background-color: rgba($color: #00B76C, $alpha: 0.06);
  313. }
  314. }
  315. }
  316. }
  317. .money {
  318. .li {
  319. margin-bottom: 16rpx;
  320. &:last-child {
  321. margin-bottom: 0;
  322. }
  323. span {
  324. font-size: 30rpx;
  325. }
  326. }
  327. .corg {
  328. color: #18bb88;
  329. margin-left: 12rpx;
  330. }
  331. }
  332. .card {
  333. background-color: #fff;
  334. border-radius: 20rpx;
  335. margin-bottom: 30rpx;
  336. padding: 28rpx 30rpx;
  337. font-size: 32rpx;
  338. box-shadow: 4rpx 4rpx 16rpx 10rpx rgba($color: #000, $alpha: 0.15);
  339. &:last-child {
  340. margin-bottom: 0;
  341. }
  342. }
  343. .footbtn {
  344. width: calc(100% - 60rpx);
  345. height: 80rpx;
  346. background: #17bb87;
  347. border-radius: 45rpx;
  348. position: fixed;
  349. bottom: 50rpx;
  350. left: 30rpx;
  351. color: #fff;
  352. font-size: 36rpx;
  353. text-align: center;
  354. line-height: 80rpx;
  355. }
  356. </style>