myCollect.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="my-collect-page">
  3. <view :class="['top-wrap',!(!isSearchRes&&!keywords)?'top-wrap-ptb':'']">
  4. <searchBox placeholder="搜索" @change="onChange" @search="onSearch" />
  5. <view class="tab-box" v-show="!isSearchRes&&!keywords">
  6. <text
  7. :class="['tab-item',active==item.val?'tab-active':'']"
  8. v-for="item in opts"
  9. :key="item.val"
  10. @click="handleChangeOpt(item.val)"
  11. >{{item.name}}</text>
  12. </view>
  13. </view>
  14. <view class="list-wrap">
  15. <view class="item" v-for="(item,index) in list" :key="item.CollectionId">
  16. <view class="c-time">{{item.CreateTime|formatCTime}}</view>
  17. <van-swipe-cell :right-width="90">
  18. <!-- 视频类别样式 -->
  19. <view class="flex video-box" v-if="[2,3].includes(item.CollectionType)" @click="goDetail(item)">
  20. <image class="img" :src="item.ImgUrl" mode="aspectFill" lazy-load="true"/>
  21. <view class="con">
  22. <view class="title" v-html="item.Title"></view>
  23. <view class="author">{{item.Author}}</view>
  24. <view class="time">发布时间:{{item.PublishTime}}</view>
  25. </view>
  26. </view>
  27. <!-- 报告类型样式 -->
  28. <view class="report-box" v-if="item.CollectionType==1" @click="goDetail(item)">
  29. <view class="title" v-html="item.Title"></view>
  30. <view class="con">
  31. <text v-if="item.ClassifyName">#{{item.ClassifyName}}</text>
  32. <text v-if="item.ClassifySecondName" style="margin-left:20rpx">#{{item.ClassifySecondName}}</text>
  33. <view class="time">发布时间:{{item.PublishTime}}</view>
  34. </view>
  35. </view>
  36. <view slot="right" class="cancel-btn" @click="handleCancel(item,index)">取消收藏</view>
  37. </van-swipe-cell>
  38. </view>
  39. </view>
  40. <view class="report-empty-box" v-if="finished&&list.length==0">
  41. <image :src="globalImgUrls.chartEmpty" mode="widthFix" />
  42. <view>暂无相关收藏内容</view>
  43. </view>
  44. <van-dialog id="van-dialog" />
  45. </view>
  46. </template>
  47. <script>
  48. import searchBox from "@/components/searchBox/searchBox.vue";
  49. import {apiMyCollectList,apiCancelCollect} from '@/api/user'
  50. const dayjs=require('@/utils/dayjs.min')
  51. export default {
  52. components: {
  53. searchBox
  54. },
  55. filters: {
  56. formatCTime(e){
  57. if(dayjs().isSame(e,'year')){//当年
  58. return dayjs(e).format('MM-DD')
  59. }else{
  60. return dayjs(e).format('YYYY-MM-DD')
  61. }
  62. }
  63. },
  64. data() {
  65. return {
  66. opts:[
  67. {
  68. name:'全部',
  69. val:0,
  70. },
  71. {
  72. name:'研报',
  73. val:1,
  74. },
  75. {
  76. name:'线上路演',
  77. val:3,
  78. },
  79. {
  80. name:'视频社区',
  81. val:2,
  82. },
  83. ],
  84. active:0,
  85. page:1,
  86. pageSize:20,
  87. finished:false,
  88. list:[],
  89. keywords:'',
  90. isSearchRes:false
  91. }
  92. },
  93. onLoad(){
  94. this.getList()
  95. },
  96. onPullDownRefresh() {
  97. this.keywords=''
  98. this.page=1
  99. this.list=[]
  100. this.finished=false
  101. this.isSearchRes=false
  102. this.getList()
  103. setTimeout(() => {
  104. uni.stopPullDownRefresh()
  105. }, 1500);
  106. },
  107. onReachBottom() {
  108. if(this.finished) return
  109. this.page++
  110. this.getList()
  111. },
  112. methods: {
  113. onChange(e){
  114. this.keywords=e
  115. this.finished=false
  116. this.list=[]
  117. },
  118. onSearch(){
  119. this.active=0
  120. this.page=1
  121. this.finished=false
  122. this.list=[]
  123. if(this.keywords){
  124. this.isSearchRes=true
  125. }else{
  126. this.isSearchRes=false
  127. }
  128. this.getList()
  129. },
  130. handleChangeOpt(e){
  131. this.active=e
  132. this.page=1
  133. this.finished=false
  134. this.list=[]
  135. this.keywords=''
  136. this.isSearchRes=false
  137. this.getList()
  138. },
  139. async getList(){
  140. const res=await apiMyCollectList({
  141. curr_page:this.page,
  142. page_size:this.pageSize,
  143. keywords:this.keywords,
  144. from_type:this.active
  145. })
  146. if(res.code===200){
  147. const arr=res.data.list
  148. this.list=[...this.list,...arr]
  149. this.finished=res.data.paging.is_end
  150. }
  151. },
  152. handleCancel(item,index){
  153. this.$dialog.confirm({
  154. title:'',
  155. message: '确认取消收藏?',
  156. confirmButtonText:'确定'
  157. }).then(()=>{
  158. apiCancelCollect({collection_id:Number(item.CollectionId)}).then(res=>{
  159. if(res.code===200){
  160. uni.showToast({
  161. title:'操作成功',
  162. icon:'none'
  163. })
  164. this.list.splice(index,1)
  165. }
  166. })
  167. }).catch(()=>{})
  168. },
  169. goDetail(item){
  170. if(item.CollectionType==1){// 报告
  171. if(item.ExtendId>0){
  172. uni.navigateTo({url: `/pages-report/chapterDetail?chapterId=${item.ExtendId}`})
  173. }else{
  174. uni.navigateTo({url:'/pages-report/reportDetail?reportId='+item.PrimaryId})
  175. }
  176. }else if(item.CollectionType==2){//视频社区
  177. //跳转tabbar不允许带参数 所以用relaunch
  178. uni.reLaunch({url:'/pages/video/videoList?videoId='+item.PrimaryId})
  179. }else if(item.CollectionType==3){//路演视频
  180. uni.reLaunch({url:'/pages/roadShow/video/list?videoId='+item.PrimaryId})
  181. }
  182. }
  183. },
  184. }
  185. </script>
  186. <style lang="scss">
  187. page{
  188. padding-bottom: constant(safe-area-inset-bottom);
  189. padding-bottom: env(safe-area-inset-bottom);
  190. }
  191. </style>
  192. <style lang="scss" scoped>
  193. .top-wrap{
  194. position: sticky;
  195. top: 0;
  196. left: 0;
  197. right: 0;
  198. z-index: 50;
  199. background-color: #fff;
  200. padding: 40rpx 34rpx 0 34rpx;
  201. box-shadow: 0px 4rpx 4rpx 0px rgba(198,198,198,0.25);
  202. &.top-wrap-ptb{
  203. box-shadow: none;
  204. padding-bottom: 20rpx;
  205. }
  206. .tab-box{
  207. padding-top: 40rpx;
  208. padding-bottom: 10rpx;
  209. .tab-item{
  210. display: inline-block;
  211. margin-right: 60rpx;
  212. color: #666;
  213. font-size: 32rpx;
  214. }
  215. .tab-active{
  216. color: #333;
  217. position: relative;
  218. &::after{
  219. position: absolute;
  220. content: '';
  221. display: block;
  222. width: 36rpx;
  223. height: 6rpx;
  224. background: #E3B377;
  225. border-radius: 3rpx;
  226. bottom: -10rpx;
  227. left: 50%;
  228. transform: translateX(-50%);
  229. }
  230. }
  231. }
  232. }
  233. .list-wrap{
  234. padding: 34rpx;
  235. .item{
  236. padding: 30rpx 0;
  237. border-bottom: 1px solid #E5E5E5;
  238. .c-time{
  239. display: inline-block;
  240. font-size: 28rpx;
  241. padding: 5rpx 10rpx;
  242. color: #666;
  243. background-color: #f6f6f6;
  244. border-radius: 3rpx;
  245. margin-bottom: 12rpx;
  246. }
  247. .video-box{
  248. .img{
  249. width: 231rpx;
  250. height: 134rpx;
  251. flex-shrink: 0;
  252. border-radius: 4rpx;
  253. margin-right: 20rpx;
  254. }
  255. .con{
  256. flex: 1;
  257. }
  258. .title{
  259. font-size: 32rpx;
  260. color: #000;
  261. // min-height: 80rpx;
  262. }
  263. .author{
  264. color: #666;
  265. min-height: 30rpx;
  266. margin: 10rpx 0 20rpx 0;
  267. }
  268. .time{
  269. color: #666;
  270. }
  271. }
  272. .report-box{
  273. .title{
  274. line-height: 1.7;
  275. margin: 12rpx 0;
  276. }
  277. .con{
  278. text{
  279. display: inline-block;
  280. color: #666;
  281. }
  282. .time{
  283. float: right;
  284. }
  285. }
  286. }
  287. .cancel-btn{
  288. position: absolute;
  289. top: 50%;
  290. transform: translateY(-50%);
  291. background: #F3A52F;
  292. border-radius: 25px;
  293. color: #fff;
  294. font-size: 16px;
  295. width: 84px;
  296. text-align: center;
  297. line-height: 30px;
  298. }
  299. }
  300. }
  301. </style>