myCollection.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="container myCollection-container">
  3. <view class="collect-ul" v-if="haveData">
  4. <view class="content-item" v-for="item in collectList" :key="item.ArticleId">
  5. <view class="item-user" v-if="item.Source == 2">
  6. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/user_report.png"></image>
  7. <text> {{ item.NickName }}</text>
  8. </view>
  9. <view class="item-title">
  10. <text style="display: inline" @click="goDetailReport(item)">
  11. {{ item.Title }}
  12. </text>
  13. <text @click="themeDetails(item, val)" class="item-industry" v-for="val in item.List" :key="val.IndustrialManagementId"> # {{ val.IndustryName }} </text>
  14. </view>
  15. <view class="item-more">
  16. <text>{{ item.PublishDate }}</text>
  17. <view class="pv-ollect" v-if="item.Source == 2">
  18. <view>
  19. <image class="pv" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/examine_icon.png"></image>
  20. {{ item.Pv }}
  21. </view>
  22. <view @click="collectClick(item)">
  23. <image v-if="item.IsCollect" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_act.png"></image>
  24. <image v-else src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_ico.png"></image>
  25. {{ item.CollectNum }}人收藏
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20" v-if="totalPage > 1" />
  31. </view>
  32. <view class="nodata" v-else>
  33. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
  34. <text>暂时没有收藏的内容</text>
  35. </view>
  36. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  37. </view>
  38. </template>
  39. <script>
  40. import { Mine, Report } from "@/config/api.js";
  41. import { Throttle } from "@/config/util.js";
  42. import freeCharge from "@/components/freeCharge";
  43. export default {
  44. data() {
  45. return {
  46. page_no: 1,
  47. pageSize: 10,
  48. collectList: [],
  49. status: "loadmore",
  50. totalPage: "",
  51. loadText: {
  52. loadmore: "上拉加载更多",
  53. loading: "加载中",
  54. nomore: "已经到底了",
  55. },
  56. haveData: true, //是否有数据
  57. refresh: false, //正在下拉
  58. };
  59. },
  60. onLoad() {
  61. this.getCollectList();
  62. },
  63. components: {
  64. freeCharge,
  65. },
  66. methods: {
  67. /* 获取列表 */
  68. getCollectList() {
  69. Mine.getCollect({
  70. PageSize: this.pageSize,
  71. CurrentIndex: this.page_no,
  72. }).then((res) => {
  73. if (res.Ret === 200) {
  74. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  75. this.totalPage = res.Data.Paging.Pages; //总页数
  76. if (this.page_no === 1) {
  77. this.collectList = res.Data.List || [];
  78. this.haveData = this.collectList.length ? true : false;
  79. if (this.refresh) {
  80. uni.stopPullDownRefresh();
  81. this.refresh = false;
  82. }
  83. } else {
  84. this.collectList = this.collectList.concat(res.Data.List);
  85. }
  86. }
  87. });
  88. },
  89. // 去往文章详情页面
  90. goDetailReport(item) {
  91. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId);
  92. },
  93. // 去往主题详情
  94. themeDetails(item, val) {
  95. if (item.Source === 1) {
  96. //非严选
  97. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + val.IndustrialManagementId);
  98. } else {
  99. //严选
  100. this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + val.IndustrialManagementId);
  101. }
  102. },
  103. // 收藏
  104. async collectClick(item) {
  105. const res = await Report.collectRpt({ ArticleId: item.ArticleId });
  106. if (res.Ret === 200) {
  107. item.IsCollect = !item.IsCollect;
  108. item.IsCollect
  109. ? (item.CollectNum += 1) &&
  110. uni.showToast({
  111. title: "收藏成功",
  112. icon: "none",
  113. duration: 2000,
  114. })
  115. : (item.CollectNum -= 1);
  116. !item.IsCollect &&
  117. uni.showToast({
  118. title: "已取消收藏",
  119. icon: "none",
  120. duration: 2000,
  121. });
  122. }
  123. },
  124. },
  125. /* 触底 */
  126. onReachBottom: Throttle(function () {
  127. if (this.status === "nomore") return;
  128. this.status = "loading";
  129. this.page_no++;
  130. this.getCollectList();
  131. }),
  132. /* 下拉刷新 */
  133. onPullDownRefresh: Throttle(function () {
  134. this.page_no = 1;
  135. this.refresh = true;
  136. this.getCollectList();
  137. }),
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .myCollection-container {
  142. background-color: #f7f7f7;
  143. .collect-ul {
  144. padding: 4rpx 30rpx;
  145. .content-item {
  146. background-color: #fff;
  147. margin-top: 20rpx;
  148. padding: 35rpx 20rpx 0;
  149. .item-title {
  150. font-weight: 500;
  151. .item-industry {
  152. margin-left: 10rpx;
  153. color: #3385ff;
  154. display: inline-block;
  155. }
  156. }
  157. .item-user {
  158. display: flex;
  159. align-items: center;
  160. color: #999999;
  161. font-size: 28rpx;
  162. margin-bottom: 20rpx;
  163. image {
  164. width: 23rpx;
  165. height: 26rpx;
  166. margin-right: 20rpx;
  167. }
  168. }
  169. .item-more {
  170. display: flex;
  171. justify-content: space-between;
  172. color: #cecece;
  173. margin: 20rpx 0 0;
  174. padding-bottom: 30rpx;
  175. .pv-ollect {
  176. display: flex;
  177. align-items: center;
  178. width: 40%;
  179. justify-content: space-between;
  180. image {
  181. width: 22rpx;
  182. height: 21rpx;
  183. margin-right: 10rpx;
  184. }
  185. .pv {
  186. height: 16rpx;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. </style>