myCollection.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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" v-if="totalPage > 1" />
  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. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  18. </view>
  19. </template>
  20. <script>
  21. import { Mine } from "@/config/api.js";
  22. import { Throttle } from "@/config/util.js";
  23. import freeCharge from "@/components/freeCharge";
  24. export default {
  25. data() {
  26. return {
  27. refresh: false, //正在下拉
  28. page_no: 1,
  29. pageSize: 10,
  30. collectList: [],
  31. haveData: true,
  32. status: "loadmore",
  33. loadText: {
  34. loadmore: "上拉加载更多",
  35. loading: "加载中",
  36. nomore: "已经到底了",
  37. },
  38. totalPage: "",
  39. };
  40. },
  41. onLoad() {
  42. this.getCollectList();
  43. },
  44. components: {
  45. freeCharge,
  46. },
  47. methods: {
  48. /* 获取列表 */
  49. getCollectList() {
  50. Mine.getCollect({
  51. PageSize: this.pageSize,
  52. CurrentIndex: this.page_no,
  53. }).then((res) => {
  54. if (res.Ret === 200) {
  55. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  56. this.totalPage = res.Data.Paging.Pages; //总页数
  57. if (this.page_no === 1) {
  58. this.collectList = res.Data.List || [];
  59. this.haveData = this.collectList.length ? true : false;
  60. if (this.refresh) {
  61. uni.stopPullDownRefresh();
  62. this.refresh = false;
  63. }
  64. } else {
  65. this.collectList = this.collectList.concat(res.Data.List);
  66. }
  67. }
  68. });
  69. },
  70. goDetail(id) {
  71. uni.navigateTo({
  72. url: "/pageMy/reportDetail/reportDetail?id=" + id,
  73. });
  74. },
  75. },
  76. /* 触底 */
  77. onReachBottom: Throttle(function () {
  78. if (this.status === "nomore") return;
  79. this.status = "loading";
  80. this.page_no++;
  81. this.getCollectList();
  82. }),
  83. /* 下拉刷新 */
  84. onPullDownRefresh: Throttle(function () {
  85. this.page_no = 1;
  86. this.refresh = true;
  87. this.getCollectList();
  88. }),
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .myCollection-container {
  93. background-color: #f7f7f7;
  94. .collect-ul {
  95. padding-top: 4rpx;
  96. .collect-ltem {
  97. display: flex;
  98. padding: 30rpx 34rpx;
  99. background: #fff;
  100. margin-bottom: 4rpx;
  101. align-items: center;
  102. justify-content: space-between;
  103. .title {
  104. max-width: 625rpx;
  105. color: #4a4a4a;
  106. font-size: 34rpx;
  107. }
  108. .desc {
  109. margin-top: 17rpx;
  110. width: 625rpx;
  111. color: #999;
  112. }
  113. }
  114. }
  115. }
  116. </style>