myCollection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. this.$store.commit("setRouterReport", "收藏");
  81. uni.hideShareMenu();
  82. this.getCollectList();
  83. },
  84. components: {
  85. freeCharge,
  86. RoadshowItem,
  87. },
  88. methods: {
  89. /* 获取列表 */
  90. async getCollectList() {
  91. const res =
  92. this.tabsActive == 1
  93. ? await Mine.getCollect({
  94. PageSize: this.pageSize,
  95. CurrentIndex: this.page_no,
  96. })
  97. : this.getrroadshowList();
  98. if (res.Ret === 200) {
  99. this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
  100. this.totalPage = res.Data.Paging.Pages; //总页数
  101. if (this.page_no === 1) {
  102. this.collectList = res.Data.List || [];
  103. this.haveData = this.collectList.length ? true : false;
  104. if (this.refresh) {
  105. uni.stopPullDownRefresh();
  106. this.refresh = false;
  107. }
  108. } else {
  109. this.collectList = this.collectList.concat(res.Data.List);
  110. }
  111. }
  112. },
  113. async getrroadshowList() {
  114. const res = await User.getListMicroRoadshow();
  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. // 去往文章详情页面
  131. goDetailReport(item) {
  132. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId);
  133. },
  134. // 去往主题详情
  135. themeDetails(item, val) {
  136. if (item.Source === 1) {
  137. //非严选
  138. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + val.IndustrialManagementId);
  139. } else {
  140. //严选
  141. this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + val.IndustrialManagementId);
  142. }
  143. },
  144. // 收藏
  145. async collectClick(item) {
  146. const res = await Report.collectRpt({ ArticleId: item.ArticleId });
  147. if (res.Ret === 200) {
  148. item.IsCollect = !item.IsCollect;
  149. item.IsCollect
  150. ? (item.CollectNum += 1) &&
  151. uni.showToast({
  152. title: "收藏成功",
  153. icon: "none",
  154. duration: 2000,
  155. })
  156. : (item.CollectNum -= 1);
  157. !item.IsCollect &&
  158. uni.showToast({
  159. title: "已取消收藏",
  160. icon: "none",
  161. duration: 2000,
  162. });
  163. }
  164. },
  165. // 点击top tabs
  166. handleClickTopSub(item) {
  167. this.tabsActive = item.id;
  168. this.page_no = 1;
  169. this.collectList = [];
  170. this.getCollectList();
  171. },
  172. // 微路演收藏
  173. async isCollectionHandeler(item) {
  174. const res = await Home.microRoadshowCollect({
  175. Id: item.Id,
  176. SourceType: item.Type,
  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. },
  204. onHide() {
  205. this.$store.commit("audioBg/parseIntAudio", false);
  206. this.curVideoId = 0;
  207. },
  208. /* 触底 */
  209. onReachBottom() {
  210. if (this.status === "nomore") return;
  211. this.status = "loading";
  212. this.page_no++;
  213. this.getCollectList();
  214. },
  215. /* 下拉刷新 */
  216. onPullDownRefresh() {
  217. this.page_no = 1;
  218. this.refresh = true;
  219. this.getCollectList();
  220. },
  221. /** 用户点击分享*/
  222. onShareAppMessage: function ({ from, target }) {
  223. if (from === "button") {
  224. let item = target.dataset.item;
  225. let audio_id = item.Type == 1 || item.AudioType == 1 ? item.Id : "";
  226. // type=2 -- 活动视频 type=3 -- 产业视频
  227. let video_id = item.Type == 2 || item.Type == 3 ? item.Id : "";
  228. let activity_id = item.Type == 2 && item.ActivityId > 0 ? item.ActivityId : "";
  229. let title_share = item.AudioTitle || item.Title;
  230. return {
  231. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : title_share,
  232. path: "/pages/material/material?topTabsActive=4" + "&audioShareId=" + audio_id + "&videoShareId=" + video_id + "&activityId=" + activity_id,
  233. imageUrl: item.AudioShareImg || item.ShareImg,
  234. };
  235. }
  236. },
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. .myCollection-container {
  241. background-color: #f7f7f7;
  242. .collect-ul {
  243. padding: 4rpx 10rpx 20rpx;
  244. .content-item {
  245. background-color: #fff;
  246. margin-top: 20rpx;
  247. padding: 35rpx 20rpx 0;
  248. .item-title {
  249. font-weight: 500;
  250. .item-industry {
  251. margin-left: 10rpx;
  252. color: #3385ff;
  253. display: inline-block;
  254. }
  255. }
  256. .item-user {
  257. display: flex;
  258. align-items: center;
  259. color: #999999;
  260. font-size: 28rpx;
  261. margin-bottom: 20rpx;
  262. image {
  263. width: 23rpx;
  264. height: 26rpx;
  265. margin-right: 20rpx;
  266. }
  267. }
  268. .item-more {
  269. display: flex;
  270. justify-content: space-between;
  271. color: #cecece;
  272. margin: 20rpx 0 0;
  273. padding-bottom: 30rpx;
  274. .pv-ollect {
  275. display: flex;
  276. align-items: center;
  277. width: 40%;
  278. justify-content: space-between;
  279. image {
  280. width: 22rpx;
  281. height: 21rpx;
  282. margin-right: 10rpx;
  283. }
  284. .pv {
  285. height: 16rpx;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. .second-tabs {
  292. position: sticky;
  293. top: 0;
  294. left: 0;
  295. width: 100%;
  296. z-index: 9;
  297. display: flex;
  298. overflow: hidden;
  299. overflow-x: auto;
  300. background-color: #fff;
  301. font-size: 32rpx;
  302. color: #333333;
  303. padding: 20rpx 35rpx;
  304. &::-webkit-scrollbar {
  305. width: 0;
  306. height: 0;
  307. display: none;
  308. }
  309. .item {
  310. position: relative;
  311. padding-bottom: 16rpx;
  312. margin-right: 50rpx;
  313. flex-shrink: 0;
  314. .active {
  315. position: absolute;
  316. left: 0;
  317. bottom: 0;
  318. height: 4rpx;
  319. width: 100%;
  320. border-radius: 1rpx;
  321. background: linear-gradient(90deg, #2e85ff 0%, #7eeaf6 100%);
  322. }
  323. }
  324. .tabs-active {
  325. color: #3385ff;
  326. font-weight: 500;
  327. }
  328. }
  329. .audio-video-content {
  330. display: flex;
  331. flex-wrap: wrap;
  332. justify-content: space-between;
  333. .audio-item {
  334. width: 49%;
  335. }
  336. }
  337. }
  338. </style>