myCollection.vue 12 KB

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