index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="container">
  3. <u-navbar title="接单中心" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
  4. <scroll-view class="scroll_wrap" scroll-y @scrolltolower="scrolltolower">
  5. <order-card v-for="order, index in ordersList" :key="order.receiptId" :order="order"
  6. @handleCardClick="handleCardClick" @handleBuzyBtnClick="handleBuzyBtnClick"></order-card>
  7. <view class="hasMore">
  8. {{ ordersList.length >= page.total ? '没有更多了~' : '向下滑动加载更多~' }}
  9. </view>
  10. </scroll-view>
  11. <view class="createOrder" @click="handleAddClick">
  12. <u-icon name="plus" size="30" color="#ffffff"></u-icon>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import orderCard from "./compounts/orderCard.vue";
  18. export default {
  19. components: {
  20. orderCard
  21. },
  22. data() {
  23. return {
  24. ordersList: [],
  25. page: {
  26. pageSize: 10,
  27. pageNum: 1,
  28. total: 0
  29. }
  30. };
  31. },
  32. methods: {
  33. async getOrderList() {
  34. const { rows, total } = await uni.$u.api.selectClueOrderFormList({
  35. pageSize: this.page.pageSize,
  36. pageNum: this.page.pageNum,
  37. }
  38. );
  39. console.log('接单列表', rows);
  40. this.ordersList.push(...rows);
  41. this.page.total = total;
  42. },
  43. scrolltolower() {
  44. if (this.ordersList.length >= this.page.total) {
  45. return uni.$u.toast('没有更多了');
  46. }
  47. this.page.pageNum++;
  48. this.getOrderList();
  49. },
  50. reset() {
  51. this.ordersList = [];
  52. this.page.pageNum = 1;
  53. },
  54. // 跳转按钮接单
  55. handleCardClick(order) {
  56. console.log('点击了订单', order);
  57. //跳转
  58. // uni.navigateTo({
  59. // url: `/pages/orderDetail/index?orderId=${order.id}&item=${order.item}&type=${this.type}&clueId=${order.clueId}`,
  60. // })
  61. //跳转新的页面
  62. uni.navigateTo({
  63. url: `/pages/orderDetailNew/index?orderId=${order.id}&item=${order.item}&type=${this.type}&clueId=${order.clueId}`,
  64. })
  65. },
  66. // 在忙按钮先延迟把当前项目移动到队列末尾
  67. // 点击或者在忙的时候倒计时300s结束之后触发
  68. // 目前的问题是移动到当前10个item
  69. // 队列的最后,而不是全部队列的最后
  70. handleBuzyBtnClick(order) {
  71. console.log('在忙', order);
  72. // 先把当前项目移动到队列末尾
  73. const index = this.ordersList.findIndex(item => item.id == order.id);
  74. if (index != -1) {
  75. const item = this.ordersList.splice(index, 1)[0];
  76. this.ordersList.push(item);
  77. }
  78. },
  79. },
  80. onLoad() {
  81. this.getOrderList();
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .scroll_wrap {
  87. height: calc(100vh - 44px);
  88. }
  89. .hasMore {
  90. text-align: center;
  91. padding: 20rpx 0;
  92. font-size: 24rpx;
  93. color: #999;
  94. }
  95. .createOrder {
  96. position: fixed;
  97. bottom: 20rpx;
  98. right: 20rpx;
  99. z-index: 999;
  100. background-color: #007AFF;
  101. border-radius: 50%;
  102. padding: 10rpx;
  103. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  104. width: 80rpx;
  105. height: 80rpx;
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. }
  110. </style>