orderManage.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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 :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" :src="item.imgUrl || '../../static/index/banner.png'" />
  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" 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. ele.countDownTime = new Date(ele.createTime.slice(0, 19)).getTime() + temLockTime * 60 * 1000 - new Date().getTime()
  117. }
  118. })
  119. }
  120. },
  121. // 倒计时结束回调
  122. async finish(item) {
  123. const res = await this.$myRequest({
  124. url: '/mhotel/abkupdateOrderStatus.action',
  125. data: {
  126. bookingId: item.id
  127. }
  128. })
  129. // console.log(res)
  130. if (res.code === 200) {
  131. item.orderStatus = '6'
  132. }
  133. // uni.showModal({
  134. // title: '提示',
  135. // content: '订单已超过可支付时间',
  136. // showCancel: false,
  137. // success: async (res) => {
  138. // if (res.confirm) {
  139. // const res = await this.$myRequest({
  140. // url: '/mhotel/abkupdateOrderStatus.action',
  141. // data: {
  142. // bookingId: item.id
  143. // }
  144. // })
  145. // // console.log(res)
  146. // if (res.code === 200) {
  147. // uni.switchTab({
  148. // url: '/pages/my/my'
  149. // })
  150. // }
  151. // }
  152. // }
  153. // })
  154. },
  155. // 点击预定按钮回调
  156. goPagePay(item) {
  157. console.log(item.countDownTime)
  158. if (item.countDownTime <= 0) {
  159. uni.showModal({
  160. title: '提示',
  161. content: '订单已超过可支付时间',
  162. showCancel: false,
  163. success: async (res) => {
  164. if (res.confirm) {
  165. const res = await this.$myRequest({
  166. url: '/mhotel/abkupdateOrderStatus.action',
  167. data: {
  168. bookingId: item.id
  169. }
  170. })
  171. // console.log(res)
  172. if (res.code === 200) {
  173. this.page = 1
  174. this.orderList = []
  175. this.getOrderList()
  176. }
  177. }
  178. }
  179. })
  180. } else {
  181. uni.navigateTo({
  182. url: `/pages/pay/pay?id=${item.id}`
  183. })
  184. }
  185. },
  186. // 点击再次预定按钮回调
  187. goPageDetail(item) {
  188. uni.showModal({
  189. title: '提示',
  190. content: '确定再次预定吗?',
  191. success: async (res) => {
  192. if (res.confirm) {
  193. const result = await this.$myRequest({
  194. url: '/mhotel/abkcreateOrder.action',
  195. data: {
  196. houseId: item.houseId,
  197. startTime: item.orderStartTime.slice(0, 10),
  198. endTime: item.orderEndTime.slice(0, 10),
  199. houseOrderNumber: item.houseOrderNumber,
  200. userName: item.userName,
  201. userPhone: item.userPhone,
  202. userId: uni.getStorageSync('userInfo').id
  203. }
  204. })
  205. if (result.code === 200) {
  206. uni.navigateTo({
  207. url: `/pages/pay/pay?id=${result.data}`
  208. })
  209. // uni.showToast({
  210. // title: '预定成功',
  211. // icon: 'success',
  212. // mask: true
  213. // })
  214. // setTimeout(() => {
  215. // this.page = 1
  216. // this.orderList = []
  217. // this.getOrderList()
  218. // }, 1500)
  219. }
  220. }
  221. }
  222. })
  223. },
  224. // 点击每一个订单回调
  225. goPageOrderDetail(item) {
  226. // console.log(item)
  227. uni.navigateTo({
  228. url: `/pages/orderDetail/orderDetail?id=${item.id}`
  229. })
  230. },
  231. // 右侧选项内容删除按钮回调
  232. handleDelete(item) {
  233. // console.log(item)
  234. if (
  235. item.orderStatus === '1' ||
  236. item.orderStatus === '5' ||
  237. item.orderStatus === '6' ||
  238. item.orderStatus === '7' ||
  239. item.orderStatus === '8' ||
  240. item.orderStatus === '9'
  241. ) {
  242. uni.showModal({
  243. title: '提示',
  244. content: '确定删除吗?删除后不可恢复',
  245. success: async (res) => {
  246. if (res.confirm) {
  247. const res = await this.$myRequest({
  248. url: '/mhotel/abkdelBooking.action',
  249. data: {
  250. bookingId: item.id
  251. }
  252. })
  253. // console.log(res)
  254. if (res.code === 200) {
  255. uni.showToast({
  256. title: '删除成功',
  257. icon: 'success',
  258. mask: true
  259. })
  260. setTimeout(() => {
  261. this.orderList = []
  262. this.page = 1
  263. this.getOrderList()
  264. }, 1500)
  265. }
  266. }
  267. }
  268. })
  269. } else {
  270. uni.showToast({
  271. title: '当前状态订单不可删除',
  272. icon: 'none',
  273. mask: true
  274. })
  275. }
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. .container {
  282. box-sizing: border-box;
  283. padding: 0 20rpx 40rpx;
  284. min-height: 100vh;
  285. background-color: #f2f3f5;
  286. overflow-y: auto;
  287. .order_right {
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. margin-top: 20rpx;
  292. width: 126rpx;
  293. background-color: #d43030;
  294. .img {
  295. width: 50rpx;
  296. height: 50rpx;
  297. }
  298. }
  299. .order_box {
  300. margin-top: 20rpx;
  301. box-sizing: border-box;
  302. padding: 0 22rpx;
  303. width: 710rpx;
  304. border-radius: 15rpx;
  305. background-color: #fff;
  306. .box_header {
  307. display: flex;
  308. align-items: center;
  309. height: 94rpx;
  310. .img {
  311. width: 47rpx;
  312. height: 47rpx;
  313. }
  314. .title {
  315. margin-left: 16rpx;
  316. width: 350rpx;
  317. font-size: 32rpx;
  318. font-weight: bold;
  319. overflow: hidden;
  320. white-space: nowrap;
  321. text-overflow: ellipsis;
  322. }
  323. .type {
  324. display: flex;
  325. justify-content: flex-end;
  326. align-items: center;
  327. margin-left: auto;
  328. width: 285rpx;
  329. color: #808080;
  330. font-size: 28rpx;
  331. }
  332. .type2 {
  333. color: #ff5733;
  334. }
  335. }
  336. .box_info {
  337. display: flex;
  338. height: 140rpx;
  339. .img {
  340. width: 100rpx;
  341. height: 100rpx;
  342. border-radius: 9rpx;
  343. }
  344. .info_right {
  345. display: flex;
  346. flex-direction: column;
  347. justify-content: space-around;
  348. margin-top: -5rpx;
  349. margin-left: 18rpx;
  350. height: 120rpx;
  351. color: #808080;
  352. font-size: 28rpx;
  353. .info_right_item {
  354. flex: 1;
  355. }
  356. }
  357. }
  358. .box_btn {
  359. display: flex;
  360. justify-content: flex-end;
  361. margin-top: -10rpx;
  362. height: 100rpx;
  363. .btn_item {
  364. display: flex;
  365. justify-content: center;
  366. align-items: center;
  367. margin-left: 20rpx;
  368. width: 178rpx;
  369. height: 68rpx;
  370. border-radius: 64rpx;
  371. color: #808080;
  372. font-size: 28rpx;
  373. border: 1rpx solid #808080;
  374. }
  375. }
  376. }
  377. .noData {
  378. display: flex;
  379. flex-direction: column;
  380. justify-content: center;
  381. align-items: center;
  382. img {
  383. margin-top: 150rpx;
  384. width: 600rpx;
  385. height: 600rpx;
  386. }
  387. }
  388. }
  389. // 修改倒计时字体颜色
  390. ::v-deep .uv-count-down .uv-count-down__text {
  391. color: #ff5733;
  392. }
  393. </style>