browseHistory.vue 6.0 KB

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