myCollection.vue 13 KB

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