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