affirmOrder.vue 17 KB

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