orderDetail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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.orderStartTime || '').slice(5, 7) }}月{{ (info.checkOutTime || '').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. },
  149. onLoad(options) {
  150. this.id = options.id
  151. this.getData()
  152. },
  153. methods: {
  154. // 获取订单信息
  155. async getData() {
  156. const res = await this.$myRequest({
  157. url: '/mhotel/ampgetBookingById.action',
  158. data: {
  159. bookingId: this.id
  160. }
  161. })
  162. // console.log(res)
  163. if (res.code === 200) {
  164. this.info = res.data
  165. // 计算出倒计时时间(毫秒)
  166. let temLockTime = this.info.lockTime ? this.info.lockTime * 1 : 15
  167. // 兼容ios部分系统转换时间格式
  168. let createTime = this.info.createTime.slice(0, 19).replace(/-/g, '/')
  169. this.info.countDownTime = new Date(createTime).getTime() + temLockTime * 60 * 1000 - new Date().getTime()
  170. }
  171. },
  172. // 点击复制文字回调
  173. handleCopy(text) {
  174. uni.setClipboardData({
  175. data: text,
  176. success: () => {}
  177. })
  178. },
  179. handleBack() {
  180. uni.navigateBack(1)
  181. },
  182. // 点击地图/导航文字回调
  183. handleMap() {
  184. uni.getSetting({
  185. success: (res) => {
  186. if (res.authSetting['scope.userLocation']) {
  187. let lat = this.info.hotelHpositionWens.split(',')[0] * 1
  188. let lng = this.info.hotelHpositionWens.split(',')[1] * 1
  189. uni.openLocation({
  190. latitude: lat,
  191. longitude: lng,
  192. name: this.info.hotelName,
  193. address: this.info.hotelHposition,
  194. success: () => {}
  195. })
  196. } else {
  197. uni.showModal({
  198. content: '当前没有定位权限,是否去设置打开?',
  199. confirmText: '确认',
  200. cancelText: '取消',
  201. success: (res) => {
  202. if (res.confirm) {
  203. uni.openSetting({
  204. success: (res) => {
  205. this.handleMap()
  206. }
  207. })
  208. } else {
  209. uni.showToast({
  210. title: '获取定位权限失败',
  211. icon: 'none',
  212. mask: true
  213. })
  214. }
  215. }
  216. })
  217. }
  218. }
  219. })
  220. },
  221. // 点击联系商家文字回调
  222. handlePhone(phone) {
  223. uni.makePhoneCall({
  224. phoneNumber: phone
  225. })
  226. },
  227. // 点击去支付按钮回调
  228. handlePay() {
  229. uni.navigateTo({
  230. url: `/pages/pay/pay?id=${this.id}`
  231. })
  232. },
  233. // 点击取消订单按钮回调
  234. handleCancel() {
  235. uni.showModal({
  236. title: '提示',
  237. content: '确定取消该订单吗?',
  238. success: async (res) => {
  239. if (res.confirm) {
  240. const result = await this.$myRequest({
  241. url: '/mhotel/abkcancelBooking.action',
  242. data: {
  243. bookingId: this.info.id,
  244. open_id: uni.getStorageSync('openid')
  245. }
  246. })
  247. if (result.code === 200) {
  248. uni.showToast({
  249. title: '取消成功,' + result.message,
  250. icon: 'none',
  251. mask: true
  252. })
  253. setTimeout(() => {
  254. uni.navigateBack(1)
  255. }, 1500)
  256. }
  257. }
  258. }
  259. })
  260. },
  261. // 点击再次预定按钮回调
  262. handleAgain() {
  263. uni.showModal({
  264. title: '提示',
  265. content: '确定再次预定吗?',
  266. success: async (res) => {
  267. if (res.confirm) {
  268. const result = await this.$myRequest({
  269. url: '/mhotel/abkcreateOrder.action',
  270. data: {
  271. houseId: this.info.houseId,
  272. startTime: this.info.orderStartTime.slice(0, 10),
  273. endTime: this.info.orderEndTime.slice(0, 10),
  274. houseOrderNumber: this.info.houseOrderNumber,
  275. userName: this.info.userName,
  276. userPhone: this.info.userPhone,
  277. userId: uni.getStorageSync('userInfo').id
  278. }
  279. })
  280. if (result.code === 200) {
  281. uni.navigateTo({
  282. url: `/pages/pay/pay?id=${result.data}`
  283. })
  284. // uni.showToast({
  285. // title: '预定成功',
  286. // icon: 'success',
  287. // mask: true
  288. // })
  289. // setTimeout(() => {
  290. // uni.navigateBack(1)
  291. // }, 1500)
  292. }
  293. }
  294. }
  295. })
  296. },
  297. // 点击删除订单按钮回调
  298. handleDelete() {
  299. uni.showModal({
  300. title: '提示',
  301. content: '确定删除该订单吗?',
  302. success: async (res) => {
  303. if (res.confirm) {
  304. const result = await this.$myRequest({
  305. url: '/mhotel/abkdelBooking.action',
  306. data: {
  307. bookingId: this.info.id,
  308. open_id: uni.getStorageSync('openid')
  309. }
  310. })
  311. if (result.code === 200) {
  312. uni.showToast({
  313. title: '删除成功',
  314. icon: 'success',
  315. mask: true
  316. })
  317. setTimeout(() => {
  318. uni.navigateBack(1)
  319. }, 1500)
  320. }
  321. }
  322. }
  323. })
  324. },
  325. // 倒计时结束回调
  326. async finish(item) {
  327. const res = await this.$myRequest({
  328. url: '/mhotel/abkupdateOrderStatus.action',
  329. data: {
  330. bookingId: item.id
  331. }
  332. })
  333. // console.log(res)
  334. if (res.code === 200) {
  335. item.orderStatus = '6'
  336. }
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss" scoped>
  342. .container {
  343. position: relative;
  344. height: 100vh;
  345. background-color: #f2f2f2;
  346. .header {
  347. height: 480rpx;
  348. color: #fff;
  349. img {
  350. width: 100%;
  351. }
  352. .header_title {
  353. position: absolute;
  354. top: 65rpx;
  355. left: 308rpx;
  356. color: #fff;
  357. font-size: 28rpx;
  358. }
  359. .header_icon {
  360. position: absolute;
  361. top: 76rpx;
  362. left: 10rpx;
  363. width: 47rpx;
  364. height: 70rpx;
  365. img {
  366. width: 47rpx;
  367. height: 47rpx;
  368. }
  369. }
  370. .header_type {
  371. position: absolute;
  372. top: 162rpx;
  373. left: 30rpx;
  374. font-size: 40rpx;
  375. font-weight: bold;
  376. }
  377. .header_time {
  378. position: absolute;
  379. top: 162rpx;
  380. left: 530rpx;
  381. display: flex;
  382. align-items: center;
  383. font-size: 30rpx;
  384. font-weight: bold;
  385. }
  386. .header_info {
  387. position: absolute;
  388. top: 235rpx;
  389. left: 30rpx;
  390. font-size: 24rpx;
  391. }
  392. .header_btn {
  393. position: absolute;
  394. top: 290rpx;
  395. left: 30rpx;
  396. right: 30rpx;
  397. display: flex;
  398. justify-content: space-between;
  399. .btn_box {
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. width: 335rpx;
  404. height: 72rpx;
  405. border-radius: 10rpx;
  406. color: #096562;
  407. font-size: 28rpx;
  408. background-color: #fff;
  409. }
  410. }
  411. .header_msg {
  412. position: absolute;
  413. top: 378rpx;
  414. left: 30rpx;
  415. font-size: 24rpx;
  416. }
  417. }
  418. .body {
  419. position: absolute;
  420. top: 430rpx;
  421. left: 0;
  422. right: 0;
  423. box-sizing: border-box;
  424. padding: 20rpx;
  425. height: calc(100vh - 430rpx);
  426. border-radius: 20rpx 20rpx 0 0;
  427. background-color: #ebeced;
  428. overflow-y: auto;
  429. .body_box {
  430. box-sizing: border-box;
  431. padding: 0 30rpx;
  432. margin-bottom: 20rpx;
  433. display: flex;
  434. flex-direction: column;
  435. height: 240rpx;
  436. border-radius: 14rpx;
  437. background-color: #fff;
  438. .box_title {
  439. line-height: 90rpx;
  440. font-size: 28rpx;
  441. font-weight: bold;
  442. border-bottom: 1rpx solid #e5e5e5;
  443. }
  444. .box_container {
  445. display: flex;
  446. margin-top: 25rpx;
  447. font-size: 28rpx;
  448. .container_key {
  449. width: 160rpx;
  450. color: #808080;
  451. }
  452. .container_value {
  453. }
  454. .container_copy {
  455. margin-left: auto;
  456. color: #096562;
  457. }
  458. .price {
  459. color: #ff5733;
  460. }
  461. }
  462. .box_info {
  463. display: flex;
  464. margin-top: 20rpx;
  465. height: 130rpx;
  466. img {
  467. width: 100rpx;
  468. height: 100rpx;
  469. border-radius: 10rpx;
  470. }
  471. .info_msg {
  472. display: flex;
  473. flex-direction: column;
  474. justify-content: space-around;
  475. margin-top: -10rpx;
  476. margin-left: 18rpx;
  477. width: 540rpx;
  478. .msg_name {
  479. font-size: 28rpx;
  480. font-weight: bold;
  481. }
  482. .msg_address {
  483. color: #808080;
  484. font-size: 24rpx;
  485. display: -webkit-box;
  486. -webkit-box-orient: vertical;
  487. -webkit-line-clamp: 2;
  488. overflow: hidden;
  489. }
  490. }
  491. }
  492. .box_btn {
  493. display: flex;
  494. justify-content: space-around;
  495. align-items: center;
  496. height: 110rpx;
  497. .btn_item {
  498. display: flex;
  499. align-items: center;
  500. width: 200rpx;
  501. .img {
  502. margin-right: 14rpx;
  503. width: 38rpx;
  504. height: 38rpx;
  505. }
  506. .img2 {
  507. width: 66rpx;
  508. height: 66rpx;
  509. }
  510. }
  511. }
  512. }
  513. .body_box2 {
  514. display: flex;
  515. flex-direction: column;
  516. box-sizing: border-box;
  517. padding: 0 30rpx;
  518. margin-bottom: 20rpx;
  519. height: 478rpx;
  520. border-radius: 15rpx;
  521. background-color: #fff;
  522. .info_time {
  523. display: flex;
  524. align-items: center;
  525. margin-top: 20rpx;
  526. font-size: 32rpx;
  527. font-weight: bold;
  528. .time_line {
  529. width: 17rpx;
  530. height: 1rpx;
  531. background-color: #096562;
  532. }
  533. .time_num {
  534. box-sizing: border-box;
  535. padding: 0 15rpx;
  536. height: 46rpx;
  537. line-height: 46rpx;
  538. font-size: 24rpx;
  539. font-weight: 400;
  540. border-radius: 66rpx;
  541. border: 1rpx solid #096562;
  542. background-color: #f0f2f5;
  543. }
  544. .gap {
  545. margin: 0 10rpx;
  546. }
  547. text {
  548. font-size: 24rpx;
  549. font-weight: 400;
  550. }
  551. }
  552. .info_msg {
  553. margin-top: 15rpx;
  554. font-size: 28rpx;
  555. font-weight: bold;
  556. }
  557. .info_type {
  558. display: flex;
  559. flex-wrap: wrap;
  560. margin-top: 15rpx;
  561. .type_item {
  562. box-sizing: border-box;
  563. padding: 0 15rpx;
  564. margin-right: 20rpx;
  565. height: 41rpx;
  566. line-height: 41rpx;
  567. font-size: 24rpx;
  568. color: #fff;
  569. border-radius: 34rpx;
  570. background-color: #096562;
  571. }
  572. }
  573. .info_tag {
  574. display: flex;
  575. flex-wrap: wrap;
  576. margin: 18rpx 0 0;
  577. box-sizing: border-box;
  578. padding-bottom: 30rpx;
  579. color: #808080;
  580. font-size: 24rpx;
  581. border-bottom: 1rpx solid #e5e5e5;
  582. .tag_item {
  583. margin-right: 20rpx;
  584. }
  585. }
  586. .info_box {
  587. display: flex;
  588. margin-top: 23rpx;
  589. font-size: 28rpx;
  590. .box_key {
  591. width: 160rpx;
  592. color: #808080;
  593. }
  594. .box_value {
  595. }
  596. }
  597. }
  598. }
  599. }
  600. // 修改倒计时字体颜色
  601. ::v-deep .uv-count-down .uv-count-down__text {
  602. color: #fff;
  603. }
  604. </style>