affirmOrder.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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 disabled 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 disabled 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 dayList" :key="index">
  112. {{ item.date }}
  113. <text>{{ item.topinfo }}</text>
  114. </view>
  115. </view>
  116. <view class="box_total">
  117. {{ roomCount }}间 x {{ info.nightNum }}晚
  118. <!-- x ¥{{ info.item.price }} -->
  119. </view>
  120. </view>
  121. </view>
  122. <!-- 优惠区域 -->
  123. <view class="sale" v-if="chooseObj.discountAmount">
  124. <view class="sale_top">
  125. <view class="top_key">优惠</view>
  126. <view class="top_value">- ¥{{ chooseObj.discountAmount }}</view>
  127. </view>
  128. <view class="sale_bottom">
  129. <view class="bottom_key">
  130. <img src="../../static/index/coupon.png" />
  131. {{ chooseObj.typeName }}
  132. </view>
  133. <view class="bottom_value">- ¥{{ chooseObj.discountAmount }}</view>
  134. </view>
  135. </view>
  136. </view>
  137. <!-- 底部提交订单区域 -->
  138. <view class="foot">
  139. <view class="foot_left">
  140. <text>¥</text>
  141. {{ totalPrice }}
  142. </view>
  143. <view class="foot_right" @click="goPagePay">提交订单</view>
  144. </view>
  145. </view>
  146. </template>
  147. <script>
  148. export default {
  149. data() {
  150. return {
  151. info: {},
  152. // 预定房间数量
  153. roomCount: 1,
  154. // 住客姓名
  155. clientName: '',
  156. // 联系电话
  157. clientPhone: '',
  158. // 预计到店时间
  159. arriveTime: '',
  160. // 当前时间
  161. timeValue: Number(new Date()),
  162. // 民宿名称
  163. hotelName: '',
  164. // 状态栏高度
  165. statusBarH: 0,
  166. // 胶囊按钮栏高度
  167. customBarH: 0,
  168. // 优惠券数量
  169. couponNum: 0,
  170. chooseObj: {},
  171. dayList: [],
  172. totalMoney: 0
  173. }
  174. },
  175. created() {
  176. // 获取系统信息
  177. uni.getSystemInfo({
  178. success: (e) => {
  179. // 获取状态栏高度
  180. this.statusBarH = e.statusBarHeight + 10
  181. // // 获取菜单按钮栏高度
  182. let custom = uni.getMenuButtonBoundingClientRect()
  183. this.customBarH = custom.height + 10
  184. }
  185. })
  186. },
  187. onLoad(options) {
  188. this.info = JSON.parse(options.info)
  189. this.hotelName = this.info.hotelName
  190. this.getDayList()
  191. uni.$on('change', this.change)
  192. uni.$on('choose', this.choose)
  193. },
  194. // 计算属性
  195. computed: {
  196. // 总费用
  197. totalPrice() {
  198. // if (this.info.item) {
  199. // return (this.roomCount * this.info.item.price * this.info.nightNum - (this.chooseObj.discountAmount * 1 || 0)).toFixed(2)
  200. // }
  201. if (this.info.item) {
  202. let tem = this.roomCount * this.totalMoney - (this.chooseObj.discountAmount * 1 || 0)
  203. let res = tem > 0 ? tem.toFixed(2) : 0
  204. return res
  205. }
  206. }
  207. },
  208. // 监听属性
  209. watch: {
  210. totalPrice: {
  211. handler(newVal, oldVal) {
  212. this.getCouponNum()
  213. }
  214. }
  215. },
  216. methods: {
  217. async getDayList() {
  218. const res = await this.$myRequest({
  219. url: '/mhotel/house/price/dailyPrice.action',
  220. data: {
  221. roomId: this.info.item.id,
  222. startTime: this.info.queryStartTime,
  223. endTime: this.info.queryEndTime
  224. }
  225. })
  226. // console.log(res)
  227. if (res.code === 200) {
  228. this.dayList = res.data.list
  229. this.totalMoney = res.data.totalPrice
  230. }
  231. },
  232. async getCouponNum() {
  233. const res = await this.$myRequest({
  234. url: '/mhotel/hcusefulCoupon.action',
  235. data: {
  236. hotelId: this.info.hotelId,
  237. page: 1,
  238. rows: 1,
  239. userId: uni.getStorageSync('userInfo').id,
  240. totalPrice: (this.roomCount * this.totalMoney).toFixed(2)
  241. }
  242. })
  243. // console.log(res);
  244. if (res.code === 200) {
  245. this.couponNum = res.page.total
  246. }
  247. },
  248. change(e) {
  249. this.clientName = e.name
  250. this.clientPhone = e.phone
  251. },
  252. choose(e) {
  253. this.chooseObj = e.data
  254. // console.log(this.chooseObj)
  255. },
  256. handleSelectClient() {
  257. uni.navigateTo({
  258. url: '/pages/common/common?type=1'
  259. })
  260. },
  261. confirm(e) {
  262. // console.log(e.value)
  263. let date = new Date(e.value)
  264. let month = date.getMonth() + 1
  265. let day = date.getDate()
  266. let H = date.getHours()
  267. let M = date.getMinutes()
  268. this.arriveTime = `${month}月${day}日${H}:${M}分之前`
  269. },
  270. formatter(type, value) {
  271. if (type === 'year') {
  272. return `${value}年`
  273. }
  274. if (type === 'month') {
  275. return `${value}月`
  276. }
  277. if (type === 'day') {
  278. return `${value}日`
  279. }
  280. return value
  281. },
  282. handleSelectTime() {
  283. this.$refs.datetimePicker.open()
  284. },
  285. handleAdd() {
  286. this.roomCount++
  287. },
  288. handleMinus() {
  289. if (this.roomCount > 1) {
  290. this.roomCount--
  291. } else {
  292. uni.showToast({
  293. title: '至少需要预定1间',
  294. icon: 'none'
  295. })
  296. }
  297. },
  298. // 提交订单按钮回调
  299. async goPagePay() {
  300. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  301. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  302. if (this.totalPrice <= 0) {
  303. uni.showToast({
  304. title: '支付金额不能小于等于0',
  305. icon: 'none',
  306. mask: true
  307. })
  308. return
  309. }
  310. if (!this.clientName) {
  311. uni.showToast({
  312. title: '请选择住客',
  313. icon: 'none',
  314. mask: true
  315. })
  316. return
  317. }
  318. if (!reName.test(this.clientName)) {
  319. uni.showToast({
  320. title: '姓名格式有误',
  321. icon: 'none'
  322. })
  323. return
  324. }
  325. if (!this.clientPhone) {
  326. uni.showToast({
  327. title: '请选择联系电话',
  328. icon: 'none',
  329. mask: true
  330. })
  331. return
  332. }
  333. if (!rePhone.test(this.clientPhone)) {
  334. uni.showToast({
  335. title: '电话号码格式有误',
  336. icon: 'none'
  337. })
  338. return
  339. }
  340. const res = await this.$myRequest({
  341. url: '/mhotel/abkcreateOrder.action',
  342. data: {
  343. houseId: this.info.item.id,
  344. startTime: this.info.queryStartTime,
  345. endTime: this.info.queryEndTime,
  346. houseOrderNumber: this.roomCount,
  347. userName: this.clientName,
  348. userPhone: this.clientPhone,
  349. userId: uni.getStorageSync('userInfo').id,
  350. complaintId: this.chooseObj.complaintId || '',
  351. useId: this.chooseObj.id || ''
  352. }
  353. })
  354. // console.log(res)
  355. if (res.code === 200) {
  356. uni.navigateTo({
  357. url: `/pages/pay/pay?id=${res.data}`
  358. })
  359. }
  360. },
  361. handleBack() {
  362. uni.navigateBack(1)
  363. },
  364. handleGoPage() {
  365. let temTotalPrice = (this.roomCount * this.totalMoney).toFixed(2)
  366. uni.navigateTo({
  367. url: `/pages/coupon/coupon?id=${this.info.hotelId}&totalPrice=${temTotalPrice}&complaintId=${this.chooseObj.complaintId}`
  368. })
  369. }
  370. }
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .container {
  375. position: relative;
  376. display: flex;
  377. flex-direction: column;
  378. height: 100vh;
  379. overflow: hidden;
  380. background-color: #ebeced;
  381. .header {
  382. position: relative;
  383. height: 180rpx;
  384. overflow: hidden;
  385. img {
  386. width: 100%;
  387. }
  388. .header_title {
  389. position: absolute;
  390. top: 0;
  391. left: 182rpx;
  392. width: 50%;
  393. color: #fff;
  394. text-align: center;
  395. font-size: 28rpx;
  396. overflow: hidden;
  397. text-overflow: ellipsis;
  398. white-space: nowrap;
  399. }
  400. .header_icon {
  401. position: absolute;
  402. top: 0;
  403. left: 5rpx;
  404. width: 47rpx;
  405. height: 70rpx;
  406. img {
  407. width: 47rpx;
  408. height: 47rpx;
  409. }
  410. }
  411. }
  412. .body {
  413. height: calc(100vh - 306rpx);
  414. overflow-y: auto;
  415. .info {
  416. display: flex;
  417. flex-direction: column;
  418. box-sizing: border-box;
  419. padding: 0 30rpx;
  420. margin: 0 auto;
  421. margin-top: 18rpx;
  422. width: 710rpx;
  423. border-radius: 15rpx;
  424. background-color: #fff;
  425. .info_time {
  426. display: flex;
  427. align-items: center;
  428. margin-top: 20rpx;
  429. font-size: 32rpx;
  430. font-weight: bold;
  431. .time_line {
  432. width: 17rpx;
  433. height: 1rpx;
  434. background-color: #096562;
  435. }
  436. .time_num {
  437. box-sizing: border-box;
  438. padding: 0 15rpx;
  439. height: 46rpx;
  440. line-height: 46rpx;
  441. font-size: 24rpx;
  442. font-weight: 400;
  443. border-radius: 66rpx;
  444. border: 1rpx solid #096562;
  445. background-color: #f0f2f5;
  446. }
  447. .gap {
  448. margin: 0 10rpx;
  449. }
  450. text {
  451. font-size: 24rpx;
  452. font-weight: 400;
  453. }
  454. }
  455. .info_msg {
  456. margin-top: 15rpx;
  457. font-size: 28rpx;
  458. font-weight: bold;
  459. }
  460. .info_type {
  461. display: flex;
  462. flex-wrap: wrap;
  463. margin-top: 15rpx;
  464. .type_item {
  465. box-sizing: border-box;
  466. padding: 0 15rpx;
  467. margin-right: 20rpx;
  468. height: 41rpx;
  469. line-height: 41rpx;
  470. font-size: 24rpx;
  471. color: #fff;
  472. border-radius: 34rpx;
  473. background-color: #096562;
  474. }
  475. }
  476. .info_tag {
  477. display: flex;
  478. flex-wrap: wrap;
  479. margin: 18rpx 0 30rpx;
  480. color: #808080;
  481. font-size: 24rpx;
  482. .tag_item {
  483. margin-right: 20rpx;
  484. }
  485. }
  486. }
  487. .msg {
  488. box-sizing: border-box;
  489. padding-left: 26rpx;
  490. margin: auto;
  491. margin-top: 20rpx;
  492. width: 710rpx;
  493. border-radius: 15rpx;
  494. background-color: #fff;
  495. .msg_title {
  496. height: 87rpx;
  497. line-height: 87rpx;
  498. font-size: 28rpx;
  499. font-weight: bold;
  500. border-bottom: 1rpx solid #e6e6e6;
  501. }
  502. .msg_box {
  503. display: flex;
  504. align-items: center;
  505. height: 97rpx;
  506. font-size: 28rpx;
  507. border-bottom: 1rpx solid #e6e6e6;
  508. .box_key {
  509. width: 120rpx;
  510. color: #808080;
  511. }
  512. .box_value {
  513. margin-left: 30rpx;
  514. flex: 1;
  515. input {
  516. box-sizing: border-box;
  517. padding-right: 30rpx;
  518. width: 100%;
  519. }
  520. }
  521. .color {
  522. color: #808080;
  523. }
  524. .box_icon {
  525. display: flex;
  526. align-items: center;
  527. height: 100%;
  528. .img {
  529. width: 47rpx;
  530. height: 47rpx;
  531. }
  532. .img2 {
  533. margin: 0 30rpx;
  534. width: 37rpx;
  535. height: 37rpx;
  536. }
  537. .img3 {
  538. margin: 0 30rpx;
  539. width: 40rpx;
  540. height: 40rpx;
  541. }
  542. }
  543. }
  544. }
  545. .coupon {
  546. box-sizing: border-box;
  547. padding-left: 26rpx;
  548. margin: 20rpx auto 0;
  549. width: 710rpx;
  550. height: 197rpx;
  551. border-radius: 15rpx;
  552. background-color: #fff;
  553. .coupon_title {
  554. line-height: 92rpx;
  555. font-size: 28rpx;
  556. font-weight: bold;
  557. border-bottom: 1rpx solid #e6e6e6;
  558. }
  559. .coupon_box {
  560. display: flex;
  561. align-items: center;
  562. justify-content: space-between;
  563. height: 105rpx;
  564. .box_key {
  565. display: flex;
  566. align-items: center;
  567. font-size: 28rpx;
  568. img {
  569. margin-right: 10rpx;
  570. width: 40rpx;
  571. height: 40rpx;
  572. }
  573. }
  574. .box_value {
  575. display: flex;
  576. align-items: center;
  577. .value_count {
  578. display: flex;
  579. justify-content: center;
  580. align-items: center;
  581. width: 105rpx;
  582. height: 45rpx;
  583. color: #fff;
  584. font-size: 24rpx;
  585. border-radius: 7rpx;
  586. background-color: #ff5733;
  587. }
  588. img {
  589. margin-right: 17rpx;
  590. width: 40rpx;
  591. height: 40rpx;
  592. }
  593. }
  594. }
  595. }
  596. .price {
  597. box-sizing: border-box;
  598. padding-left: 26rpx;
  599. margin: 20rpx auto;
  600. width: 710rpx;
  601. height: 197rpx;
  602. border-radius: 15rpx;
  603. background-color: #fff;
  604. .price_title {
  605. line-height: 92rpx;
  606. font-size: 28rpx;
  607. font-weight: bold;
  608. border-bottom: 1rpx solid #e6e6e6;
  609. }
  610. .price_box {
  611. display: flex;
  612. justify-content: space-between;
  613. align-items: center;
  614. height: 92rpx;
  615. font-size: 28rpx;
  616. .box_key {
  617. color: #808080;
  618. }
  619. .box_value {
  620. display: flex;
  621. align-items: center;
  622. text {
  623. color: #ff5733;
  624. font-size: 24rpx;
  625. }
  626. span {
  627. margin-right: 30rpx;
  628. color: #ff5733;
  629. }
  630. }
  631. }
  632. }
  633. .all {
  634. box-sizing: border-box;
  635. padding-left: 26rpx;
  636. margin: 0 auto 20rpx;
  637. width: 710rpx;
  638. border-radius: 15rpx;
  639. background-color: #fff;
  640. .all_title {
  641. display: flex;
  642. height: 92rpx;
  643. justify-content: space-between;
  644. align-items: center;
  645. font-size: 28rpx;
  646. font-weight: bold;
  647. border-bottom: 1rpx solid #e6e6e6;
  648. .mr_30 {
  649. margin-right: 30rpx;
  650. }
  651. }
  652. .all_box {
  653. box-sizing: border-box;
  654. padding-right: 26rpx;
  655. display: flex;
  656. justify-content: space-between;
  657. font-size: 28rpx;
  658. .box_list {
  659. margin-bottom: 28rpx;
  660. color: #808080;
  661. .list_item {
  662. margin-top: 30rpx;
  663. text {
  664. margin-left: 120rpx;
  665. }
  666. }
  667. }
  668. .box_total {
  669. display: flex;
  670. justify-content: center;
  671. align-items: center;
  672. }
  673. }
  674. }
  675. .sale {
  676. margin: 0 auto 20rpx;
  677. box-sizing: border-box;
  678. padding: 0 30rpx;
  679. width: 710rpx;
  680. height: 209rpx;
  681. border-radius: 15rpx;
  682. background-color: #fff;
  683. .sale_top {
  684. display: flex;
  685. align-items: center;
  686. justify-content: space-between;
  687. height: 92rpx;
  688. font-size: 28rpx;
  689. font-weight: bold;
  690. .top_key {
  691. }
  692. .top_value {
  693. color: #ff5733;
  694. }
  695. }
  696. .sale_bottom {
  697. display: flex;
  698. align-items: center;
  699. justify-content: space-between;
  700. box-sizing: border-box;
  701. padding: 0 26rpx;
  702. width: 650rpx;
  703. height: 80rpx;
  704. font-size: 24rpx;
  705. border-radius: 7rpx;
  706. background-color: #f2f2f2;
  707. .bottom_key {
  708. display: flex;
  709. align-items: center;
  710. img {
  711. margin-right: 10rpx;
  712. width: 34rpx;
  713. height: 34rpx;
  714. }
  715. }
  716. .bottom_value {
  717. }
  718. }
  719. }
  720. }
  721. .foot {
  722. position: absolute;
  723. left: 0;
  724. right: 0;
  725. bottom: 0;
  726. padding: 0 20rpx;
  727. display: flex;
  728. justify-content: space-between;
  729. align-items: center;
  730. height: 126rpx;
  731. background-color: #fff;
  732. .foot_left {
  733. margin-top: -10rpx;
  734. font-size: 40rpx;
  735. color: #ff5733;
  736. text {
  737. font-size: 24rpx;
  738. }
  739. }
  740. .foot_right {
  741. margin-top: -10rpx;
  742. display: flex;
  743. justify-content: center;
  744. align-items: center;
  745. width: 238rpx;
  746. height: 80rpx;
  747. color: #fff;
  748. font-size: 32rpx;
  749. border-radius: 64rpx;
  750. background-color: #096562;
  751. }
  752. }
  753. }
  754. </style>