integral.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="content">
  3. <empty v-if="list.length === 0"></empty>
  4. <view class="integral-box" v-for="(item, ind) in list" :key="ind">
  5. <view class="integral-left">
  6. <view class="integral-title">{{ item.mark }}</view>
  7. <view class="integral-time">{{ item.add_time }}</view>
  8. </view>
  9. <view class="integral-number">
  10. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  11. </view>
  12. </view>
  13. <uni-load-more :status="loadingType"></uni-load-more>
  14. </view>
  15. </template>
  16. <script>
  17. import { integrallist } from '@/api/user.js';
  18. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  19. import empty from '@/components/empty';
  20. export default {
  21. components: {
  22. uniLoadMore,
  23. empty
  24. },
  25. data() {
  26. return {
  27. list: [
  28. {
  29. id:0,mark:'ffdffa',add_time:'2021-01-27',number:9
  30. }
  31. ],
  32. page: 1,
  33. limit: 10,
  34. loadingType: 'more',
  35. }
  36. },
  37. onLoad() {
  38. this.loadData();
  39. },
  40. onReachBottom() {
  41. this.loadData();
  42. },
  43. methods: {
  44. loadData() {
  45. let obj = this;
  46. if (obj.loadingType === 'noMore') {
  47. //防止重复加载
  48. return;
  49. }
  50. // 修改当前对象状态为加载中
  51. obj.loadingType = 'loading';
  52. integrallist({
  53. page: obj.page,
  54. limit: obj.limit
  55. }).then(({data}) => {
  56. obj.list = obj.list.concat(data);
  57. obj.page++;
  58. if (obj.limit == data.length) {
  59. //判断是否还有数据, 有改为 more, 没有改为noMore
  60. obj.loadingType = 'more';
  61. return;
  62. } else {
  63. //判断是否还有数据, 有改为 more, 没有改为noMore
  64. obj.loadingType = 'noMore';
  65. }
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .content {
  73. padding-top: 20rpx;
  74. .integral-box {
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. padding: 20rpx 30rpx;
  79. border-bottom: 1px solid #EEEEEE;
  80. background: #FFFFFF;
  81. .integral-left {
  82. .integral-title {
  83. font-size: $font-base;
  84. font-family: PingFang SC;
  85. font-weight: bold;
  86. color: #333333;
  87. }
  88. .integral-time {
  89. font-size: 22rpx;
  90. font-family: PingFang SC;
  91. font-weight: 500;
  92. color: #999999;
  93. }
  94. }
  95. .integral-number {
  96. font-size: 30rpx;
  97. font-family: PingFang SC;
  98. font-weight: bold;
  99. color: #FF0000;
  100. }
  101. }
  102. }
  103. </style>