orderManage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. <uni-countdown :show-day="false" :second="countDownTime" @timeup="timeup(item.createTime)" />
  20. <!-- <uv-count-down :time="countDownTime" format="mm:ss" @change="change" @finish="finish"></uv-count-down> -->
  21. </view>
  22. <view class="type" v-if="item.orderStatus === '2'">已支付</view>
  23. <view class="type" v-if="item.orderStatus === '3'">待入住</view>
  24. <view class="type" v-if="item.orderStatus === '4'">已入住</view>
  25. <view class="type" v-if="item.orderStatus === '5'">已消费</view>
  26. <view class="type" v-if="item.orderStatus === '6'">支付超时</view>
  27. <view class="type" v-if="item.orderStatus === '7'">已取消</view>
  28. <view class="type" v-if="item.orderStatus === '8'">已退单</view>
  29. <view class="type" v-if="item.orderStatus === '9'">已退款</view>
  30. <view class="type" v-if="item.orderStatus === '10'">退款中</view>
  31. </view>
  32. <!-- 酒店信息区域 -->
  33. <view class="box_info">
  34. <img class="img" :src="item.imgUrl || '../../static/my/test.png'" />
  35. <view class="info_right">
  36. <view class="info_right_item">{{ item.houseOrderNumber }}间,{{ item.houseName }}</view>
  37. <view class="info_right_item">{{ item.orderStartTime }} - {{ item.orderEndTime }}</view>
  38. <view class="info_right_item">总价:¥{{ item.houseTotalPrice }}.00</view>
  39. </view>
  40. </view>
  41. <!-- 按钮区域 -->
  42. <view class="box_btn" v-if="item.orderStatus === '1' || item.orderStatus === '6'">
  43. <view class="btn_item" v-if="item.orderStatus === '1'" @click.stop="goPagePay">预定</view>
  44. <view class="btn_item" v-if="item.orderStatus === '6'" @click.stop="goPageDetail">再次预定</view>
  45. </view>
  46. </view>
  47. </uni-swipe-action-item>
  48. </uni-swipe-action>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. // 订单列表
  56. orderList: [],
  57. // 倒计时时间(毫秒)
  58. countDownTime: null,
  59. // 当前页
  60. page: 1,
  61. // 每页多少条数据
  62. rows: 10,
  63. // 一共多少条数据
  64. total: ''
  65. }
  66. },
  67. onLoad() {
  68. this.getOrderList()
  69. },
  70. onUnload: function () {
  71. clearInterval(this.timer);
  72. },
  73. // 下拉刷新
  74. onPullDownRefresh() {
  75. setTimeout(() => {
  76. this.orderList = []
  77. this.page = 1
  78. this.getOrderList()
  79. uni.stopPullDownRefresh()
  80. }, 2000)
  81. },
  82. // 上拉加载
  83. onReachBottom() {
  84. if (this.orderList.length < this.total) {
  85. this.page++
  86. this.getOrderList()
  87. } else {
  88. uni.showToast({
  89. title: '没有更多数据了',
  90. icon: 'none',
  91. mask: true
  92. })
  93. }
  94. },
  95. methods: {
  96. // 获取订单列表数据
  97. async getOrderList() {
  98. const res = await this.$myRequest({
  99. url: '/mhotel/ampgetBookingList.action',
  100. data: {
  101. userId: '2008',
  102. page: this.page,
  103. rows: this.rows
  104. }
  105. })
  106. // console.log(res)
  107. if (res.code === 200) {
  108. this.orderList = [...this.orderList, ...res.data.pageList]
  109. this.total = res.data.total
  110. }
  111. },
  112. // 倒计时变化时触发
  113. change(e) {
  114. // console.log(e)
  115. },
  116. // 倒计时结束回调
  117. finish() {
  118. uni.showModal({
  119. title: '提示',
  120. content: '订单已超过可支付时间,请重新下单',
  121. showCancel: false,
  122. success: (res) => {
  123. if (res.confirm) {
  124. uni.switchTab({
  125. url: '/pages/home/home'
  126. })
  127. }
  128. }
  129. })
  130. },
  131. // 倒计时
  132. timeup(createTime) {
  133. var that = this;
  134. /**setInterval间歇调用 */
  135. that.timer = setInterval(function () {
  136. //订单下单时间
  137. var buy_time = createTime;
  138. //计算剩余下单时间
  139. var time = (new Date(buy_time).getTime() + 15* 60 * 1000) - (new Date().getTime());
  140. if(time>0){
  141. //计算剩余的分钟
  142. var minutes = parseInt(time / 1000 / 60 % 60, 10);
  143. //计算剩余的秒数
  144. var seconds = parseInt(time / 1000 % 60, 10);
  145. that.countDownTime=parseInt(time / 1000);
  146. // console.log(that.countDownTime)
  147. //判断分钟和秒数小于10要在前面加个0.
  148. if(minutes<10){
  149. minutes = '0' + minutes;
  150. }
  151. if (seconds < 10) {
  152. seconds = '0' + seconds;
  153. }
  154. var timer = minutes + ":" + seconds;
  155. }
  156. }, 1000);
  157. if(that.countDownTime==0) {
  158. uni.showModal({
  159. title: '提示',
  160. content: '订单已超过可支付时间,请重新下单',
  161. showCancel: false,
  162. success: (res) => {
  163. if (res.confirm) {
  164. uni.switchTab({
  165. url: '/pages/home/home'
  166. })
  167. }
  168. }
  169. })
  170. }
  171. },
  172. // 点击预定按钮回调
  173. goPagePay() {
  174. uni.navigateTo({
  175. url: '/pages/pay/pay'
  176. })
  177. },
  178. // 点击再次预定按钮回调
  179. goPageDetail() {
  180. uni.navigateTo({
  181. url: '/pages/detail/detail'
  182. })
  183. },
  184. // 点击每一个订单回调
  185. goPageOrderDetail(item) {
  186. let info = JSON.stringify(item)
  187. uni.navigateTo({
  188. url: `/pages/orderDetail/orderDetail?info=${info}`
  189. })
  190. },
  191. // 右侧选项内容删除按钮回调
  192. handleDelete(item) {
  193. // console.log(item)
  194. uni.showModal({
  195. title: '提示',
  196. content: '确定删除吗?删除后不可恢复',
  197. success: async (res) => {
  198. if (res.confirm) {
  199. const res = await this.$myRequest({
  200. url: '/mhotel/abkdelBooking.action',
  201. data: {
  202. bookingId: item.id
  203. }
  204. })
  205. // console.log(res)
  206. if (res.code === 200) {
  207. uni.showToast({
  208. title: '删除成功',
  209. icon: 'success',
  210. mask: true
  211. })
  212. setTimeout(() => {
  213. this.orderList = []
  214. this.page = 1
  215. this.getOrderList()
  216. }, 1500)
  217. }
  218. }
  219. }
  220. })
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .container {
  227. box-sizing: border-box;
  228. padding: 0 20rpx 40rpx;
  229. min-height: 100vh;
  230. background-color: #f2f3f5;
  231. overflow-y: auto;
  232. .order_right {
  233. display: flex;
  234. justify-content: center;
  235. align-items: center;
  236. margin-top: 20rpx;
  237. width: 126rpx;
  238. background-color: #d43030;
  239. .img {
  240. width: 50rpx;
  241. height: 50rpx;
  242. }
  243. }
  244. .order_box {
  245. margin-top: 20rpx;
  246. box-sizing: border-box;
  247. padding: 0 22rpx;
  248. width: 710rpx;
  249. border-radius: 15rpx;
  250. background-color: #fff;
  251. .box_header {
  252. display: flex;
  253. align-items: center;
  254. height: 94rpx;
  255. .img {
  256. width: 47rpx;
  257. height: 47rpx;
  258. }
  259. .title {
  260. margin-left: 16rpx;
  261. font-size: 32rpx;
  262. font-weight: bold;
  263. }
  264. .type {
  265. display: flex;
  266. align-items: center;
  267. margin-left: auto;
  268. color: #808080;
  269. font-size: 28rpx;
  270. }
  271. .type2 {
  272. color: #ff5733;
  273. }
  274. }
  275. .box_info {
  276. display: flex;
  277. height: 140rpx;
  278. .img {
  279. width: 100rpx;
  280. height: 100rpx;
  281. border-radius: 9rpx;
  282. }
  283. .info_right {
  284. display: flex;
  285. flex-direction: column;
  286. justify-content: space-around;
  287. margin-top: -5rpx;
  288. margin-left: 18rpx;
  289. height: 120rpx;
  290. color: #808080;
  291. font-size: 28rpx;
  292. .info_right_item {
  293. flex: 1;
  294. }
  295. }
  296. }
  297. .box_btn {
  298. display: flex;
  299. justify-content: flex-end;
  300. margin-top: -10rpx;
  301. height: 100rpx;
  302. .btn_item {
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. margin-left: 20rpx;
  307. width: 178rpx;
  308. height: 68rpx;
  309. border-radius: 64rpx;
  310. color: #808080;
  311. font-size: 28rpx;
  312. border: 1rpx solid #808080;
  313. }
  314. }
  315. }
  316. }
  317. // 修改倒计时字体颜色
  318. ::v-deep .uv-count-down .uv-count-down__text {
  319. color: #ff5733;
  320. }
  321. </style>