myCollection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="container myCollection-container">
  3. <view class="second-tabs">
  4. <view :class="['item', item.id == tabsActive && 'tabs-active']" v-for="item in tabsList" :key="item.id" @click="handleClickTopSub(item)">
  5. {{ item.name }}
  6. <view class="active" v-if="item.id == tabsActive"></view>
  7. </view>
  8. </view>
  9. <view class="collect-ul" v-if="haveData">
  10. <view class="audio-video-content" v-if="tabsActive == 2">
  11. <view class="audio-item" v-for="item in collectList" :key="item.Id">
  12. <RoadshowItem :list="item" @isCollectionHandeler="isCollectionHandeler" />
  13. </view>
  14. </view>
  15. <block v-else>
  16. <view class="content-item" v-for="item in collectList" :key="item.ArticleId">
  17. <view class="item-user" v-if="item.Source == 2">
  18. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/user_report.png"></image>
  19. <text> {{ item.NickName }}</text>
  20. </view>
  21. <view class="item-title">
  22. <text style="display: inline" @click="goDetailReport(item)">
  23. {{ item.Title }}
  24. </text>
  25. <text @click="themeDetails(item, val)" class="item-industry" v-for="val in item.List" :key="val.IndustrialManagementId"> # {{ val.IndustryName }} </text>
  26. </view>
  27. <view class="item-more">
  28. <text>{{ item.PublishDate }}</text>
  29. <view class="pv-ollect" v-if="item.Source == 2">
  30. <view>
  31. <image class="pv" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/examine_icon.png"></image>
  32. {{ item.Pv }}
  33. </view>
  34. <view @click="collectClick(item)">
  35. <image v-if="item.IsCollect" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_act.png"></image>
  36. <image v-else src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_ico.png"></image>
  37. {{ item.CollectNum }}人收藏
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </block>
  43. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20" v-if="totalPage > 1" />
  44. </view>
  45. <view class="nodata" v-else>
  46. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
  47. <text>暂时没有收藏的内容</text>
  48. </view>
  49. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  50. </view>
  51. </template>
  52. <script>
  53. import { Mine, Report, Home, User } from "@/config/api.js";
  54. import RoadshowItem from "@/components/ItemComponent/roadshowItem.vue";
  55. import freeCharge from "@/components/freeCharge";
  56. export default {
  57. data() {
  58. return {
  59. page_no: 1,
  60. pageSize: 10,
  61. collectList: [],
  62. videoAudioList: [],
  63. status: "loadmore",
  64. totalPage: "",
  65. loadText: {
  66. loadmore: "上拉加载更多",
  67. loading: "加载中",
  68. nomore: "已经到底了",
  69. },
  70. haveData: true, //是否有数据
  71. refresh: false, //正在下拉
  72. tabsList: [
  73. { name: "报告", id: 1 },
  74. { name: "微路演", id: 2 },
  75. ],
  76. tabsActive: 1,
  77. };
  78. },
  79. onLoad() {
  80. uni.hideShareMenu();
  81. this.getCollectList();
  82. },
  83. components: {
  84. freeCharge,
  85. RoadshowItem,
  86. },
  87. methods: {
  88. /* 获取列表 */
  89. async getCollectList() {
  90. const res =
  91. this.tabsActive == 1
  92. ? await Mine.getCollect({
  93. PageSize: this.pageSize,
  94. CurrentIndex: this.page_no,
  95. })
  96. : this.getrroadshowList();
  97. if (res.Ret === 200) {
  98. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  99. this.totalPage = res.Data.Paging.Pages; //总页数
  100. if (this.page_no === 1) {
  101. this.collectList = res.Data.List || [];
  102. this.haveData = this.collectList.length ? true : false;
  103. if (this.refresh) {
  104. uni.stopPullDownRefresh();
  105. this.refresh = false;
  106. }
  107. } else {
  108. this.collectList = this.collectList.concat(res.Data.List);
  109. }
  110. }
  111. },
  112. async getrroadshowList() {
  113. const res = await User.getListMicroRoadshow();
  114. if (res.Ret === 200) {
  115. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  116. this.totalPage = res.Data.Paging.Pages; //总页数
  117. if (this.page_no === 1) {
  118. this.collectList = res.Data.List || [];
  119. this.haveData = this.collectList.length ? true : false;
  120. if (this.refresh) {
  121. uni.stopPullDownRefresh();
  122. this.refresh = false;
  123. }
  124. } else {
  125. this.collectList = this.collectList.concat(res.Data.List);
  126. }
  127. }
  128. },
  129. // 去往文章详情页面
  130. goDetailReport(item) {
  131. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId);
  132. },
  133. // 去往主题详情
  134. themeDetails(item, val) {
  135. if (item.Source === 1) {
  136. //非严选
  137. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + val.IndustrialManagementId);
  138. } else {
  139. //严选
  140. this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + val.IndustrialManagementId);
  141. }
  142. },
  143. // 收藏
  144. async collectClick(item) {
  145. const res = await Report.collectRpt({ ArticleId: item.ArticleId });
  146. if (res.Ret === 200) {
  147. item.IsCollect = !item.IsCollect;
  148. item.IsCollect
  149. ? (item.CollectNum += 1) &&
  150. uni.showToast({
  151. title: "收藏成功",
  152. icon: "none",
  153. duration: 2000,
  154. })
  155. : (item.CollectNum -= 1);
  156. !item.IsCollect &&
  157. uni.showToast({
  158. title: "已取消收藏",
  159. icon: "none",
  160. duration: 2000,
  161. });
  162. }
  163. },
  164. // 点击top tabs
  165. handleClickTopSub(item) {
  166. this.tabsActive = item.id;
  167. this.page_no = 1;
  168. this.collectList = [];
  169. this.getCollectList();
  170. },
  171. // 微路演收藏
  172. async isCollectionHandeler(item) {
  173. const res = await Home.microRoadshowCollect({
  174. Id: item.Id,
  175. SourceType: item.Type,
  176. PageRouter: this.$store.state.pageRouterReport,
  177. });
  178. if (res.Ret === 200) {
  179. let index = this.collectList.findIndex((key) => key.Id == item.Id);
  180. this.collectList.splice(index, 1);
  181. uni.showToast({
  182. title: res.Msg,
  183. duration: 2000,
  184. });
  185. }
  186. },
  187. },
  188. computed: {
  189. curVoiceId() {
  190. //当前正在播放的音频id
  191. return this.$store.state.audioBg.indexId;
  192. },
  193. curAudioPaused() {
  194. //当前音频是否暂停状态
  195. return this.$store.state.audioBg.paused;
  196. },
  197. showAudioBox() {
  198. return this.$store.state.audioBg.parseIntShow;
  199. },
  200. },
  201. onShow() {
  202. this.$store.commit("audioBg/parseIntAudio", true);
  203. this.$store.commit("setRouterReport", "收藏");
  204. },
  205. onHide() {
  206. this.$store.commit("audioBg/parseIntAudio", false);
  207. this.curVideoId = 0;
  208. },
  209. /* 触底 */
  210. onReachBottom() {
  211. if (this.status === "nomore") return;
  212. this.status = "loading";
  213. this.page_no++;
  214. this.getCollectList();
  215. },
  216. /* 下拉刷新 */
  217. onPullDownRefresh() {
  218. this.page_no = 1;
  219. this.refresh = true;
  220. this.getCollectList();
  221. },
  222. /** 用户点击分享*/
  223. onShareAppMessage: function ({ from, target }) {
  224. if (from === "button") {
  225. let item = target.dataset.item;
  226. let audio_id = item.Type == 1 || item.AudioType == 1 ? item.Id : "";
  227. // type=2 -- 活动视频 type=3 -- 产业视频
  228. let video_id = item.Type == 2 || item.Type == 3 ? item.Id : "";
  229. let activity_id = item.Type == 2 && item.ActivityId > 0 ? item.ActivityId : "";
  230. let title_share = item.AudioTitle || item.Title;
  231. this.getRecordTracking("我的收藏转发", { ActivityId: item.ActivityId, Id: item.Id, Type: item.Type });
  232. return {
  233. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : title_share,
  234. path: "/pages/material/material?topTabsActive=4" + "&audioShareId=" + audio_id + "&videoShareId=" + video_id + "&activityId=" + activity_id,
  235. imageUrl: item.AudioShareImg || item.ShareImg,
  236. };
  237. }
  238. },
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. .myCollection-container {
  243. background-color: #f7f7f7;
  244. .collect-ul {
  245. padding: 4rpx 10rpx 20rpx;
  246. .content-item {
  247. background-color: #fff;
  248. margin-top: 20rpx;
  249. padding: 35rpx 20rpx 0;
  250. .item-title {
  251. font-weight: 500;
  252. .item-industry {
  253. margin-left: 10rpx;
  254. color: #3385ff;
  255. display: inline-block;
  256. }
  257. }
  258. .item-user {
  259. display: flex;
  260. align-items: center;
  261. color: #999999;
  262. font-size: 28rpx;
  263. margin-bottom: 20rpx;
  264. image {
  265. width: 23rpx;
  266. height: 26rpx;
  267. margin-right: 20rpx;
  268. }
  269. }
  270. .item-more {
  271. display: flex;
  272. justify-content: space-between;
  273. color: #cecece;
  274. margin: 20rpx 0 0;
  275. padding-bottom: 30rpx;
  276. .pv-ollect {
  277. display: flex;
  278. align-items: center;
  279. width: 40%;
  280. justify-content: space-between;
  281. image {
  282. width: 22rpx;
  283. height: 21rpx;
  284. margin-right: 10rpx;
  285. }
  286. .pv {
  287. height: 16rpx;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. .second-tabs {
  294. position: sticky;
  295. top: 0;
  296. left: 0;
  297. width: 100%;
  298. z-index: 9;
  299. display: flex;
  300. overflow: hidden;
  301. overflow-x: auto;
  302. background-color: #fff;
  303. font-size: 32rpx;
  304. color: #333333;
  305. padding: 20rpx 35rpx;
  306. &::-webkit-scrollbar {
  307. width: 0;
  308. height: 0;
  309. display: none;
  310. }
  311. .item {
  312. position: relative;
  313. padding-bottom: 16rpx;
  314. margin-right: 50rpx;
  315. flex-shrink: 0;
  316. .active {
  317. position: absolute;
  318. left: 0;
  319. bottom: 0;
  320. height: 4rpx;
  321. width: 100%;
  322. border-radius: 1rpx;
  323. background: linear-gradient(90deg, #2e85ff 0%, #7eeaf6 100%);
  324. }
  325. }
  326. .tabs-active {
  327. color: #3385ff;
  328. font-weight: 500;
  329. }
  330. }
  331. .audio-video-content {
  332. display: flex;
  333. flex-wrap: wrap;
  334. justify-content: space-between;
  335. .audio-item {
  336. width: 49%;
  337. }
  338. }
  339. }
  340. </style>