myCollection.vue 12 KB

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