orderDetail.vue 16 KB

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