index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view>
  3. <view v-if="integralList.length" class="month-list">
  4. <view class="month-item" v-for="(integralItem, index) in integralList" :key="index">
  5. <view class="month-top">{{ integralItem.time }}</view>
  6. <view class="month-bottom">
  7. <view class="item acea-row" v-for="item in integralItem.list" :key="item.id">
  8. <view class="item-left">
  9. <view>{{ item.mark }}</view>
  10. <view class="time">{{ item.add_time }}</view>
  11. </view>
  12. <view class="item-right">{{ item.pm ? '+' : '-' }}{{ item.number }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="px-20 mt-20" v-else>
  18. <emptyPage title='暂无积分记录~' src="/statics/images/noOrder.gif"></emptyPage>
  19. </view>
  20. <view class="loadingicon acea-row row-center-wrapper" v-if="integralList.length">{{ loadTitle }}</view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getIntegralList
  26. } from '@/api/user.js';
  27. import emptyPage from '@/components/emptyPage.vue'
  28. export default {
  29. data() {
  30. return {
  31. page: 1,
  32. limit: 10,
  33. integralList: [],
  34. list: [],
  35. times: [],
  36. loadend: false,
  37. loading: false,
  38. loadTitle: '加载更多',
  39. }
  40. },
  41. components:{ emptyPage },
  42. onLoad() {
  43. this.getIntegralList();
  44. },
  45. onReachBottom() {
  46. this.getIntegralList();
  47. },
  48. methods: {
  49. getIntegralList() {
  50. let that = this;
  51. if (that.loading) return;
  52. if (that.loadend) return;
  53. that.loading = true;
  54. that.loadTitle = '';
  55. getIntegralList({
  56. page: that.page,
  57. limit: that.limit
  58. }).then(function(res) {
  59. let data = res.data;
  60. let list = data.list;
  61. let times = data.times;
  62. let integralList = [];
  63. for (let i = 0; i < times.length; i++) {
  64. if (!that.times.includes(times[i])) {
  65. that.times.push(times[i]);
  66. that.integralList.push({
  67. time: times[i],
  68. list: [],
  69. });
  70. }
  71. }
  72. for (let i = 0; i < that.integralList.length; i++) {
  73. for (let j = 0; j < list.length; j++) {
  74. if (times[i] == list[j].time_key) {
  75. that.integralList[i].list.push(list[j]);
  76. }
  77. }
  78. }
  79. let loadend = list.length < that.limit;
  80. that.page = that.page + 1;
  81. that.loading = false;
  82. that.loadend = loadend;
  83. that.loadTitle = loadend ? '没有更多内容啦~' : "加载更多";
  84. }, function(res) {
  85. this.loading = false;
  86. that.loadTitle = '加载更多';
  87. });
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .month-list {
  94. padding: 0 20rpx;
  95. .month-top {
  96. padding: 32rpx 0 24rpx;
  97. font-size: 24rpx;
  98. line-height: 34rpx;
  99. color: #999999;
  100. }
  101. .month-bottom {
  102. padding: 0 24rpx;
  103. border-radius: 24rpx;
  104. background: #FFFFFF;
  105. }
  106. .item {
  107. padding: 32rpx 0;
  108. +.item {
  109. border-top: 1rpx solid #EEEEEE;
  110. }
  111. }
  112. .item-left {
  113. flex: 1;
  114. font-size: 28rpx;
  115. line-height: 40rpx;
  116. color: #333333;
  117. }
  118. .time {
  119. margin-top: 12rpx;
  120. font-size: 24rpx;
  121. line-height: 34rpx;
  122. color: #999999;
  123. }
  124. .item-right {
  125. font-family: Regular;
  126. font-size: 36rpx;
  127. line-height: 40rpx;
  128. color: #333333;
  129. }
  130. }
  131. .loadingicon {
  132. padding: 32rpx 0;
  133. font-size: 26rpx;
  134. line-height: 36rpx;
  135. color: #CCCCCC;
  136. }
  137. </style>