browseHistory.vue 6.0 KB

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