reportList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="report-list-page">
  3. <view class="top-filter-box">
  4. <view class="flex search-wrap">
  5. <view style="flex: 1">
  6. <searchBox
  7. placeholder="请输入报告标题或关键字"
  8. :hasRightBtn="false"
  9. :disabled="false"
  10. :clear="!searchVal"
  11. @change="onChange"
  12. @search="onSearch"
  13. ></searchBox>
  14. </view>
  15. <!-- <view class="filter-box" @click="showFilter=true" v-if="classifyList.length>0">
  16. <image src="./static/filter-icon.png" mode="aspectFill"></image>
  17. <text>筛选</text>
  18. </view> -->
  19. </view>
  20. <view class="tabs-box" v-if="classifyMenuList.length>0">
  21. <text
  22. :class="['sub-nav-item',0===selectClassifyMenu?'active':'']"
  23. @click="handleSelectMenu({menu_id:0,menu_name:'全部'})"
  24. >全部</text>
  25. <text
  26. :class="['sub-nav-item',item.menu_id===selectClassifyMenu?'active':'']"
  27. v-for="item in classifyMenuList"
  28. :key="item.menu_id"
  29. @click="handleSelectMenu(item)"
  30. >{{item.menu_name}}</text>
  31. </view>
  32. </view>
  33. <view class="report-empty-box" v-if="finished&&list.length==0">
  34. <image :src="globalImgUrls.chartEmpty" mode="widthFix" />
  35. <view>{{searchVal?'找不到对应报告,试试别的搜索词吧':'暂无报告'}}</view>
  36. </view>
  37. <view class="report-list-wrap" :style="{paddingBottom:showAudioPop&&'150px'}" v-else>
  38. <view class="flex item" v-for="item in list" :key="item.report_id" @click="goReportDetail(item)">
  39. <image class="img" :src="item.report_img_url" mode="aspectFill" lazy-load />
  40. <view class="con">
  41. <view class="title" v-html="item.title"></view>
  42. <view class="info">
  43. <view v-html="item.classify_name_second" style="display:inline-block"></view>
  44. <text v-if="item.classify_name_second" style="display:inline-block;margin:0 10rpx">&nbsp;·&nbsp;</text>
  45. <text>{{item.stage}}期 | {{item.publish_time|formatReportTime}}</text>
  46. </view>
  47. <view class="audio-box" v-if="item.auth_ok" @click.stop="handleClickAudio(item)">
  48. <image :src="curAudioReportId==item.report_id&&!curAudioPaused?'./static/a-play.png':'./static/a-pause.png'" mode="aspectFill"/>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 筛选 -->
  54. <van-popup :show="showFilter" position="bottom" :safe-area-inset-bottom="false" round @close="showFilter=false">
  55. <view class="filter-wrap" @touchmove.stop>
  56. <view class="flex top">
  57. <text style="color:#000">筛选</text>
  58. <text style="color:#E3B377" @click="showFilter=false">取消</text>
  59. </view>
  60. <view class="list-box">
  61. <van-row gutter="10">
  62. <van-col span="8" v-for="item in classifyList" :key="item.classify_id_second">
  63. <view
  64. :class="['item',item.classify_id_second==selectSecClassifyId&&'active']"
  65. @click="handleSelectSecClassifyId(item)"
  66. >{{item.classify_second_simple}}</view>
  67. </van-col>
  68. </van-row>
  69. </view>
  70. </view>
  71. </van-popup>
  72. <!-- 音频弹窗 -->
  73. <audioBox v-if="showAudioPop"></audioBox>
  74. <!-- 分享海报 -->
  75. <sharePoster
  76. :style="{bottom:'190rpx'}"
  77. :shareData="{
  78. type:'report_list',
  79. code_page:'pages-report/reportList',
  80. code_scene:code_scene,
  81. data:shareParams
  82. }"></sharePoster>
  83. </view>
  84. </template>
  85. <script>
  86. import searchBox from "./components/searchBox.vue";
  87. import audioBox from './components/audioBox.vue'
  88. import sharePoster from '@/components/sharePoster/sharePoster.vue'
  89. import {apiReportList,apiSubClassifyList,apiReportClassifyMenuList} from '@/api/report'
  90. import {apiGetSceneToParams} from '@/api/common'
  91. const dayjs=require('@/utils/dayjs.min')
  92. export default {
  93. computed: {
  94. showAudioPop(){//是否显示音频弹窗
  95. return this.$store.state.report.audioData.show
  96. },
  97. curAudioReportId(){//当前播放的音频所属报告
  98. return this.$store.state.report.audioData.reportId
  99. },
  100. curAudioPaused(){//当前音频是否暂停状态
  101. return this.$store.state.report.audioData.paused
  102. },
  103. shareParams(){
  104. let obj={
  105. list_title:this.classifyName,
  106. img_1:'',
  107. title_1:'',
  108. abstract_1:'',
  109. abstract_1_style:'',
  110. time_1:'',
  111. img_2:'',
  112. title_2:'',
  113. abstract_2:'',
  114. abstract_2_style:'',
  115. time_2:'',
  116. }
  117. if(this.list[0]){
  118. obj.img_1=this.list[0].report_img_url
  119. obj.title_1=this.list[0].title
  120. obj.abstract_1=this.list[0].classify_name_second
  121. obj.time_1=`${this.list[0].stage}期 | ${dayjs(this.list[0].publish_time).format('YYYY.MM.DD')}`
  122. obj.abstract_1_style=this.list[0].classify_name_second?'':'display:none'
  123. }
  124. if(this.list[1]){
  125. obj.img_2=this.list[1].report_img_url
  126. obj.title_2=this.list[1].title
  127. obj.abstract_2=this.list[1].classify_name_second
  128. obj.time_2=`${this.list[1].stage}期 | ${dayjs(this.list[1].publish_time).format('YYYY.MM.DD')}`
  129. obj.abstract_2_style=this.list[1].classify_name_second?'':'display:none'
  130. }
  131. return obj
  132. },
  133. code_scene(){
  134. return JSON.stringify({classifyId:this.classifyId,classifyName:this.classifyName})
  135. }
  136. },
  137. components: {
  138. searchBox,
  139. audioBox
  140. },
  141. data() {
  142. return {
  143. classifyId:0,
  144. classifyName:'',
  145. classifyList:[],
  146. selectSecClassifyId:0,
  147. searchVal: "",
  148. showFilter:false,
  149. list:[],
  150. finished:false,
  151. page:1,
  152. pageSize:20,
  153. classifyMenuList:[],
  154. selectClassifyMenu:0,
  155. };
  156. },
  157. onLoad(options) {
  158. if(options.scene){
  159. this.init(options.scene)
  160. }else{
  161. this.classifyId=options.classifyId
  162. this.classifyName=decodeURIComponent(options.classifyName)
  163. // 设置title
  164. uni.setNavigationBarTitle({ title: decodeURIComponent(options.classifyName) })
  165. this.getList()
  166. // this.getClassifyList()
  167. this.getClassifyMenuList()
  168. }
  169. },
  170. onPullDownRefresh() {
  171. this.page=1
  172. this.list=[]
  173. this.finished=false
  174. this.getList()
  175. // this.getClassifyList()
  176. this.getClassifyMenuList()
  177. setTimeout(() => {
  178. uni.stopPullDownRefresh()
  179. }, 1500);
  180. },
  181. onReachBottom() {
  182. if(this.finished) return
  183. this.page++
  184. this.getList()
  185. },
  186. onShareAppMessage() {
  187. return {
  188. title:`FICC【${this.classifyName}】`
  189. }
  190. },
  191. methods: {
  192. async init(e){
  193. const res=await apiGetSceneToParams({scene_key:e})
  194. if(res.code==200){
  195. const obj=JSON.parse(res.data)
  196. this.classifyId=obj.classifyId
  197. this.classifyName=decodeURIComponent(obj.classifyName)
  198. uni.setNavigationBarTitle({ title: decodeURIComponent(obj.classifyName) })
  199. this.getList()
  200. // this.getClassifyList()
  201. this.getClassifyMenuList()
  202. }
  203. },
  204. //获取研报列表
  205. async getList(){
  206. const res=await apiReportList({
  207. classify_id_first:Number(this.classifyId),
  208. classify_id_second:Number(this.selectSecClassifyId),
  209. classify_menu_id:Number(this.selectClassifyMenu),
  210. key_word:this.searchVal,
  211. current_index:this.page,
  212. page_size:this.pageSize
  213. })
  214. if(res.code===200){
  215. let arr=res.data.list||[]
  216. this.list=[...this.list,...arr]
  217. if(res.data.paging.is_end){
  218. this.finished=true
  219. }
  220. }
  221. },
  222. // 获取子目录
  223. async getClassifyMenuList(){
  224. const res=await apiReportClassifyMenuList({classify_id:Number(this.classifyId)})
  225. if(res.code===200){
  226. this.classifyMenuList=res.data||[]
  227. }
  228. },
  229. handleSelectMenu(item){
  230. if(item.menu_id==this.selectClassifyMenu) return
  231. this.selectClassifyMenu=item.menu_id
  232. this.searchVal=''
  233. this.page=1
  234. this.finished=false
  235. this.list=[]
  236. this.getList()
  237. },
  238. //分类数据(需求修改 不要这种筛选了 换成后台配置的子目录去筛选)
  239. async getClassifyList(){
  240. const res=await apiSubClassifyList({classify_id_first:Number(this.classifyId)})
  241. if(res.code===200){
  242. this.classifyList=res.data
  243. }
  244. },
  245. handleSelectSecClassifyId(item){
  246. if(this.selectSecClassifyId==item.classify_id_second){
  247. this.selectSecClassifyId=''
  248. }else{
  249. this.selectSecClassifyId=item.classify_id_second
  250. }
  251. this.showFilter=false
  252. this.page=1
  253. this.finished=false
  254. this.list=[]
  255. this.getList()
  256. },
  257. onChange(e) {
  258. this.searchVal = e;
  259. },
  260. onSearch() {
  261. console.log("搜索", this.searchVal);
  262. this.page=1
  263. this.finished=false
  264. this.list=[]
  265. this.getList()
  266. },
  267. goReportDetail(item){
  268. if(['晨报','周报'].includes(item.classify_name_first)){
  269. uni.navigateTo({ url: '/pages-report/chapterList?reportId='+item.report_id })
  270. return
  271. }
  272. uni.navigateTo({ url: '/pages-report/reportDetail?reportId='+item.report_id })
  273. },
  274. handleClickAudio(item){
  275. if(!item.auth_ok) return
  276. if(!item.video_list||item.video_list.length==0){
  277. uni.showToast({
  278. title: '暂无音频',
  279. icon: 'none'
  280. })
  281. return
  282. }
  283. // 判断是否为同一个音频
  284. if(this.$store.state.report.audioData.reportId==item.report_id){
  285. if(this.globalBgMusic.paused){
  286. this.globalBgMusic.play()
  287. this.$store.commit('showPopAudio')
  288. }else{
  289. this.globalBgMusic.pause()
  290. }
  291. }else{
  292. this.$store.commit('addAudio', {list:item.video_list,reportId:item.report_id})
  293. }
  294. },
  295. // 跳转搜索
  296. goSearch(){
  297. uni.navigateTo({
  298. url:`/pages-report/reportListSearch?classify_id_first=${this.classifyId}&classifyName=${this.classifyName}`
  299. })
  300. }
  301. },
  302. };
  303. </script>
  304. <style>
  305. page{
  306. padding-bottom: constant(safe-area-inset-bottom);
  307. padding-bottom: env(safe-area-inset-bottom);
  308. }
  309. </style>
  310. <style lang="scss" scoped>
  311. .top-filter-box{
  312. background-color: white;
  313. position: sticky;
  314. top: 0;
  315. left: 0;
  316. z-index: 99;
  317. .tabs-box{
  318. box-shadow: 0px 4rpx 4rpx 0px rgba(198,198,198,0.2500);
  319. overflow-x: auto;
  320. white-space: nowrap;
  321. padding: 0 34rpx 16rpx 34rpx;
  322. &::-webkit-scrollbar{
  323. width: 0;
  324. height: 0;
  325. display: none;
  326. }
  327. .sub-nav-item{
  328. display: inline-block;
  329. position: relative;
  330. margin-right: 50rpx;
  331. font-size: 28rpx;
  332. color: #666;
  333. position: relative;
  334. &.active{
  335. color: #E3B377;
  336. &::after{
  337. content: '';
  338. display: block;
  339. width: 54rpx;
  340. height: 4rpx;
  341. background-color: #E3B377;
  342. position: absolute;
  343. bottom: -16rpx;
  344. left: 50%;
  345. transform: translateX(-50%);
  346. }
  347. }
  348. }
  349. }
  350. }
  351. .search-wrap {
  352. background-color: #fff;
  353. padding: 30rpx 34rpx 16rpx 34rpx;
  354. align-items: center;
  355. .filter-box {
  356. margin-left: 20rpx;
  357. image {
  358. width: 52rpx;
  359. height: 52rpx;
  360. vertical-align: middle;
  361. }
  362. text {
  363. vertical-align: middle;
  364. color: #e3b377;
  365. font-size: 32rpx;
  366. }
  367. }
  368. }
  369. .report-list-wrap {
  370. padding: 34rpx 34rpx 0 34rpx;
  371. .item{
  372. margin-bottom: 30rpx;
  373. position: relative;
  374. .img{
  375. width: 90rpx;
  376. height: 120rpx;
  377. background-color: #f5f5f5;
  378. border-radius: 8rpx;
  379. overflow: hidden;
  380. margin-right: 19rpx;
  381. flex-shrink: 0;
  382. }
  383. .con{
  384. padding-right: 100rpx;
  385. flex: 1;
  386. }
  387. .title{
  388. font-size: 28rpx;
  389. font-weight: bold;
  390. margin-bottom: 10rpx;
  391. min-height: 70rpx;
  392. }
  393. .info{
  394. font-size: 24rpx;
  395. color: #9C9791;
  396. }
  397. .audio-box{
  398. position: absolute;
  399. top: 50%;
  400. transform: translateY(-50%);
  401. width: 22px;
  402. height: 20px;
  403. background: linear-gradient(180deg, #F3A52F 0%, #E3B377 100%);
  404. border-radius: 6px;
  405. right: 20rpx;
  406. text-align: center;
  407. image{
  408. width: 12px;
  409. height: 12px;
  410. position: relative;
  411. top: 1px;
  412. }
  413. }
  414. }
  415. }
  416. .filter-wrap{
  417. background-color: #fff;
  418. padding-top: 53rpx;
  419. .top{
  420. font-size: 32rpx;
  421. justify-content: space-between;
  422. margin-bottom: 40rpx;
  423. padding: 0 34rpx;
  424. }
  425. .list-box{
  426. min-height: 30vh;
  427. max-height: 60vh;
  428. overflow-y: auto;
  429. padding: 0 34rpx;
  430. .item{
  431. background-color: #F6F6F6;
  432. color: #000000;
  433. // text-align: center;
  434. height: 76rpx;
  435. overflow: hidden;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. // line-height: 76rpx;
  440. margin-bottom: 20rpx;
  441. }
  442. .active{
  443. background-color: #FAEEDE;
  444. }
  445. }
  446. }
  447. </style>