myCollection.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. if (item.IsRoadShow) {
  149. //跳转路演精华
  150. uni.navigateTo({
  151. url: "/reportPages/roadEssence/roadEssence?id=" + item.ArticleId,
  152. });
  153. } else {
  154. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId);
  155. }
  156. },
  157. // 去往主题详情
  158. themeDetails(item, val) {
  159. if (item.Source === 1) {
  160. //非严选
  161. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + val.IndustrialManagementId);
  162. } else {
  163. //严选
  164. this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + val.IndustrialManagementId);
  165. }
  166. },
  167. // 收藏
  168. async collectClick(item) {
  169. const res = await Report.collectRpt({ ArticleId: item.ArticleId });
  170. if (res.Ret === 200) {
  171. item.IsCollect = !item.IsCollect;
  172. item.IsCollect
  173. ? (item.CollectNum += 1) &&
  174. uni.showToast({
  175. title: "收藏成功",
  176. icon: "none",
  177. duration: 2000,
  178. })
  179. : (item.CollectNum -= 1);
  180. !item.IsCollect &&
  181. uni.showToast({
  182. title: "已取消收藏",
  183. icon: "none",
  184. duration: 2000,
  185. });
  186. }
  187. },
  188. // 点击top tabs
  189. handleClickTopSub(item) {
  190. this.tabsActive = item.id;
  191. this.page_no = 1;
  192. this.collectList = [];
  193. this.getCollectList();
  194. },
  195. // 微路演收藏
  196. async isCollectionHandeler(item) {
  197. const res = await Home.microRoadshowCollect({
  198. Id: item.Id,
  199. SourceType: item.Type,
  200. PageRouter: this.$store.state.pageRouterReport,
  201. });
  202. if (res.Ret === 200) {
  203. let index = this.collectList.findIndex((key) => key.Id == item.Id);
  204. this.collectList.splice(index, 1);
  205. uni.showToast({
  206. title: res.Msg,
  207. duration: 2000,
  208. });
  209. }
  210. },
  211. //我的收藏的删除
  212. myChartCollect(id) {
  213. uni.showModal({
  214. content: "确认要将该图表移除我的收藏吗?",
  215. confirmColor: "#3385FF",
  216. cancelColor: "#606266",
  217. success: async (res) => {
  218. if (res.confirm) {
  219. const res = await Chart.myChartCollect({
  220. ChartId: id,
  221. });
  222. if (res.Ret === 200) {
  223. this.page_no = 1;
  224. this.getCollectList();
  225. this.$util.toast("已取消收藏");
  226. }
  227. }
  228. },
  229. });
  230. },
  231. //我的收藏 置顶
  232. async myChartIsTop(id) {
  233. const res = await Chart.myChartTop({
  234. ChartId: id,
  235. });
  236. if (res.Ret === 200) {
  237. this.page_no = 1;
  238. this.getCollectList();
  239. this.$util.toast(res.Msg);
  240. }
  241. },
  242. },
  243. computed: {
  244. curVoiceId() {
  245. //当前正在播放的音频id
  246. return this.$store.state.audioBg.indexId;
  247. },
  248. curAudioPaused() {
  249. //当前音频是否暂停状态
  250. return this.$store.state.audioBg.paused;
  251. },
  252. showAudioBox() {
  253. return this.$store.state.audioBg.parseIntShow;
  254. },
  255. },
  256. onShow() {
  257. this.$store.commit("audioBg/parseIntAudio", true);
  258. this.$store.commit("setRouterReport", "收藏");
  259. },
  260. onHide() {
  261. this.$store.commit("audioBg/parseIntAudio", false);
  262. this.curVideoId = 0;
  263. },
  264. /* 触底 */
  265. onReachBottom() {
  266. if (this.status === "nomore") return;
  267. this.status = "loading";
  268. this.page_no++;
  269. this.getCollectList();
  270. },
  271. /* 下拉刷新 */
  272. onPullDownRefresh() {
  273. this.page_no = 1;
  274. this.refresh = true;
  275. this.getCollectList();
  276. },
  277. /** 用户点击分享*/
  278. onShareAppMessage: function ({ from, target }) {
  279. if (from === "button") {
  280. let item = target.dataset.item;
  281. let audio_id = item.Type == 1 || item.AudioType == 1 ? item.Id : "";
  282. // type=2 -- 活动视频 type=3 -- 产业视频
  283. let video_id = item.Type == 2 || item.Type == 3 ? item.Id : "";
  284. let activity_id = item.Type == 2 && item.ActivityId > 0 ? item.ActivityId : "";
  285. let title_share = item.AudioTitle || item.Title;
  286. this.getRecordTracking("我的收藏转发", { ActivityId: item.ActivityId, Id: item.Id, Type: item.Type });
  287. return {
  288. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : title_share,
  289. path: "/pages/material/material?topTabsActive=4" + "&audioShareId=" + audio_id + "&videoShareId=" + video_id + "&activityId=" + activity_id,
  290. imageUrl: item.AudioShareImg || item.ShareImg,
  291. };
  292. }
  293. },
  294. };
  295. </script>
  296. <style lang="scss">
  297. .myCollection-container {
  298. background-color: #f7f7f7;
  299. .collect-ul {
  300. padding: 4rpx 10rpx 20rpx;
  301. .content-item {
  302. background-color: #fff;
  303. margin-top: 20rpx;
  304. padding: 35rpx 20rpx 0;
  305. .item-title {
  306. font-weight: 500;
  307. .item-industry {
  308. margin-left: 10rpx;
  309. color: #3385ff;
  310. display: inline-block;
  311. }
  312. }
  313. .item-user {
  314. display: flex;
  315. align-items: center;
  316. color: #999999;
  317. font-size: 28rpx;
  318. margin-bottom: 20rpx;
  319. image {
  320. width: 23rpx;
  321. height: 26rpx;
  322. margin-right: 20rpx;
  323. }
  324. }
  325. .item-more {
  326. display: flex;
  327. justify-content: space-between;
  328. color: #cecece;
  329. margin: 20rpx 0 0;
  330. padding-bottom: 30rpx;
  331. .pv-ollect {
  332. display: flex;
  333. align-items: center;
  334. width: 40%;
  335. justify-content: space-between;
  336. image {
  337. width: 22rpx;
  338. height: 21rpx;
  339. margin-right: 10rpx;
  340. }
  341. .pv {
  342. height: 16rpx;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. .second-tabs {
  349. position: sticky;
  350. top: 0;
  351. left: 0;
  352. width: 100%;
  353. z-index: 9;
  354. display: flex;
  355. overflow: hidden;
  356. overflow-x: auto;
  357. background-color: #fff;
  358. font-size: 32rpx;
  359. color: #333333;
  360. padding: 20rpx 35rpx;
  361. &::-webkit-scrollbar {
  362. width: 0;
  363. height: 0;
  364. display: none;
  365. }
  366. .item {
  367. position: relative;
  368. padding-bottom: 16rpx;
  369. margin-right: 50rpx;
  370. flex-shrink: 0;
  371. .active {
  372. position: absolute;
  373. left: 0;
  374. bottom: 0;
  375. height: 4rpx;
  376. width: 100%;
  377. border-radius: 1rpx;
  378. background: linear-gradient(90deg, #2e85ff 0%, #7eeaf6 100%);
  379. }
  380. }
  381. .tabs-active {
  382. color: #3385ff;
  383. font-weight: 500;
  384. }
  385. }
  386. .audio-video-content {
  387. display: flex;
  388. flex-wrap: wrap;
  389. justify-content: space-between;
  390. .audio-item {
  391. width: 49%;
  392. }
  393. }
  394. .chart-ul {
  395. display: flex;
  396. flex-wrap: wrap;
  397. padding: 15rpx;
  398. justify-content: space-between;
  399. }
  400. }
  401. </style>