index.vue 3.8 KB

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