myCollection.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="container myCollection-container">
  3. <view class="collect-ul" v-if="haveData">
  4. <view class="collect-ltem" v-for="(item,index) in collectList" :key="index" @click="goDetail(item.ArticleId)">
  5. <view class="item-left">
  6. <text class="title text_twoLine">{{item.Title}}</text>
  7. <text class="text_twoLine desc">{{item.Body}}</text>
  8. </view>
  9. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  10. </view>
  11. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20"/>
  12. </view>
  13. <view class="nodata" v-else>
  14. <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
  15. <text>暂时没有收藏的内容</text>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { Mine } from '@/config/api.js'
  21. import { Throttle } from '@/config/util.js'
  22. export default {
  23. data() {
  24. return {
  25. page_no:1,
  26. pageSize:10,
  27. collectList:[],
  28. haveData:true,
  29. status:'loadmore',
  30. loadText: {
  31. loadmore: '上拉加载更多',
  32. loading: '加载中',
  33. nomore: '已经到底了'
  34. },
  35. };
  36. },
  37. onLoad() {
  38. this.getCollectList()
  39. },
  40. methods: {
  41. /* 获取列表 */
  42. getCollectList() {
  43. Mine.getCollect({
  44. PageSize: this.pageSize,
  45. CurrentIndex: this.page_no
  46. }).then(res => {
  47. if(res.Ret === 200) {
  48. this.status = this.page_no < res.Data.Paging.Pages ? 'loadmore' : 'nomore';
  49. if(this.page_no === 1) {
  50. this.collectList = res.Data.List || [];
  51. this.haveData = this.collectList.length ? true : false
  52. }else {
  53. this.collectList = this.collectList.concat(res.Data.List)
  54. }
  55. }
  56. })
  57. },
  58. goDetail(id) {
  59. uni.navigateTo({
  60. url:'/pages/reportDetail/reportDetail?id='+id,
  61. })
  62. }
  63. },
  64. /* 触底 */
  65. onReachBottom: Throttle(function() {
  66. if(this.status === 'nomore') return ;
  67. this.status = 'loading';
  68. this.page_no++;
  69. this.getCollectList()
  70. })
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .myCollection-container {
  75. background-color: #F7F7F7;
  76. .collect-ul {
  77. padding-top: 4rpx;
  78. .collect-ltem {
  79. display: flex;
  80. padding: 30rpx 34rpx;
  81. background: #fff;
  82. margin-bottom: 4rpx;
  83. align-items: center;
  84. justify-content: space-between;
  85. .title {
  86. max-width: 625rpx;
  87. color: #4A4A4A;
  88. font-size: 34rpx;
  89. }
  90. .desc {
  91. margin-top: 17rpx;
  92. width: 625rpx;
  93. color: #999;
  94. }
  95. }
  96. }
  97. }
  98. </style>