attention.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="content-box">
  5. <view class="card-box">
  6. <!-- <block v-for="item in dataList">
  7. <view class="card-items">
  8. <discovery :data-val="item" idName="followSourceId" />
  9. </view>
  10. </block> -->
  11. <!-- :key="t.key" -->
  12. <u-waterfall v-model="dataList">
  13. <template v-slot:left="{leftList}">
  14. <view class="card-left-item" v-for="(item, index) in leftList" :key="`left_${index}`">
  15. <discovery :data-val="item" idName="followSourceId"/>
  16. </view>
  17. </template>
  18. <template v-slot:right="{rightList}">
  19. <view class="card-right-item" v-for="(item, index) in rightList" :key="`right_${index}`">
  20. <discovery :data-val="item" idName="followSourceId"/>
  21. </view>
  22. </template>
  23. </u-waterfall>
  24. </view>
  25. <loadMore v-if="dataList.length > 0 || loadingStatus === 'loading' " :status="loadingStatus">
  26. </loadMore>
  27. <view class="empty-data" v-if="(!dataList || dataList.length===0) && loadingStatus=== 'noMore' ">
  28. <EmptyDate />
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import Mixin from "./Mixin.js"
  35. import {
  36. getUserFollowList
  37. } from "@/api/government.js"
  38. export default {
  39. mixins: [Mixin],
  40. data() {
  41. return {
  42. config: {
  43. back: true,
  44. title: '关注',
  45. color: 'black',
  46. backgroundColor: [1, '#fff'],
  47. statusBarFontColor: 'black'
  48. },
  49. dataList: [],
  50. pageNum: 0,
  51. pageSize: 10,
  52. loadingStatus: ''
  53. }
  54. },
  55. onLoad() {
  56. this.init();
  57. },
  58. onReachBottom() {
  59. if (this.loadingStatus === "more") {
  60. this.getUserFollow();
  61. }
  62. },
  63. onPullDownRefresh() {
  64. this.init();
  65. },
  66. methods: {
  67. init() {
  68. this.dataList = [];
  69. this.pageNum = 0;
  70. this.pageSize = 10;
  71. this.loadingStatus = '';
  72. this.getUserFollow();
  73. },
  74. getUserFollow() {
  75. if (this.loadingStatus === 'noMore' || this.loadingStatus === 'loading') return
  76. this.loadingStatus = 'loading';
  77. this.pageNum++;
  78. getUserFollowList({
  79. pageNum: this.pageNum,
  80. pageSize: this.pageSize,
  81. collectType: 0
  82. }).then(res => {
  83. if (res.code === 200) {
  84. this.dataList = this.dataList.concat(res.rows || []);
  85. };
  86. this.setLoadingStatus(this.$mUtil.pagination(res.total, this.pageNum, this.pageSize))
  87. }).catch(err => {
  88. this.setLoadingStatus("noMore")
  89. })
  90. },
  91. setLoadingStatus(status) {
  92. setTimeout(() => {
  93. this.loadingStatus = status
  94. }, 300)
  95. }
  96. }
  97. }
  98. </script>
  99. <style>
  100. page {
  101. background-color: #F9F9F9;
  102. }
  103. </style>
  104. <style lang="scss" scoped>
  105. .content-box {
  106. .card-box {
  107. padding: 0 20rpx;
  108. /deep/ .u-column{
  109. width: 50%;
  110. }
  111. // display: flex;
  112. // flex-direction: row;
  113. // justify-content: space-between;
  114. // align-items: stretch;
  115. // flex-wrap: wrap;
  116. // .card-items {
  117. // width: calc(50% - 10rpx);
  118. // }
  119. .card-left-item {
  120. padding-right: 10rpx;
  121. }
  122. .card-right-item {
  123. padding-left: 10rpx;
  124. }
  125. }
  126. .empty-data {
  127. padding-top: 80rpx;
  128. }
  129. }
  130. </style>