index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="container">
  3. <view class="dom-top">
  4. <view class="dom-item" v-for="(item, index) in domTopData" :key="index" @tap="statusClick(item.id)">
  5. <text :class="item.id === riderStatus ? 'active-dom-top' : ''">{{item.name}}</text>
  6. </view>
  7. </view>
  8. <scroll-view scroll-y style="overflow: hidden;">
  9. <view v-for="item in riderData" :key="item.id" style="margin: 10rpx 0;">
  10. <rider-order :orderInfo="item" @orderCilck="goOrderClick" :statusId="riderStatus"></rider-order>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. getRiderList
  18. } from '@/api/rider.js';
  19. import riderOrder from "@/components/riderOrder/index.vue";
  20. let app = getApp();
  21. export default {
  22. name: 'riderShipping',
  23. components: {
  24. riderOrder,
  25. },
  26. data() {
  27. return {
  28. riderData: [], // 订单数组
  29. loading: false, //是否加载中
  30. loadend: false, //是否加载完毕
  31. loadTitle: '加载更多', //提示语
  32. page: 1,
  33. limit: 20,
  34. isReceiveId: null,
  35. riderStatus: 1,
  36. domTopData: [{
  37. id: 1,
  38. name: '待接单'
  39. },
  40. {
  41. id: 8,
  42. name: '待取货'
  43. },
  44. {
  45. id: 4,
  46. name: '配送中'
  47. },
  48. {
  49. id: 5,
  50. name: '已完成'
  51. }
  52. ],
  53. }
  54. },
  55. methods: {
  56. /**
  57. * 切换类型
  58. */
  59. statusClick: function(status) {
  60. if (status == this.riderStatus) return;
  61. this.page = 1;
  62. this.riderStatus = status;
  63. this.loadend = false;
  64. this.getRiderDataList();
  65. },
  66. /**
  67. * 获取订单列表
  68. */
  69. getRiderDataList: function() {
  70. let that = this;
  71. if (that.loadend) return;
  72. if (that.loading) return;
  73. that.loading = true;
  74. that.loadTitle = "加载更多";
  75. getRiderList({
  76. status: that.riderStatus,
  77. page: that.page,
  78. limit: that.limit
  79. }).then(res => {
  80. let list = res.data.list || [];
  81. let loadend = list.length < that.limit;
  82. that.riderData = that.$util.SplitArray(list, that.riderData);
  83. that.$set(that, 'riderData', that.riderData);
  84. that.loadend = loadend;
  85. that.loading = false;
  86. that.loadTitle = loadend ? "我也是有底线的" : '加载更多';
  87. that.page = that.page + 1;
  88. }).catch(err => {
  89. that.loading = false;
  90. that.loadTitle = "加载更多";
  91. })
  92. },
  93. goOrderClick(id) {
  94. this.isReceiveId = id
  95. console.log(id)
  96. }
  97. },
  98. onLoad(options) {
  99. this.getRiderDataList()
  100. },
  101. mounted() {
  102. },
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. .container {
  107. width: 100%;
  108. height: 100%;
  109. display: flex;
  110. flex-direction: column;
  111. overflow: hidden;
  112. }
  113. .dom-top {
  114. width: 100%;
  115. height: 96rpx;
  116. font-weight: 400;
  117. font-size: 27rpx;
  118. color: #141414;
  119. background-color: #fff;
  120. // padding: 19rpx 115rpx 38rpx 115rpx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. .dom-item {
  125. flex: 1;
  126. text-align: center;
  127. height: 96rpx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. }
  132. }
  133. .active-dom-top {
  134. color: $bg-color-primary;
  135. border-bottom: 9rpx solid $bg-color-primary;
  136. border-bottom-top-radius: 6rpx;
  137. border-bottom-bottom-radius: 6rpx;
  138. border-bottom-left-radius: 6rpx;
  139. border-bottom-right-radius: 6rpx;
  140. }
  141. </style>