orderDetail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view class="container" v-if="info">
  3. <!-- 顶部订单状态信息区域 -->
  4. <view class="header">
  5. <!-- 背景图片区域 -->
  6. <img src="../../static/my/headerImg.png" />
  7. <!-- 标题区域 -->
  8. <view class="header_title">订单详情</view>
  9. <!-- 返回图标区域 -->
  10. <view class="header_icon" @click="handleBack">
  11. <img src="../../static/index/left.png" />
  12. </view>
  13. <view class="header_type" v-if="info.orderStatus === '1'">待支付</view>
  14. <view class="header_time" v-if="info.orderStatus === '1'">
  15. 剩余
  16. <uv-count-down v-if="info.countDownTime" :time="info.countDownTime" format="mm:ss" @finish="finish(info)"></uv-count-down>
  17. </view>
  18. <view class="header_info" v-if="info.orderStatus === '1'">超时后,订单将会自动取消</view>
  19. <view class="header_type" v-if="info.orderStatus === '2'">已支付</view>
  20. <view class="header_info" v-if="info.orderStatus === '2'">订单已支付,请等待商家接单</view>
  21. <view class="header_type" v-if="info.orderStatus === '3'">待入住</view>
  22. <view class="header_info" v-if="info.orderStatus === '3'">订单已被商家接单,请前往办理入住</view>
  23. <view class="header_type" v-if="info.orderStatus === '4'">已入住</view>
  24. <view class="header_info" v-if="info.orderStatus === '4'">订单已办理入住</view>
  25. <view class="header_type" v-if="info.orderStatus === '5'">已消费</view>
  26. <view class="header_info" v-if="info.orderStatus === '5'">您的订单已消费,期待您再次预定哦</view>
  27. <view class="header_type" v-if="info.orderStatus === '6'">支付超时</view>
  28. <view class="header_info" v-if="info.orderStatus === '6'">订单已超过可支付时间,请重新下单</view>
  29. <view class="header_type" v-if="info.orderStatus === '7'">已取消</view>
  30. <view class="header_info" v-if="info.orderStatus === '7'">订单已取消,请重新下单</view>
  31. <view class="header_type" v-if="info.orderStatus === '8'">已退单</view>
  32. <view class="header_info" v-if="info.orderStatus === '8'">订单已被商家退单,请重新下单</view>
  33. <view class="header_type" v-if="info.orderStatus === '9'">已退款</view>
  34. <view class="header_info" v-if="info.orderStatus === '9'">订单已被商家退款</view>
  35. <view class="header_type" v-if="info.orderStatus === '10'">退款中</view>
  36. <view class="header_info" v-if="info.orderStatus === '10'">正在退款中...</view>
  37. <view class="header_btn">
  38. <view class="btn_box" v-if="info.orderStatus === '1'" @click="handlePay">去支付 ¥{{ info.houseTotalPrice }}</view>
  39. <!-- hotelIsCanorder 1可取消,0不可 -->
  40. <view class="btn_box" v-if="(info.orderStatus === '2' || info.orderStatus === '3') && info.hotelIsCanorder === '1'" @click="handleCancel">取消订单</view>
  41. <view class="btn_box" v-if="info.orderStatus * 1 > 3" @click="handleAgain">再次预定</view>
  42. <view
  43. class="btn_box"
  44. @click="handleDelete"
  45. v-if="
  46. info.orderStatus === '1' ||
  47. info.orderStatus === '5' ||
  48. info.orderStatus === '6' ||
  49. info.orderStatus === '7' ||
  50. info.orderStatus === '8' ||
  51. info.orderStatus === '9'
  52. "
  53. >
  54. 删除订单
  55. </view>
  56. </view>
  57. <!-- <view class="header_msg" v-if="info.orderStatus === '1'">预定成功后,07月26日12:00前可免费取消</view> -->
  58. </view>
  59. <!-- 主体内容区域 -->
  60. <view class="body">
  61. <!-- 费用信息区域 -->
  62. <view class="body_box">
  63. <view class="box_title">费用信息</view>
  64. <view class="box_container">
  65. <view class="container_key">在线支付</view>
  66. <view class="container_value price">¥{{ info.houseTotalPrice }}</view>
  67. </view>
  68. <view class="box_container">
  69. <view class="container_key">发票报销</view>
  70. <view class="container_value">如需发票,请先与酒店确认</view>
  71. </view>
  72. </view>
  73. <!-- 民宿信息区域 -->
  74. <view class="body_box">
  75. <view class="box_info">
  76. <img mode="aspectFill" :src="info.houseFileInfoList[0].url" />
  77. <view class="info_msg">
  78. <view class="msg_name">{{ info.hotelName }}</view>
  79. <view class="msg_address">{{ info.hotelHposition }}</view>
  80. </view>
  81. </view>
  82. <view class="box_btn">
  83. <view class="btn_item" @click="handleMap">
  84. <img class="img" src="../../static/my/map.png" />
  85. 地图/导航
  86. </view>
  87. <view class="btn_item" @click="handlePhone(info.hotelPhone)">
  88. <img class="img2" src="../../static/my/phone.png" />
  89. 联系商家
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 房型信息和用户信息区域 -->
  94. <view class="body_box2">
  95. <view class="info_time">
  96. {{ (info.orderStartTime || '').slice(5, 7) }}月{{ (info.orderStartTime || '').slice(8, 10) }}日
  97. <view class="time_line"></view>
  98. <view class="time_num">{{ info.orderLiveTime }}</view>
  99. <view class="time_line"></view>
  100. <view class="gap">{{ (info.orderEndTime || '').slice(5, 7) }}月{{ (info.orderEndTime || '').slice(8, 10) }}日</view>
  101. </view>
  102. <view class="info_msg">{{ info.houseName }}</view>
  103. <view class="info_type">
  104. <view class="type_item">普通型</view>
  105. </view>
  106. <view class="info_tag">
  107. <view class="tag_item" v-if="info.houseAreas">{{ info.houseAreas }}㎡</view>
  108. <view class="tag_item" v-for="tag in info.houseConfigList" :key="tag.id">{{ tag.name }}</view>
  109. </view>
  110. <view class="info_box">
  111. <view class="box_key">住客姓名</view>
  112. <view class="box_value">{{ info.userName }}</view>
  113. </view>
  114. <view class="info_box">
  115. <view class="box_key">联系电话</view>
  116. <view class="box_value">{{ info.userPhone }}</view>
  117. </view>
  118. <view class="info_box">
  119. <view class="box_key">预计到店</view>
  120. <view class="box_value">7月26日14:00之前</view>
  121. </view>
  122. </view>
  123. <!-- 订单信息区域 -->
  124. <view class="body_box">
  125. <view class="box_title">订单信息</view>
  126. <view class="box_container">
  127. <view class="container_key">订单号</view>
  128. <view class="container_value">{{ info.orderNum }}</view>
  129. <view class="container_copy" @click="handleCopy(info.orderNum)">复制</view>
  130. </view>
  131. <view class="box_container">
  132. <view class="container_key">下单时间</view>
  133. <view class="container_value">{{ (info.createTime || '').slice(0, 19) }}</view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <script>
  140. export default {
  141. data() {
  142. return {
  143. // 详细信息
  144. info: null,
  145. // 订单ID
  146. id: '',
  147. // 距离差
  148. distance: ''
  149. }
  150. },
  151. onLoad(options) {
  152. this.id = options.id
  153. this.distance = options.distance
  154. this.getData()
  155. },
  156. methods: {
  157. // 获取订单信息
  158. async getData() {
  159. const res = await this.$myRequest({
  160. url: '/mhotel/ampgetBookingById.action',
  161. data: {
  162. bookingId: this.id
  163. }
  164. })
  165. // console.log(res)
  166. if (res.code === 200) {
  167. this.info = res.data
  168. // 计算出倒计时时间(毫秒)
  169. let temLockTime = this.info.lockTime ? this.info.lockTime * 1 : 15
  170. // 兼容ios部分系统转换时间格式
  171. let createTime = this.info.createTime.slice(0, 19).replace(/-/g, '/')
  172. this.info.countDownTime = new Date(createTime).getTime() + temLockTime * 60 * 1000 - new Date().getTime()
  173. }
  174. },
  175. // 点击复制文字回调
  176. handleCopy(text) {
  177. uni.setClipboardData({
  178. data: text,
  179. success: () => {}
  180. })
  181. },
  182. handleBack() {
  183. uni.navigateBack(1)
  184. },
  185. // 点击地图/导航文字回调
  186. handleMap() {
  187. uni.getSetting({
  188. success: (res) => {
  189. if (res.authSetting['scope.userLocation']) {
  190. let lat = this.info.hotelHpositionWens.split(',')[0] * 1
  191. let lng = this.info.hotelHpositionWens.split(',')[1] * 1
  192. uni.openLocation({
  193. latitude: lat,
  194. longitude: lng,
  195. name: this.info.hotelName,
  196. address: this.info.hotelHposition,
  197. success: () => {}
  198. })
  199. } else {
  200. uni.showModal({
  201. content: '当前没有定位权限,是否去设置打开?',
  202. confirmText: '确认',
  203. cancelText: '取消',
  204. success: (res) => {
  205. if (res.confirm) {
  206. uni.openSetting({
  207. success: (res) => {
  208. this.handleMap()
  209. }
  210. })
  211. } else {
  212. uni.showToast({
  213. title: '获取定位权限失败',
  214. icon: 'none',
  215. mask: true
  216. })
  217. }
  218. }
  219. })
  220. }
  221. }
  222. })
  223. },
  224. // 点击联系商家文字回调
  225. handlePhone(phone) {
  226. uni.makePhoneCall({
  227. phoneNumber: phone
  228. })
  229. },
  230. // 点击去支付按钮回调
  231. handlePay() {
  232. uni.navigateTo({
  233. url: `/pages/pay/pay?id=${this.id}`
  234. })
  235. },
  236. // 点击取消订单按钮回调
  237. handleCancel() {
  238. uni.showModal({
  239. title: '提示',
  240. content: '确定取消该订单吗?',
  241. success: async (res) => {
  242. if (res.confirm) {
  243. const result = await this.$myRequest({
  244. url: '/mhotel/abkcancelBooking.action',
  245. data: {
  246. bookingId: this.info.id,
  247. open_id: uni.getStorageSync('openid')
  248. }
  249. })
  250. if (result.code === 200) {
  251. uni.showToast({
  252. title: '取消成功,' + result.message,
  253. icon: 'none',
  254. mask: true
  255. })
  256. setTimeout(() => {
  257. uni.navigateBack(1)
  258. }, 1500)
  259. }
  260. }
  261. }
  262. })
  263. },
  264. // 点击再次预定按钮回调
  265. handleAgain() {
  266. uni.navigateTo({
  267. url: `/pages/detail/detail?id=${this.info.hotelId}&distance=${this.distance}`
  268. })
  269. // if (this.info.hstatus === 1 && this.info.hotelStatus === 1) {
  270. // uni.showModal({
  271. // title: '提示',
  272. // content: '确定再次预定吗?',
  273. // success: async (res) => {
  274. // if (res.confirm) {
  275. // const result = await this.$myRequest({
  276. // url: '/mhotel/abkcreateOrder.action',
  277. // data: {
  278. // houseId: this.info.houseId,
  279. // startTime: this.info.orderStartTime.slice(0, 10),
  280. // endTime: this.info.orderEndTime.slice(0, 10),
  281. // houseOrderNumber: this.info.houseOrderNumber,
  282. // userName: this.info.userName,
  283. // userPhone: this.info.userPhone,
  284. // userId: uni.getStorageSync('userInfo').id
  285. // }
  286. // })
  287. // if (result.code === 200) {
  288. // uni.navigateTo({
  289. // url: `/pages/pay/pay?id=${result.data}`
  290. // })
  291. // }
  292. // }
  293. // }
  294. // })
  295. // } else {
  296. // uni.showToast({
  297. // title: '该民宿暂时无法预定',
  298. // icon: 'none',
  299. // mask: true
  300. // })
  301. // }
  302. },
  303. // 点击删除订单按钮回调
  304. handleDelete() {
  305. uni.showModal({
  306. title: '提示',
  307. content: '确定删除该订单吗?',
  308. success: async (res) => {
  309. if (res.confirm) {
  310. const result = await this.$myRequest({
  311. url: '/mhotel/abkdelBooking.action',
  312. data: {
  313. bookingId: this.info.id,
  314. open_id: uni.getStorageSync('openid')
  315. }
  316. })
  317. if (result.code === 200) {
  318. uni.showToast({
  319. title: '删除成功',
  320. icon: 'success',
  321. mask: true
  322. })
  323. setTimeout(() => {
  324. uni.navigateBack(1)
  325. }, 1500)
  326. }
  327. }
  328. }
  329. })
  330. },
  331. // 倒计时结束回调
  332. async finish(item) {
  333. const res = await this.$myRequest({
  334. url: '/mhotel/abkupdateOrderStatus.action',
  335. data: {
  336. bookingId: item.id
  337. }
  338. })
  339. // console.log(res)
  340. if (res.code === 200) {
  341. item.orderStatus = '6'
  342. }
  343. }
  344. }
  345. }
  346. </script>
  347. <style lang="scss" scoped>
  348. .container {
  349. position: relative;
  350. height: 100vh;
  351. background-color: #f2f2f2;
  352. .header {
  353. height: 480rpx;
  354. color: #fff;
  355. img {
  356. width: 100%;
  357. }
  358. .header_title {
  359. position: absolute;
  360. top: 76rpx;
  361. left: 308rpx;
  362. color: #fff;
  363. font-size: 28rpx;
  364. }
  365. .header_icon {
  366. position: absolute;
  367. top: 76rpx;
  368. left: 10rpx;
  369. width: 47rpx;
  370. height: 70rpx;
  371. img {
  372. width: 47rpx;
  373. height: 47rpx;
  374. }
  375. }
  376. .header_type {
  377. position: absolute;
  378. top: 162rpx;
  379. left: 30rpx;
  380. font-size: 40rpx;
  381. font-weight: bold;
  382. }
  383. .header_time {
  384. position: absolute;
  385. top: 162rpx;
  386. left: 530rpx;
  387. display: flex;
  388. align-items: center;
  389. font-size: 30rpx;
  390. font-weight: bold;
  391. }
  392. .header_info {
  393. position: absolute;
  394. top: 235rpx;
  395. left: 30rpx;
  396. font-size: 24rpx;
  397. }
  398. .header_btn {
  399. position: absolute;
  400. top: 290rpx;
  401. left: 30rpx;
  402. right: 30rpx;
  403. display: flex;
  404. justify-content: space-between;
  405. .btn_box {
  406. display: flex;
  407. justify-content: center;
  408. align-items: center;
  409. width: 335rpx;
  410. height: 72rpx;
  411. border-radius: 10rpx;
  412. color: #096562;
  413. font-size: 28rpx;
  414. background-color: #fff;
  415. }
  416. }
  417. .header_msg {
  418. position: absolute;
  419. top: 378rpx;
  420. left: 30rpx;
  421. font-size: 24rpx;
  422. }
  423. }
  424. .body {
  425. position: absolute;
  426. top: 430rpx;
  427. left: 0;
  428. right: 0;
  429. box-sizing: border-box;
  430. padding: 20rpx;
  431. height: calc(100vh - 430rpx);
  432. border-radius: 20rpx 20rpx 0 0;
  433. background-color: #ebeced;
  434. overflow-y: auto;
  435. .body_box {
  436. box-sizing: border-box;
  437. padding: 0 30rpx;
  438. margin-bottom: 20rpx;
  439. display: flex;
  440. flex-direction: column;
  441. height: 240rpx;
  442. border-radius: 14rpx;
  443. background-color: #fff;
  444. .box_title {
  445. line-height: 90rpx;
  446. font-size: 28rpx;
  447. font-weight: bold;
  448. border-bottom: 1rpx solid #e5e5e5;
  449. }
  450. .box_container {
  451. display: flex;
  452. margin-top: 25rpx;
  453. font-size: 28rpx;
  454. .container_key {
  455. width: 160rpx;
  456. color: #808080;
  457. }
  458. .container_value {
  459. }
  460. .container_copy {
  461. margin-left: auto;
  462. color: #096562;
  463. }
  464. .price {
  465. color: #ff5733;
  466. }
  467. }
  468. .box_info {
  469. display: flex;
  470. margin-top: 20rpx;
  471. height: 130rpx;
  472. img {
  473. width: 100rpx;
  474. height: 100rpx;
  475. border-radius: 10rpx;
  476. }
  477. .info_msg {
  478. display: flex;
  479. flex-direction: column;
  480. justify-content: space-around;
  481. margin-top: -10rpx;
  482. margin-left: 18rpx;
  483. width: 540rpx;
  484. .msg_name {
  485. font-size: 28rpx;
  486. font-weight: bold;
  487. }
  488. .msg_address {
  489. color: #808080;
  490. font-size: 24rpx;
  491. display: -webkit-box;
  492. -webkit-box-orient: vertical;
  493. -webkit-line-clamp: 2;
  494. overflow: hidden;
  495. }
  496. }
  497. }
  498. .box_btn {
  499. display: flex;
  500. justify-content: space-around;
  501. align-items: center;
  502. height: 110rpx;
  503. .btn_item {
  504. display: flex;
  505. align-items: center;
  506. width: 200rpx;
  507. .img {
  508. margin-right: 14rpx;
  509. width: 38rpx;
  510. height: 38rpx;
  511. }
  512. .img2 {
  513. width: 66rpx;
  514. height: 66rpx;
  515. }
  516. }
  517. }
  518. }
  519. .body_box2 {
  520. display: flex;
  521. flex-direction: column;
  522. box-sizing: border-box;
  523. padding: 0 30rpx;
  524. margin-bottom: 20rpx;
  525. height: 478rpx;
  526. border-radius: 15rpx;
  527. background-color: #fff;
  528. .info_time {
  529. display: flex;
  530. align-items: center;
  531. margin-top: 20rpx;
  532. font-size: 32rpx;
  533. font-weight: bold;
  534. .time_line {
  535. width: 17rpx;
  536. height: 1rpx;
  537. background-color: #096562;
  538. }
  539. .time_num {
  540. box-sizing: border-box;
  541. padding: 0 15rpx;
  542. height: 46rpx;
  543. line-height: 46rpx;
  544. font-size: 24rpx;
  545. font-weight: 400;
  546. border-radius: 66rpx;
  547. border: 1rpx solid #096562;
  548. background-color: #f0f2f5;
  549. }
  550. .gap {
  551. margin: 0 10rpx;
  552. }
  553. text {
  554. font-size: 24rpx;
  555. font-weight: 400;
  556. }
  557. }
  558. .info_msg {
  559. margin-top: 15rpx;
  560. font-size: 28rpx;
  561. font-weight: bold;
  562. }
  563. .info_type {
  564. display: flex;
  565. flex-wrap: wrap;
  566. margin-top: 15rpx;
  567. .type_item {
  568. box-sizing: border-box;
  569. padding: 0 15rpx;
  570. margin-right: 20rpx;
  571. height: 41rpx;
  572. line-height: 41rpx;
  573. font-size: 24rpx;
  574. color: #fff;
  575. border-radius: 34rpx;
  576. background-color: #096562;
  577. }
  578. }
  579. .info_tag {
  580. display: flex;
  581. flex-wrap: wrap;
  582. margin: 18rpx 0 0;
  583. box-sizing: border-box;
  584. padding-bottom: 30rpx;
  585. color: #808080;
  586. font-size: 24rpx;
  587. border-bottom: 1rpx solid #e5e5e5;
  588. .tag_item {
  589. margin-right: 20rpx;
  590. }
  591. }
  592. .info_box {
  593. display: flex;
  594. margin-top: 23rpx;
  595. font-size: 28rpx;
  596. .box_key {
  597. width: 160rpx;
  598. color: #808080;
  599. }
  600. .box_value {
  601. }
  602. }
  603. }
  604. }
  605. }
  606. // 修改倒计时字体颜色
  607. ::v-deep .uv-count-down .uv-count-down__text {
  608. color: #fff;
  609. }
  610. </style>