affirmOrder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. <template>
  2. <view class="container">
  3. <!-- 导航栏图片区域 -->
  4. <view class="header">
  5. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/18.png" />
  6. <!-- 标题区域 -->
  7. <view class="header_title" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }">{{ hotelName }}</view>
  8. <!-- 返回图标区域 -->
  9. <view class="header_icon" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }" @click="handleBack">
  10. <img src="../../static/index/left.png" />
  11. </view>
  12. </view>
  13. <view class="body">
  14. <!-- 房间信息区域 -->
  15. <view class="info">
  16. <view class="info_time">
  17. {{ info.startTimeMonth }}月{{ info.startTimeDay }}日
  18. <text class="gap">{{ info.startTimeWeek }}</text>
  19. <view class="time_line"></view>
  20. <view class="time_num">{{ info.nightNum }}晚</view>
  21. <view class="time_line"></view>
  22. <view class="gap">{{ info.endTimeMonth }}月{{ info.endTimeDay }}日</view>
  23. <text>{{ info.endTimeWeek }}</text>
  24. </view>
  25. <view class="info_msg">{{ info.item.hName }}</view>
  26. <view class="info_type">
  27. <view class="type_item">{{ info.hTypeName }}</view>
  28. </view>
  29. <view class="info_tag">
  30. <view class="tag_item">{{ info.item.hAreas }}㎡</view>
  31. <view class="tag_item" v-for="tag in info.item.hConfigList" :key="tag.id">{{ tag.name }}</view>
  32. </view>
  33. </view>
  34. <!-- 入住信息区域 -->
  35. <view class="msg">
  36. <view class="msg_title">入住信息</view>
  37. <view class="msg_box">
  38. <view class="box_key">房间数量</view>
  39. <view class="box_value">{{ roomCount }}间</view>
  40. <view class="box_icon">
  41. <img class="img" src="../../static/index/add.png" @click="handleAdd" />
  42. <img class="img2" src="../../static/index/minus.png" @click="handleMinus" />
  43. </view>
  44. </view>
  45. <view class="msg_box">
  46. <view class="box_key">住客姓名</view>
  47. <view class="box_value">
  48. <input type="text" placeholder="请输入住客姓名" v-model="clientName" />
  49. </view>
  50. <view class="box_icon" @click="handleSelectClient">
  51. <img class="img2" src="../../static/index/people.png" />
  52. </view>
  53. </view>
  54. <view class="msg_box">
  55. <view class="box_key">联系电话</view>
  56. <view class="box_value">
  57. <input type="number" maxlength="11" placeholder="请输入联系电话" v-model="clientPhone" />
  58. </view>
  59. </view>
  60. <!-- <view class="msg_box" @click="handleSelectTime">
  61. <view class="box_key">预计到店</view>
  62. <view class="box_value" :class="{ color: !arriveTime }">{{ arriveTime ? arriveTime : '请选择预计到店时间' }}</view>
  63. <view class="box_icon">
  64. <img class="img3" src="../../static/index/right2.png" />
  65. </view>
  66. </view> -->
  67. <uv-datetime-picker
  68. ref="datetimePicker"
  69. v-model="timeValue"
  70. mode="datetime"
  71. :closeOnClickOverlay="false"
  72. confirmColor="#096562"
  73. :formatter="formatter"
  74. @confirm="confirm"
  75. ></uv-datetime-picker>
  76. </view>
  77. <!-- 本单可享区域 -->
  78. <view class="coupon" v-if="couponNum">
  79. <view class="coupon_title">本单可享</view>
  80. <view class="coupon_box">
  81. <view class="box_key">
  82. <img src="../../static/index/coupon.png" />
  83. 优惠券
  84. </view>
  85. <view class="box_value" @click="handleGoPage">
  86. <view class="value_count">{{ couponNum }}张可用</view>
  87. <img src="../../static/index/right2.png" />
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 费用明细区域 -->
  92. <view class="price">
  93. <view class="price_title">费用明细</view>
  94. <view class="price_box">
  95. <view class="box_key">在线支付</view>
  96. <view class="box_value">
  97. {{ roomCount }}间{{ info.nightNum }}晚 共
  98. <text>¥</text>
  99. <span>{{ totalPrice }}</span>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 房费区域 -->
  104. <view class="all">
  105. <view class="all_title">
  106. <text>房费</text>
  107. <text class="mr_30">¥{{ totalPrice }}</text>
  108. </view>
  109. <view class="all_box">
  110. <view class="box_list">
  111. <view class="list_item" v-for="(item, index) in info.dayList" :key="index">{{ item }}</view>
  112. </view>
  113. <view class="box_total">{{ roomCount }}间 x {{ info.nightNum }}晚 x ¥{{ info.item.price }}</view>
  114. </view>
  115. </view>
  116. <!-- 优惠区域 -->
  117. <view class="sale" v-if="couponNum">
  118. <view class="sale_top">
  119. <view class="top_key">优惠</view>
  120. <view class="top_value">- ¥70</view>
  121. </view>
  122. <view class="sale_bottom">
  123. <view class="bottom_key">
  124. <img src="../../static/index/coupon.png" />
  125. 折扣卷
  126. </view>
  127. <view class="bottom_value">- ¥70</view>
  128. </view>
  129. </view>
  130. </view>
  131. <!-- 底部提交订单区域 -->
  132. <view class="foot">
  133. <view class="foot_left">
  134. <text>¥</text>
  135. {{ totalPrice }}
  136. </view>
  137. <view class="foot_right" @click="goPagePay">提交订单</view>
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. export default {
  143. data() {
  144. return {
  145. info: {},
  146. // 预定房间数量
  147. roomCount: 1,
  148. // 住客姓名
  149. clientName: '',
  150. // 联系电话
  151. clientPhone: '',
  152. // 预计到店时间
  153. arriveTime: '',
  154. // 当前时间
  155. timeValue: Number(new Date()),
  156. // 民宿名称
  157. hotelName: '',
  158. // 状态栏高度
  159. statusBarH: 0,
  160. // 胶囊按钮栏高度
  161. customBarH: 0,
  162. // 优惠券数量
  163. couponNum: 0
  164. }
  165. },
  166. created() {
  167. // 获取系统信息
  168. uni.getSystemInfo({
  169. success: (e) => {
  170. // 获取状态栏高度
  171. this.statusBarH = e.statusBarHeight + 10
  172. // // 获取菜单按钮栏高度
  173. let custom = uni.getMenuButtonBoundingClientRect()
  174. this.customBarH = custom.height + 10
  175. }
  176. })
  177. },
  178. onLoad(options) {
  179. this.info = JSON.parse(options.info)
  180. this.hotelName = this.info.hotelName
  181. uni.$on('change', this.change)
  182. },
  183. computed: {
  184. // 总费用
  185. totalPrice() {
  186. if (this.info.item) {
  187. return (this.roomCount * this.info.item.price * this.info.nightNum).toFixed(2)
  188. }
  189. }
  190. },
  191. methods: {
  192. change(e) {
  193. this.clientName = e.name
  194. this.clientPhone = e.phone
  195. },
  196. handleSelectClient() {
  197. uni.navigateTo({
  198. url: '/pages/common/common?type=1'
  199. })
  200. },
  201. confirm(e) {
  202. // console.log(e.value)
  203. let date = new Date(e.value)
  204. let month = date.getMonth() + 1
  205. let day = date.getDate()
  206. let H = date.getHours()
  207. let M = date.getMinutes()
  208. this.arriveTime = `${month}月${day}日${H}:${M}分之前`
  209. },
  210. formatter(type, value) {
  211. if (type === 'year') {
  212. return `${value}年`
  213. }
  214. if (type === 'month') {
  215. return `${value}月`
  216. }
  217. if (type === 'day') {
  218. return `${value}日`
  219. }
  220. return value
  221. },
  222. handleSelectTime() {
  223. this.$refs.datetimePicker.open()
  224. },
  225. handleAdd() {
  226. this.roomCount++
  227. },
  228. handleMinus() {
  229. if (this.roomCount > 1) {
  230. this.roomCount--
  231. } else {
  232. uni.showToast({
  233. title: '至少需要预定1间',
  234. icon: 'none'
  235. })
  236. }
  237. },
  238. // 提交订单按钮回调
  239. async goPagePay() {
  240. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  241. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  242. if (!this.clientName) {
  243. uni.showToast({
  244. title: '请输入住客姓名',
  245. icon: 'none',
  246. mask: true
  247. })
  248. return
  249. }
  250. if (!reName.test(this.clientName)) {
  251. uni.showToast({
  252. title: '姓名格式有误',
  253. icon: 'none'
  254. })
  255. return
  256. }
  257. if (!this.clientPhone) {
  258. uni.showToast({
  259. title: '请输入联系电话',
  260. icon: 'none',
  261. mask: true
  262. })
  263. return
  264. }
  265. if (!rePhone.test(this.clientPhone)) {
  266. uni.showToast({
  267. title: '电话号码格式有误',
  268. icon: 'none'
  269. })
  270. return
  271. }
  272. const res = await this.$myRequest({
  273. url: '/mhotel/abkcreateOrder.action',
  274. data: {
  275. houseId: this.info.item.id,
  276. startTime: this.info.queryStartTime,
  277. endTime: this.info.queryEndTime,
  278. houseOrderNumber: this.roomCount,
  279. userName: this.clientName,
  280. userPhone: this.clientPhone,
  281. userId: uni.getStorageSync('userInfo').id
  282. }
  283. })
  284. // console.log(res)
  285. if (res.code === 200) {
  286. uni.navigateTo({
  287. url: `/pages/pay/pay?id=${res.data}`
  288. })
  289. }
  290. },
  291. handleBack() {
  292. uni.navigateBack(1)
  293. },
  294. handleGoPage() {
  295. uni.navigateTo({
  296. url: '/pages/coupon/coupon'
  297. })
  298. }
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped>
  303. .container {
  304. position: relative;
  305. display: flex;
  306. flex-direction: column;
  307. height: 100vh;
  308. overflow: hidden;
  309. background-color: #ebeced;
  310. .header {
  311. position: relative;
  312. height: 180rpx;
  313. overflow: hidden;
  314. img {
  315. width: 100%;
  316. }
  317. .header_title {
  318. position: absolute;
  319. top: 0;
  320. left: 182rpx;
  321. width: 50%;
  322. color: #fff;
  323. text-align: center;
  324. font-size: 28rpx;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. white-space: nowrap;
  328. }
  329. .header_icon {
  330. position: absolute;
  331. top: 0;
  332. left: 5rpx;
  333. width: 47rpx;
  334. height: 70rpx;
  335. img {
  336. width: 47rpx;
  337. height: 47rpx;
  338. }
  339. }
  340. }
  341. .body {
  342. height: calc(100vh - 306rpx);
  343. overflow-y: auto;
  344. .info {
  345. display: flex;
  346. flex-direction: column;
  347. box-sizing: border-box;
  348. padding: 0 30rpx;
  349. margin: 0 auto;
  350. margin-top: 18rpx;
  351. width: 710rpx;
  352. border-radius: 15rpx;
  353. background-color: #fff;
  354. .info_time {
  355. display: flex;
  356. align-items: center;
  357. margin-top: 20rpx;
  358. font-size: 32rpx;
  359. font-weight: bold;
  360. .time_line {
  361. width: 17rpx;
  362. height: 1rpx;
  363. background-color: #096562;
  364. }
  365. .time_num {
  366. box-sizing: border-box;
  367. padding: 0 15rpx;
  368. height: 46rpx;
  369. line-height: 46rpx;
  370. font-size: 24rpx;
  371. font-weight: 400;
  372. border-radius: 66rpx;
  373. border: 1rpx solid #096562;
  374. background-color: #f0f2f5;
  375. }
  376. .gap {
  377. margin: 0 10rpx;
  378. }
  379. text {
  380. font-size: 24rpx;
  381. font-weight: 400;
  382. }
  383. }
  384. .info_msg {
  385. margin-top: 15rpx;
  386. font-size: 28rpx;
  387. font-weight: bold;
  388. }
  389. .info_type {
  390. display: flex;
  391. flex-wrap: wrap;
  392. margin-top: 15rpx;
  393. .type_item {
  394. box-sizing: border-box;
  395. padding: 0 15rpx;
  396. margin-right: 20rpx;
  397. height: 41rpx;
  398. line-height: 41rpx;
  399. font-size: 24rpx;
  400. color: #fff;
  401. border-radius: 34rpx;
  402. background-color: #096562;
  403. }
  404. }
  405. .info_tag {
  406. display: flex;
  407. flex-wrap: wrap;
  408. margin: 18rpx 0 30rpx;
  409. color: #808080;
  410. font-size: 24rpx;
  411. .tag_item {
  412. margin-right: 20rpx;
  413. }
  414. }
  415. }
  416. .msg {
  417. box-sizing: border-box;
  418. padding-left: 26rpx;
  419. margin: auto;
  420. margin-top: 20rpx;
  421. width: 710rpx;
  422. border-radius: 15rpx;
  423. background-color: #fff;
  424. .msg_title {
  425. height: 87rpx;
  426. line-height: 87rpx;
  427. font-size: 28rpx;
  428. font-weight: bold;
  429. border-bottom: 1rpx solid #e6e6e6;
  430. }
  431. .msg_box {
  432. display: flex;
  433. align-items: center;
  434. height: 97rpx;
  435. font-size: 28rpx;
  436. border-bottom: 1rpx solid #e6e6e6;
  437. .box_key {
  438. width: 120rpx;
  439. color: #808080;
  440. }
  441. .box_value {
  442. margin-left: 30rpx;
  443. flex: 1;
  444. input {
  445. box-sizing: border-box;
  446. padding-right: 30rpx;
  447. width: 100%;
  448. }
  449. }
  450. .color {
  451. color: #808080;
  452. }
  453. .box_icon {
  454. display: flex;
  455. align-items: center;
  456. height: 100%;
  457. .img {
  458. width: 47rpx;
  459. height: 47rpx;
  460. }
  461. .img2 {
  462. margin: 0 30rpx;
  463. width: 37rpx;
  464. height: 37rpx;
  465. }
  466. .img3 {
  467. margin: 0 30rpx;
  468. width: 40rpx;
  469. height: 40rpx;
  470. }
  471. }
  472. }
  473. }
  474. .coupon {
  475. box-sizing: border-box;
  476. padding-left: 26rpx;
  477. margin: 20rpx auto 0;
  478. width: 710rpx;
  479. height: 197rpx;
  480. border-radius: 15rpx;
  481. background-color: #fff;
  482. .coupon_title {
  483. line-height: 92rpx;
  484. font-size: 28rpx;
  485. font-weight: bold;
  486. border-bottom: 1rpx solid #e6e6e6;
  487. }
  488. .coupon_box {
  489. display: flex;
  490. align-items: center;
  491. justify-content: space-between;
  492. height: 105rpx;
  493. .box_key {
  494. display: flex;
  495. align-items: center;
  496. font-size: 28rpx;
  497. img {
  498. margin-right: 10rpx;
  499. width: 40rpx;
  500. height: 40rpx;
  501. }
  502. }
  503. .box_value {
  504. display: flex;
  505. align-items: center;
  506. .value_count {
  507. display: flex;
  508. justify-content: center;
  509. align-items: center;
  510. width: 105rpx;
  511. height: 45rpx;
  512. color: #fff;
  513. font-size: 24rpx;
  514. border-radius: 7rpx;
  515. background-color: #ff5733;
  516. }
  517. img {
  518. margin-right: 17rpx;
  519. width: 40rpx;
  520. height: 40rpx;
  521. }
  522. }
  523. }
  524. }
  525. .price {
  526. box-sizing: border-box;
  527. padding-left: 26rpx;
  528. margin: 20rpx auto;
  529. width: 710rpx;
  530. height: 197rpx;
  531. border-radius: 15rpx;
  532. background-color: #fff;
  533. .price_title {
  534. line-height: 92rpx;
  535. font-size: 28rpx;
  536. font-weight: bold;
  537. border-bottom: 1rpx solid #e6e6e6;
  538. }
  539. .price_box {
  540. display: flex;
  541. justify-content: space-between;
  542. align-items: center;
  543. height: 92rpx;
  544. font-size: 28rpx;
  545. .box_key {
  546. color: #808080;
  547. }
  548. .box_value {
  549. display: flex;
  550. align-items: center;
  551. text {
  552. color: #ff5733;
  553. font-size: 24rpx;
  554. }
  555. span {
  556. margin-right: 30rpx;
  557. color: #ff5733;
  558. }
  559. }
  560. }
  561. }
  562. .all {
  563. box-sizing: border-box;
  564. padding-left: 26rpx;
  565. margin: 0 auto 20rpx;
  566. width: 710rpx;
  567. border-radius: 15rpx;
  568. background-color: #fff;
  569. .all_title {
  570. display: flex;
  571. height: 92rpx;
  572. justify-content: space-between;
  573. align-items: center;
  574. font-size: 28rpx;
  575. font-weight: bold;
  576. border-bottom: 1rpx solid #e6e6e6;
  577. .mr_30 {
  578. margin-right: 30rpx;
  579. }
  580. }
  581. .all_box {
  582. box-sizing: border-box;
  583. padding-right: 26rpx;
  584. display: flex;
  585. justify-content: space-between;
  586. font-size: 28rpx;
  587. .box_list {
  588. margin-bottom: 28rpx;
  589. color: #808080;
  590. .list_item {
  591. margin-top: 30rpx;
  592. }
  593. }
  594. .box_total {
  595. display: flex;
  596. justify-content: center;
  597. align-items: center;
  598. }
  599. }
  600. }
  601. .sale {
  602. margin: 0 auto 20rpx;
  603. box-sizing: border-box;
  604. padding: 0 30rpx;
  605. width: 710rpx;
  606. height: 209rpx;
  607. border-radius: 15rpx;
  608. background-color: #fff;
  609. .sale_top {
  610. display: flex;
  611. align-items: center;
  612. justify-content: space-between;
  613. height: 92rpx;
  614. font-size: 28rpx;
  615. font-weight: bold;
  616. .top_key {
  617. }
  618. .top_value {
  619. color: #ff5733;
  620. }
  621. }
  622. .sale_bottom {
  623. display: flex;
  624. align-items: center;
  625. justify-content: space-between;
  626. box-sizing: border-box;
  627. padding: 0 26rpx;
  628. width: 650rpx;
  629. height: 80rpx;
  630. font-size: 24rpx;
  631. border-radius: 7rpx;
  632. background-color: #f2f2f2;
  633. .bottom_key {
  634. display: flex;
  635. align-items: center;
  636. img {
  637. margin-right: 10rpx;
  638. width: 34rpx;
  639. height: 34rpx;
  640. }
  641. }
  642. .bottom_value {
  643. }
  644. }
  645. }
  646. }
  647. .foot {
  648. position: absolute;
  649. left: 0;
  650. right: 0;
  651. bottom: 0;
  652. padding: 0 20rpx;
  653. display: flex;
  654. justify-content: space-between;
  655. align-items: center;
  656. height: 126rpx;
  657. background-color: #fff;
  658. .foot_left {
  659. margin-top: -10rpx;
  660. font-size: 40rpx;
  661. color: #ff5733;
  662. text {
  663. font-size: 24rpx;
  664. }
  665. }
  666. .foot_right {
  667. margin-top: -10rpx;
  668. display: flex;
  669. justify-content: center;
  670. align-items: center;
  671. width: 238rpx;
  672. height: 80rpx;
  673. color: #fff;
  674. font-size: 32rpx;
  675. border-radius: 64rpx;
  676. background-color: #096562;
  677. }
  678. }
  679. }
  680. </style>