orderManage.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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="countDownTime" format="mm:ss" @change="change" @finish="finish"></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/my/test.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 }} - {{ item.orderEndTime }}</view>
  37. <view class="info_right_item">总价:¥{{ item.houseTotalPrice }}.00</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">预定</view>
  43. <view class="btn_item" v-if="item.orderStatus === '6'" @click.stop="goPageDetail">再次预定</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: 10,
  62. // 一共多少条数据
  63. total: ''
  64. }
  65. },
  66. onLoad() {
  67. this.getOrderList()
  68. },
  69. // 下拉刷新
  70. onPullDownRefresh() {
  71. setTimeout(() => {
  72. this.orderList = []
  73. this.page = 1
  74. this.getOrderList()
  75. uni.stopPullDownRefresh()
  76. }, 2000)
  77. },
  78. // 上拉加载
  79. onReachBottom() {
  80. if (this.orderList.length < this.total) {
  81. this.page++
  82. this.getOrderList()
  83. } else {
  84. uni.showToast({
  85. title: '没有更多数据了',
  86. icon: 'none',
  87. mask: true
  88. })
  89. }
  90. },
  91. methods: {
  92. // 获取订单列表数据
  93. async getOrderList() {
  94. const res = await this.$myRequest({
  95. url: '/mhotel/ampgetBookingList.action',
  96. data: {
  97. userId: '2008',
  98. page: this.page,
  99. rows: this.rows
  100. }
  101. })
  102. // console.log(res)
  103. if (res.code === 200) {
  104. this.orderList = [...this.orderList, ...res.data.pageList]
  105. this.total = res.data.total
  106. }
  107. },
  108. // 倒计时变化时触发
  109. change(e) {
  110. // console.log(e)
  111. },
  112. // 倒计时结束回调
  113. finish() {
  114. uni.showModal({
  115. title: '提示',
  116. content: '订单已超过可支付时间,请重新下单',
  117. showCancel: false,
  118. success: (res) => {
  119. if (res.confirm) {
  120. uni.switchTab({
  121. url: '/pages/home/home'
  122. })
  123. }
  124. }
  125. })
  126. },
  127. // 点击预定按钮回调
  128. goPagePay() {
  129. uni.navigateTo({
  130. url: '/pages/pay/pay'
  131. })
  132. },
  133. // 点击再次预定按钮回调
  134. goPageDetail() {
  135. uni.navigateTo({
  136. url: '/pages/detail/detail'
  137. })
  138. },
  139. // 点击每一个订单回调
  140. goPageOrderDetail(item) {
  141. let info = JSON.stringify(item)
  142. uni.navigateTo({
  143. url: `/pages/orderDetail/orderDetail?info=${info}`
  144. })
  145. },
  146. // 右侧选项内容删除按钮回调
  147. handleDelete(item) {
  148. // console.log(item)
  149. uni.showModal({
  150. title: '提示',
  151. content: '确定删除吗?删除后不可恢复',
  152. success: async (res) => {
  153. if (res.confirm) {
  154. const res = await this.$myRequest({
  155. url: '/mhotel/abkdelBooking.action',
  156. data: {
  157. bookingId: item.id
  158. }
  159. })
  160. // console.log(res)
  161. if (res.code === 200) {
  162. uni.showToast({
  163. title: '删除成功',
  164. icon: 'success',
  165. mask: true
  166. })
  167. setTimeout(() => {
  168. this.orderList = []
  169. this.page = 1
  170. this.getOrderList()
  171. }, 1500)
  172. }
  173. }
  174. }
  175. })
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .container {
  182. box-sizing: border-box;
  183. padding: 0 20rpx 40rpx;
  184. min-height: 100vh;
  185. background-color: #f2f3f5;
  186. overflow-y: auto;
  187. .order_right {
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. margin-top: 20rpx;
  192. width: 126rpx;
  193. background-color: #d43030;
  194. .img {
  195. width: 50rpx;
  196. height: 50rpx;
  197. }
  198. }
  199. .order_box {
  200. margin-top: 20rpx;
  201. box-sizing: border-box;
  202. padding: 0 22rpx;
  203. width: 710rpx;
  204. border-radius: 15rpx;
  205. background-color: #fff;
  206. .box_header {
  207. display: flex;
  208. align-items: center;
  209. height: 94rpx;
  210. .img {
  211. width: 47rpx;
  212. height: 47rpx;
  213. }
  214. .title {
  215. margin-left: 16rpx;
  216. font-size: 32rpx;
  217. font-weight: bold;
  218. }
  219. .type {
  220. display: flex;
  221. align-items: center;
  222. margin-left: auto;
  223. color: #808080;
  224. font-size: 28rpx;
  225. }
  226. .type2 {
  227. color: #ff5733;
  228. }
  229. }
  230. .box_info {
  231. display: flex;
  232. height: 140rpx;
  233. .img {
  234. width: 100rpx;
  235. height: 100rpx;
  236. border-radius: 9rpx;
  237. }
  238. .info_right {
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: space-around;
  242. margin-top: -5rpx;
  243. margin-left: 18rpx;
  244. height: 120rpx;
  245. color: #808080;
  246. font-size: 28rpx;
  247. .info_right_item {
  248. flex: 1;
  249. }
  250. }
  251. }
  252. .box_btn {
  253. display: flex;
  254. justify-content: flex-end;
  255. margin-top: -10rpx;
  256. height: 100rpx;
  257. .btn_item {
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. margin-left: 20rpx;
  262. width: 178rpx;
  263. height: 68rpx;
  264. border-radius: 64rpx;
  265. color: #808080;
  266. font-size: 28rpx;
  267. border: 1rpx solid #808080;
  268. }
  269. }
  270. }
  271. }
  272. // 修改倒计时字体颜色
  273. ::v-deep .uv-count-down .uv-count-down__text {
  274. color: #ff5733;
  275. }
  276. </style>