browseHistory.vue 6.0 KB

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