orderManage.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="container">
  3. <!-- 每一个订单区域 -->
  4. <uni-swipe-action>
  5. <uni-swipe-action-item v-for="item in orderList" :key="item.id">
  6. <!-- 右侧选项内容区域 -->
  7. <template v-slot:right>
  8. <view class="order_right" @click="handleDelete(item)">
  9. <img class="img" src="../../static/my/delete.png" />
  10. </view>
  11. </template>
  12. <view class="order_box" @click="goPageOrderDetail(item)">
  13. <!-- 标题区域 -->
  14. <view class="box_header">
  15. <img class="img" src="../../static/my/hotel.png" />
  16. <view class="title">{{ item.hotelName }}</view>
  17. <view class="type type2" v-if="item.orderStatus === '1'">
  18. 待支付,剩余
  19. <uv-count-down v-if="item.countDownTime" :time="item.countDownTime" format="mm:ss" @finish="finish(item)"></uv-count-down>
  20. </view>
  21. <view class="type" v-if="item.orderStatus === '2'">已支付</view>
  22. <view class="type" v-if="item.orderStatus === '3'">待入住</view>
  23. <view class="type" v-if="item.orderStatus === '4'">已入住</view>
  24. <view class="type" v-if="item.orderStatus === '5'">已消费</view>
  25. <view class="type" v-if="item.orderStatus === '6'">支付超时</view>
  26. <view class="type" v-if="item.orderStatus === '7'">已取消</view>
  27. <view class="type" v-if="item.orderStatus === '8'">已退单</view>
  28. <view class="type" v-if="item.orderStatus === '9'">已退款</view>
  29. <view class="type" v-if="item.orderStatus === '10'">退款中</view>
  30. </view>
  31. <!-- 酒店信息区域 -->
  32. <view class="box_info">
  33. <img class="img" mode="aspectFill" :src="item.houseFileInfoList[0].url" />
  34. <view class="info_right">
  35. <view class="info_right_item">{{ item.houseOrderNumber }}间,{{ item.houseName }}</view>
  36. <view class="info_right_item">{{ (item.orderStartTime || '').slice(0, 10) }} - {{ (item.orderEndTime || '').slice(0, 10) }}</view>
  37. <view class="info_right_item">总价:¥{{ item.houseTotalPrice }}</view>
  38. </view>
  39. </view>
  40. <!-- 按钮区域 -->
  41. <view class="box_btn" v-if="item.orderStatus === '1' || item.orderStatus === '6'">
  42. <view class="btn_item pay" v-if="item.orderStatus === '1'" @click.stop="goPagePay(item)">去支付</view>
  43. <view class="btn_item" v-if="item.orderStatus === '6'" @click.stop="goPageDetail(item)">再次预定</view>
  44. </view>
  45. </view>
  46. </uni-swipe-action-item>
  47. </uni-swipe-action>
  48. <view class="noData" v-if="!orderList.length">
  49. <img src="../../static/images/noData.png" />
  50. 暂无数据
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. // 订单列表
  59. orderList: [],
  60. // 倒计时时间(毫秒)
  61. countDownTime: 1000 * 60 * 15,
  62. // 当前页
  63. page: 1,
  64. // 每页多少条数据
  65. rows: 6,
  66. // 一共多少条数据
  67. total: ''
  68. }
  69. },
  70. onShow() {
  71. this.page = 1
  72. this.orderList = []
  73. this.getOrderList()
  74. },
  75. // 下拉刷新
  76. onPullDownRefresh() {
  77. setTimeout(() => {
  78. this.orderList = []
  79. this.page = 1
  80. this.getOrderList()
  81. uni.stopPullDownRefresh()
  82. }, 2000)
  83. },
  84. // 上拉加载
  85. onReachBottom() {
  86. if (this.orderList.length < this.total) {
  87. this.page++
  88. this.getOrderList()
  89. } else {
  90. uni.showToast({
  91. title: '没有更多数据了',
  92. icon: 'none',
  93. mask: true
  94. })
  95. }
  96. },
  97. methods: {
  98. // 获取订单列表数据
  99. async getOrderList() {
  100. const res = await this.$myRequest({
  101. url: '/mhotel/ampgetBookingList.action',
  102. data: {
  103. userId: uni.getStorageSync('userInfo').id,
  104. page: this.page,
  105. rows: this.rows
  106. }
  107. })
  108. // console.log(res)
  109. if (res.code === 200) {
  110. this.total = res.data.total
  111. this.orderList = [...this.orderList, ...res.data.pageList]
  112. // 如果是待支付状态,算出剩余支付时间
  113. this.orderList.forEach((ele) => {
  114. if (ele.orderStatus === '1') {
  115. let temLockTime = ele.lockTime ? ele.lockTime * 1 : 15
  116. // 兼容ios部分系统转换时间格式
  117. let createTime = ele.createTime.slice(0, 19).replace(/-/g, '/')
  118. ele.countDownTime = new Date(createTime).getTime() + temLockTime * 60 * 1000 - new Date().getTime()
  119. }
  120. })
  121. }
  122. },
  123. // 倒计时结束回调
  124. async finish(item) {
  125. const res = await this.$myRequest({
  126. url: '/mhotel/abkupdateOrderStatus.action',
  127. data: {
  128. bookingId: item.id
  129. }
  130. })
  131. // console.log(res)
  132. if (res.code === 200) {
  133. item.orderStatus = '6'
  134. }
  135. // uni.showModal({
  136. // title: '提示',
  137. // content: '订单已超过可支付时间',
  138. // showCancel: false,
  139. // success: async (res) => {
  140. // if (res.confirm) {
  141. // const res = await this.$myRequest({
  142. // url: '/mhotel/abkupdateOrderStatus.action',
  143. // data: {
  144. // bookingId: item.id
  145. // }
  146. // })
  147. // // console.log(res)
  148. // if (res.code === 200) {
  149. // uni.switchTab({
  150. // url: '/pages/my/my'
  151. // })
  152. // }
  153. // }
  154. // }
  155. // })
  156. },
  157. // 点击预定按钮回调
  158. goPagePay(item) {
  159. console.log(item.countDownTime)
  160. if (item.countDownTime <= 0) {
  161. uni.showModal({
  162. title: '提示',
  163. content: '订单已超过可支付时间',
  164. showCancel: false,
  165. success: async (res) => {
  166. if (res.confirm) {
  167. const res = await this.$myRequest({
  168. url: '/mhotel/abkupdateOrderStatus.action',
  169. data: {
  170. bookingId: item.id
  171. }
  172. })
  173. // console.log(res)
  174. if (res.code === 200) {
  175. this.page = 1
  176. this.orderList = []
  177. this.getOrderList()
  178. }
  179. }
  180. }
  181. })
  182. } else {
  183. uni.navigateTo({
  184. url: `/pages/pay/pay?id=${item.id}`
  185. })
  186. }
  187. },
  188. // 点击再次预定按钮回调
  189. goPageDetail(item) {
  190. uni.showModal({
  191. title: '提示',
  192. content: '确定再次预定吗?',
  193. success: async (res) => {
  194. if (res.confirm) {
  195. const result = await this.$myRequest({
  196. url: '/mhotel/abkcreateOrder.action',
  197. data: {
  198. houseId: item.houseId,
  199. startTime: item.orderStartTime.slice(0, 10),
  200. endTime: item.orderEndTime.slice(0, 10),
  201. houseOrderNumber: item.houseOrderNumber,
  202. userName: item.userName,
  203. userPhone: item.userPhone,
  204. userId: uni.getStorageSync('userInfo').id
  205. }
  206. })
  207. if (result.code === 200) {
  208. uni.navigateTo({
  209. url: `/pages/pay/pay?id=${result.data}`
  210. })
  211. // uni.showToast({
  212. // title: '预定成功',
  213. // icon: 'success',
  214. // mask: true
  215. // })
  216. // setTimeout(() => {
  217. // this.page = 1
  218. // this.orderList = []
  219. // this.getOrderList()
  220. // }, 1500)
  221. }
  222. }
  223. }
  224. })
  225. },
  226. // 点击每一个订单回调
  227. goPageOrderDetail(item) {
  228. // console.log(item)
  229. uni.navigateTo({
  230. url: `/pages/orderDetail/orderDetail?id=${item.id}`
  231. })
  232. },
  233. // 右侧选项内容删除按钮回调
  234. handleDelete(item) {
  235. // console.log(item)
  236. if (
  237. item.orderStatus === '1' ||
  238. item.orderStatus === '5' ||
  239. item.orderStatus === '6' ||
  240. item.orderStatus === '7' ||
  241. item.orderStatus === '8' ||
  242. item.orderStatus === '9'
  243. ) {
  244. uni.showModal({
  245. title: '提示',
  246. content: '确定删除吗?删除后不可恢复',
  247. success: async (res) => {
  248. if (res.confirm) {
  249. const res = await this.$myRequest({
  250. url: '/mhotel/abkdelBooking.action',
  251. data: {
  252. bookingId: item.id
  253. }
  254. })
  255. // console.log(res)
  256. if (res.code === 200) {
  257. uni.showToast({
  258. title: '删除成功',
  259. icon: 'success',
  260. mask: true
  261. })
  262. setTimeout(() => {
  263. this.orderList = []
  264. this.page = 1
  265. this.getOrderList()
  266. }, 1500)
  267. }
  268. }
  269. }
  270. })
  271. } else {
  272. uni.showToast({
  273. title: '当前状态订单不可删除',
  274. icon: 'none',
  275. mask: true
  276. })
  277. }
  278. }
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. .container {
  284. box-sizing: border-box;
  285. padding: 0 20rpx 40rpx;
  286. min-height: 100vh;
  287. background-color: #f2f3f5;
  288. overflow-y: auto;
  289. .order_right {
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. margin-top: 20rpx;
  294. width: 126rpx;
  295. background-color: #d43030;
  296. .img {
  297. width: 50rpx;
  298. height: 50rpx;
  299. }
  300. }
  301. .order_box {
  302. margin-top: 20rpx;
  303. box-sizing: border-box;
  304. padding: 0 22rpx;
  305. width: 710rpx;
  306. border-radius: 15rpx;
  307. background-color: #fff;
  308. .box_header {
  309. display: flex;
  310. align-items: center;
  311. height: 94rpx;
  312. .img {
  313. width: 47rpx;
  314. height: 47rpx;
  315. }
  316. .title {
  317. margin-left: 16rpx;
  318. width: 350rpx;
  319. font-size: 32rpx;
  320. font-weight: bold;
  321. overflow: hidden;
  322. white-space: nowrap;
  323. text-overflow: ellipsis;
  324. }
  325. .type {
  326. display: flex;
  327. justify-content: flex-end;
  328. align-items: center;
  329. margin-left: auto;
  330. width: 285rpx;
  331. color: #808080;
  332. font-size: 28rpx;
  333. }
  334. .type2 {
  335. color: #ff5733;
  336. }
  337. }
  338. .box_info {
  339. display: flex;
  340. height: 140rpx;
  341. .img {
  342. width: 100rpx;
  343. height: 100rpx;
  344. border-radius: 9rpx;
  345. }
  346. .info_right {
  347. display: flex;
  348. flex-direction: column;
  349. justify-content: space-around;
  350. margin-top: -5rpx;
  351. margin-left: 18rpx;
  352. height: 120rpx;
  353. color: #808080;
  354. font-size: 28rpx;
  355. .info_right_item {
  356. flex: 1;
  357. }
  358. }
  359. }
  360. .box_btn {
  361. display: flex;
  362. justify-content: flex-end;
  363. margin-top: -10rpx;
  364. height: 100rpx;
  365. .btn_item {
  366. display: flex;
  367. justify-content: center;
  368. align-items: center;
  369. margin-left: 20rpx;
  370. width: 178rpx;
  371. height: 68rpx;
  372. border-radius: 64rpx;
  373. color: #808080;
  374. font-size: 28rpx;
  375. border: 1rpx solid #808080;
  376. }
  377. .pay {
  378. color: #fff;
  379. border: none;
  380. background-color: #096562;
  381. }
  382. }
  383. }
  384. .noData {
  385. display: flex;
  386. flex-direction: column;
  387. justify-content: center;
  388. align-items: center;
  389. img {
  390. margin-top: 150rpx;
  391. width: 600rpx;
  392. height: 600rpx;
  393. }
  394. }
  395. }
  396. // 修改倒计时字体颜色
  397. ::v-deep .uv-count-down .uv-count-down__text {
  398. color: #ff5733;
  399. }
  400. </style>