browseHistory.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="container browseHistory-container">
  3. <view class="history-ul" v-if="haveData">
  4. <view class="content-item" v-for="item in historyList" :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="10" margin-bottom="10" 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. status: "loadmore",
  47. totalPage: "",
  48. page_no: 1,
  49. pageSize: 10,
  50. haveData: null,
  51. refresh: false, //正在下拉
  52. historyList: [],
  53. loadText: {
  54. loadmore: "上拉加载更多",
  55. loading: "加载中",
  56. nomore: "已经到底了",
  57. },
  58. };
  59. },
  60. onLoad() {
  61. this.$store.commit("setRouterReport", "足迹");
  62. this.gethistoryList();
  63. },
  64. components: {
  65. freeCharge,
  66. },
  67. methods: {
  68. /* 获取列表 */
  69. gethistoryList() {
  70. Mine.getHistory({
  71. PageSize: this.pageSize,
  72. CurrentIndex: this.page_no,
  73. }).then((res) => {
  74. if (res.Ret === 200) {
  75. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  76. this.totalPage = res.Data.Paging.Pages; //总页数
  77. if (this.page_no === 1) {
  78. this.historyList = res.Data.List || [];
  79. this.haveData = this.historyList.length ? true : false;
  80. if (this.refresh) {
  81. uni.stopPullDownRefresh();
  82. this.refresh = false;
  83. }
  84. } else {
  85. this.historyList = this.historyList.concat(res.Data.List);
  86. }
  87. }
  88. });
  89. },
  90. // 去往文章详情页面
  91. goDetailReport(item) {
  92. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId);
  93. },
  94. // 去往主题详情
  95. themeDetails(item, val) {
  96. if (item.Source === 1) {
  97. //非严选
  98. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + val.IndustrialManagementId);
  99. } else {
  100. //严选
  101. this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + val.IndustrialManagementId);
  102. }
  103. },
  104. // 收藏
  105. async collectClick(item) {
  106. const res = await Report.collectRpt({ ArticleId: item.ArticleId });
  107. if (res.Ret === 200) {
  108. item.IsCollect = !item.IsCollect;
  109. item.IsCollect
  110. ? (item.CollectNum += 1) &&
  111. uni.showToast({
  112. title: "收藏成功",
  113. icon: "none",
  114. duration: 2000,
  115. })
  116. : (item.CollectNum -= 1);
  117. !item.IsCollect &&
  118. uni.showToast({
  119. title: "已取消收藏",
  120. icon: "none",
  121. duration: 2000,
  122. });
  123. }
  124. },
  125. },
  126. /* 触底 */
  127. onReachBottom: Throttle(function () {
  128. if (this.status === "nomore") return;
  129. this.status = "loading";
  130. this.page_no++;
  131. this.gethistoryList();
  132. }),
  133. /* 下拉刷新 */
  134. onPullDownRefresh: Throttle(function () {
  135. this.page_no = 1;
  136. this.refresh = true;
  137. this.gethistoryList();
  138. }),
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .browseHistory-container {
  143. background-color: #f7f7f7;
  144. .history-ul {
  145. padding: 4rpx 30rpx;
  146. .content-item {
  147. background-color: #fff;
  148. margin-top: 20rpx;
  149. padding: 35rpx 20rpx 0;
  150. .item-title {
  151. font-weight: 500;
  152. .item-industry {
  153. margin-left: 10rpx;
  154. color: #3385ff;
  155. display: inline-block;
  156. }
  157. }
  158. .item-user {
  159. display: flex;
  160. align-items: center;
  161. color: #999999;
  162. font-size: 28rpx;
  163. margin-bottom: 20rpx;
  164. image {
  165. width: 23rpx;
  166. height: 26rpx;
  167. margin-right: 20rpx;
  168. }
  169. }
  170. .item-more {
  171. display: flex;
  172. justify-content: space-between;
  173. color: #cecece;
  174. margin: 20rpx 0 0;
  175. padding-bottom: 30rpx;
  176. .pv-ollect {
  177. display: flex;
  178. align-items: center;
  179. width: 40%;
  180. justify-content: space-between;
  181. image {
  182. width: 22rpx;
  183. height: 21rpx;
  184. margin-right: 10rpx;
  185. }
  186. .pv {
  187. height: 16rpx;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>