orderManage.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. // 订单列表
  55. orderList: [],
  56. // 倒计时时间(毫秒)
  57. countDownTime: 1000 * 60 * 15,
  58. // 当前页
  59. page: 1,
  60. // 每页多少条数据
  61. rows: 6,
  62. // 一共多少条数据
  63. total: ''
  64. }
  65. },
  66. onShow() {
  67. this.page = 1
  68. this.orderList = []
  69. this.getOrderList()
  70. },
  71. // 下拉刷新
  72. onPullDownRefresh() {
  73. setTimeout(() => {
  74. this.orderList = []
  75. this.page = 1
  76. this.getOrderList()
  77. uni.stopPullDownRefresh()
  78. }, 2000)
  79. },
  80. // 上拉加载
  81. onReachBottom() {
  82. if (this.orderList.length < this.total) {
  83. this.page++
  84. this.getOrderList()
  85. } else {
  86. uni.showToast({
  87. title: '没有更多数据了',
  88. icon: 'none',
  89. mask: true
  90. })
  91. }
  92. },
  93. methods: {
  94. // 获取订单列表数据
  95. async getOrderList() {
  96. const res = await this.$myRequest({
  97. url: '/mhotel/ampgetBookingList.action',
  98. data: {
  99. userId: uni.getStorageSync('userInfo').id,
  100. page: this.page,
  101. rows: this.rows
  102. }
  103. })
  104. // console.log(res)
  105. if (res.code === 200) {
  106. this.total = res.data.total
  107. this.orderList = [...this.orderList, ...res.data.pageList]
  108. // 如果是待支付状态,算出剩余支付时间
  109. this.orderList.forEach((ele) => {
  110. if (ele.orderStatus === '1') {
  111. ele.countDownTime = new Date(ele.createTime.slice(0, 19)).getTime() + 15 * 60 * 1000 - new Date().getTime()
  112. }
  113. })
  114. }
  115. },
  116. // 倒计时结束回调
  117. finish(item) {
  118. // console.log(item)
  119. // uni.showModal({
  120. // title: '提示',
  121. // content: '订单已超过可支付时间',
  122. // showCancel: false,
  123. // success: async (res) => {
  124. // if (res.confirm) {
  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. // uni.switchTab({
  134. // url: '/pages/my/my'
  135. // })
  136. // }
  137. // }
  138. // }
  139. // })
  140. },
  141. // 点击预定按钮回调
  142. goPagePay(item) {
  143. console.log(item.countDownTime)
  144. if (item.countDownTime <= 0) {
  145. uni.showModal({
  146. title: '提示',
  147. content: '订单已超过可支付时间',
  148. showCancel: false,
  149. success: async (res) => {
  150. if (res.confirm) {
  151. const res = await this.$myRequest({
  152. url: '/mhotel/abkupdateOrderStatus.action',
  153. data: {
  154. bookingId: item.id
  155. }
  156. })
  157. // console.log(res)
  158. if (res.code === 200) {
  159. this.page = 1
  160. this.orderList = []
  161. this.getOrderList()
  162. }
  163. }
  164. }
  165. })
  166. } else {
  167. uni.navigateTo({
  168. url: `/pages/pay/pay?id=${item.id}`
  169. })
  170. }
  171. },
  172. // 点击再次预定按钮回调
  173. goPageDetail(item) {
  174. uni.showModal({
  175. title: '提示',
  176. content: '确定再次预定吗?',
  177. success: async (res) => {
  178. if (res.confirm) {
  179. const result = await this.$myRequest({
  180. url: '/mhotel/abkcreateOrder.action',
  181. data: {
  182. houseId: item.houseId,
  183. startTime: item.orderStartTime.slice(0, 10),
  184. endTime: item.orderEndTime.slice(0, 10),
  185. houseOrderNumber: item.houseOrderNumber,
  186. userName: item.userName,
  187. userPhone: item.userPhone,
  188. userId: uni.getStorageSync('userInfo').id
  189. }
  190. })
  191. if (result.code === 200) {
  192. uni.navigateTo({
  193. url: `/pages/pay/pay?id=${result.data}`
  194. })
  195. // uni.showToast({
  196. // title: '预定成功',
  197. // icon: 'success',
  198. // mask: true
  199. // })
  200. // setTimeout(() => {
  201. // this.page = 1
  202. // this.orderList = []
  203. // this.getOrderList()
  204. // }, 1500)
  205. }
  206. }
  207. }
  208. })
  209. },
  210. // 点击每一个订单回调
  211. goPageOrderDetail(item) {
  212. // console.log(item)
  213. uni.navigateTo({
  214. url: `/pages/orderDetail/orderDetail?id=${item.id}`
  215. })
  216. },
  217. // 右侧选项内容删除按钮回调
  218. handleDelete(item) {
  219. // console.log(item)
  220. if (item.orderStatus === '5' || item.orderStatus === '6' || item.orderStatus === '7' || item.orderStatus === '8' || item.orderStatus === '9') {
  221. uni.showModal({
  222. title: '提示',
  223. content: '确定删除吗?删除后不可恢复',
  224. success: async (res) => {
  225. if (res.confirm) {
  226. const res = await this.$myRequest({
  227. url: '/mhotel/abkdelBooking.action',
  228. data: {
  229. bookingId: item.id
  230. }
  231. })
  232. // console.log(res)
  233. if (res.code === 200) {
  234. uni.showToast({
  235. title: '删除成功',
  236. icon: 'success',
  237. mask: true
  238. })
  239. setTimeout(() => {
  240. this.orderList = []
  241. this.page = 1
  242. this.getOrderList()
  243. }, 1500)
  244. }
  245. }
  246. }
  247. })
  248. } else {
  249. uni.showToast({
  250. title: '当前状态订单不可删除',
  251. icon: 'none',
  252. mask: true
  253. })
  254. }
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. .container {
  261. box-sizing: border-box;
  262. padding: 0 20rpx 40rpx;
  263. min-height: 100vh;
  264. background-color: #f2f3f5;
  265. overflow-y: auto;
  266. .order_right {
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. margin-top: 20rpx;
  271. width: 126rpx;
  272. background-color: #d43030;
  273. .img {
  274. width: 50rpx;
  275. height: 50rpx;
  276. }
  277. }
  278. .order_box {
  279. margin-top: 20rpx;
  280. box-sizing: border-box;
  281. padding: 0 22rpx;
  282. width: 710rpx;
  283. border-radius: 15rpx;
  284. background-color: #fff;
  285. .box_header {
  286. display: flex;
  287. align-items: center;
  288. height: 94rpx;
  289. .img {
  290. width: 47rpx;
  291. height: 47rpx;
  292. }
  293. .title {
  294. margin-left: 16rpx;
  295. width: 350rpx;
  296. font-size: 32rpx;
  297. font-weight: bold;
  298. overflow: hidden;
  299. white-space: nowrap;
  300. text-overflow: ellipsis;
  301. }
  302. .type {
  303. display: flex;
  304. justify-content: flex-end;
  305. align-items: center;
  306. margin-left: auto;
  307. width: 285rpx;
  308. color: #808080;
  309. font-size: 28rpx;
  310. }
  311. .type2 {
  312. color: #ff5733;
  313. }
  314. }
  315. .box_info {
  316. display: flex;
  317. height: 140rpx;
  318. .img {
  319. width: 100rpx;
  320. height: 100rpx;
  321. border-radius: 9rpx;
  322. }
  323. .info_right {
  324. display: flex;
  325. flex-direction: column;
  326. justify-content: space-around;
  327. margin-top: -5rpx;
  328. margin-left: 18rpx;
  329. height: 120rpx;
  330. color: #808080;
  331. font-size: 28rpx;
  332. .info_right_item {
  333. flex: 1;
  334. }
  335. }
  336. }
  337. .box_btn {
  338. display: flex;
  339. justify-content: flex-end;
  340. margin-top: -10rpx;
  341. height: 100rpx;
  342. .btn_item {
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. margin-left: 20rpx;
  347. width: 178rpx;
  348. height: 68rpx;
  349. border-radius: 64rpx;
  350. color: #808080;
  351. font-size: 28rpx;
  352. border: 1rpx solid #808080;
  353. }
  354. }
  355. }
  356. }
  357. // 修改倒计时字体颜色
  358. ::v-deep .uv-count-down .uv-count-down__text {
  359. color: #ff5733;
  360. }
  361. </style>