reportList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <view class="report-list-page">
  3. <van-sticky style="background: #fff">
  4. <view class="flex search-wrap">
  5. <searchBox style="flex: 1" :focus="focus" placeholder="请输入报告标题或关键字" :hasRightBtn="false" @change="onChange" @search="onSearch"></searchBox>
  6. <view class="filter-box" @click="showFilter=true" v-if="classifyList.length>0">
  7. <image src="./static/filter-icon.png" mode="aspectFill"></image>
  8. <text>筛选</text>
  9. </view>
  10. </view>
  11. </van-sticky>
  12. <view class="report-empty-box" v-if="finished&&list.length==0">
  13. <image :src="globalImgUrls.chartEmpty" mode="widthFix" />
  14. <view>{{searchVal?'找不到对应报告,试试别的搜索词吧':'暂无报告'}}</view>
  15. </view>
  16. <view class="report-list-wrap" :style="{paddingBottom:showAudioPop&&'90px'}" v-else>
  17. <view class="flex item" v-for="item in list" :key="item.report_id" @click="goReportDetail(item)">
  18. <image class="img" :src="item.report_img_url" mode="aspectFill" lazy-load />
  19. <view class="con">
  20. <view class="title" v-html="item.title"></view>
  21. <view class="info" v-html="item.classify_name_second"></view>
  22. <view class="time">{{item.stage}}期 | {{item.publish_time|formatReportTime}}</view>
  23. <view :class="['audio-box',!item.auth_ok&&'grey-audio-box']" @click.stop="handleClickAudio(item)" v-if="item.auth_ok">
  24. <image :src="curAudioReportId==item.report_id&&!curAudioPaused?'./static/audio-s.png':'./static/audio.png'" mode="aspectFill"/>
  25. <text>{{curAudioReportId==item.report_id&&!curAudioPaused?'暂停':'播放'}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 筛选 -->
  31. <van-popup :show="showFilter" position="bottom" :safe-area-inset-bottom="false" round @close="showFilter=false">
  32. <view class="filter-wrap">
  33. <view class="flex top">
  34. <text style="color:#000">筛选</text>
  35. <text style="color:#E3B377" @click="showFilter=false">取消</text>
  36. </view>
  37. <view class="list-box">
  38. <van-row gutter="10">
  39. <van-col span="8" v-for="item in classifyList" :key="item.classify_id_second">
  40. <view
  41. :class="['item',item.classify_id_second==selectSecClassifyId&&'active']"
  42. @click="handleSelectSecClassifyId(item)"
  43. >{{item.classify_second_simple}}</view>
  44. </van-col>
  45. </van-row>
  46. </view>
  47. </view>
  48. </van-popup>
  49. <!-- 音频弹窗 -->
  50. <audioBox v-if="showAudioPop"></audioBox>
  51. <!-- 分享海报 -->
  52. <sharePoster
  53. :style="{bottom:'140rpx'}"
  54. :shareData="{
  55. type:'report_list',
  56. code_page:'pages-report/reportList',
  57. code_scene:code_scene,
  58. data:shareParams
  59. }"></sharePoster>
  60. </view>
  61. </template>
  62. <script>
  63. import searchBox from "./components/searchBox.vue";
  64. import audioBox from './components/audioBox.vue'
  65. import sharePoster from '@/components/sharePoster/sharePoster.vue'
  66. import {apiReportList,apiSubClassifyList} from '@/api/report'
  67. import {apiGetSceneToParams} from '@/api/common'
  68. const moment=require('@/utils/moment-with-locales.min')
  69. export default {
  70. computed: {
  71. showAudioPop(){//是否显示音频弹窗
  72. return this.$store.state.report.audioData.show
  73. },
  74. curAudioReportId(){//当前播放的音频所属报告
  75. return this.$store.state.report.audioData.reportId
  76. },
  77. curAudioPaused(){//当前音频是否暂停状态
  78. return this.$store.state.report.audioData.paused
  79. },
  80. shareParams(){
  81. let obj={
  82. list_title:this.classifyName,
  83. img_1:'',
  84. title_1:'',
  85. abstract_1:'',
  86. time_1:'',
  87. img_2:'',
  88. title_2:'',
  89. abstract_2:'',
  90. time_2:'',
  91. }
  92. if(this.list[0]){
  93. obj.img_1=this.list[0].report_img_url
  94. obj.title_1=this.list[0].title
  95. obj.abstract_1=this.list[0].classify_name_second
  96. obj.time_1=`${this.list[0].stage}期 | ${moment(this.list[0].publish_time).format('YYYY.MM.DD')}`
  97. }
  98. if(this.list[1]){
  99. obj.img_2=this.list[1].report_img_url
  100. obj.title_2=this.list[1].title
  101. obj.abstract_2=this.list[1].classify_name_second
  102. obj.time_2=`${this.list[1].stage}期 | ${moment(this.list[1].publish_time).format('YYYY.MM.DD')}`
  103. }
  104. return obj
  105. },
  106. code_scene(){
  107. return JSON.stringify({classifyId:this.classifyId,classifyName:this.classifyName})
  108. }
  109. },
  110. components: {
  111. searchBox,
  112. audioBox
  113. },
  114. data() {
  115. return {
  116. classifyId:0,
  117. classifyName:'',
  118. classifyList:[],
  119. selectSecClassifyId:0,
  120. searchVal: "",
  121. showFilter:false,
  122. list:[],
  123. finished:false,
  124. page:1,
  125. pageSize:20
  126. };
  127. },
  128. onLoad(options) {
  129. if(options.scene){
  130. this.init(options.scene)
  131. }else{
  132. this.classifyId=options.classifyId
  133. this.classifyName=decodeURIComponent(options.classifyName)
  134. // 设置title
  135. uni.setNavigationBarTitle({ title: decodeURIComponent(options.classifyName) })
  136. this.getList()
  137. this.getClassifyList()
  138. }
  139. },
  140. onPullDownRefresh() {
  141. this.page=1
  142. this.list=[]
  143. this.finished=false
  144. this.getList()
  145. this.getClassifyList()
  146. setTimeout(() => {
  147. uni.stopPullDownRefresh()
  148. }, 1500);
  149. },
  150. onReachBottom() {
  151. if(this.finished) return
  152. this.page++
  153. this.getList()
  154. },
  155. onShareAppMessage() {
  156. return {
  157. title:`FICC【${this.classifyName}】`
  158. }
  159. },
  160. methods: {
  161. async init(e){
  162. const res=await apiGetSceneToParams({scene_key:e})
  163. if(res.code==200){
  164. const obj=JSON.parse(res.data)
  165. this.classifyId=obj.classifyId
  166. this.classifyName=decodeURIComponent(obj.classifyName)
  167. uni.setNavigationBarTitle({ title: decodeURIComponent(obj.classifyName) })
  168. this.getList()
  169. this.getClassifyList()
  170. }
  171. },
  172. //获取研报列表
  173. async getList(){
  174. const res=await apiReportList({
  175. classify_id_first:Number(this.classifyId),
  176. classify_id_second:Number(this.selectSecClassifyId),
  177. key_word:this.searchVal,
  178. current_index:this.page,
  179. page_size:this.pageSize
  180. })
  181. if(res.code===200){
  182. let arr=res.data.list||[]
  183. this.list=[...this.list,...arr]
  184. if(res.data.paging.is_end){
  185. this.finished=true
  186. }
  187. }
  188. },
  189. //分类数据
  190. async getClassifyList(){
  191. const res=await apiSubClassifyList({classify_id_first:Number(this.classifyId)})
  192. if(res.code===200){
  193. this.classifyList=res.data
  194. }
  195. },
  196. handleSelectSecClassifyId(item){
  197. if(this.selectSecClassifyId==item.classify_id_second){
  198. this.selectSecClassifyId=''
  199. }else{
  200. this.selectSecClassifyId=item.classify_id_second
  201. }
  202. this.showFilter=false
  203. this.page=1
  204. this.finished=false
  205. this.list=[]
  206. this.getList()
  207. },
  208. onChange(e) {
  209. this.searchVal = e;
  210. },
  211. onSearch() {
  212. console.log("搜索", this.searchVal);
  213. this.page=1
  214. this.finished=false
  215. this.list=[]
  216. this.getList()
  217. },
  218. goReportDetail(item){
  219. uni.navigateTo({ url: '/pages-report/reportDetail?reportId='+item.report_id })
  220. },
  221. handleClickAudio(item){
  222. if(!item.auth_ok) return
  223. if(!item.video_list||item.video_list.length==0){
  224. uni.showToast({
  225. title: '暂无音频',
  226. icon: 'none'
  227. })
  228. return
  229. }
  230. // 判断是否为同一个音频
  231. if(this.$store.state.report.audioData.reportId==item.report_id){
  232. if(this.globalBgMusic.paused){
  233. this.globalBgMusic.play()
  234. }else{
  235. this.globalBgMusic.pause()
  236. }
  237. }else{
  238. this.$store.commit('addAudio', {list:item.video_list,reportId:item.report_id})
  239. }
  240. }
  241. },
  242. };
  243. </script>
  244. <style>
  245. page{
  246. padding-bottom: 0;
  247. }
  248. </style>
  249. <style lang="scss" scoped>
  250. .search-wrap {
  251. background-color: #fff;
  252. padding: 30rpx 34rpx;
  253. align-items: center;
  254. .filter-box {
  255. margin-left: 20rpx;
  256. image {
  257. width: 52rpx;
  258. height: 52rpx;
  259. vertical-align: middle;
  260. }
  261. text {
  262. vertical-align: middle;
  263. color: #e3b377;
  264. font-size: 32rpx;
  265. }
  266. }
  267. }
  268. .report-list-wrap {
  269. padding: 0 34rpx;
  270. .item {
  271. padding-bottom: 30rpx;
  272. margin-bottom: 30rpx;
  273. border-bottom: 1px solid #EDEDED;
  274. .img {
  275. width: 120rpx;
  276. height: 180rpx;
  277. background-color: #f5f5f5;
  278. flex-shrink: 0;
  279. margin-right: 20rpx;
  280. border-radius: 16rpx;
  281. }
  282. .con {
  283. flex: 1;
  284. position: relative;
  285. overflow: hidden;
  286. .title {
  287. font-size: 32rpx;
  288. font-weight: bold;
  289. margin-bottom: 8rpx;
  290. }
  291. .time {
  292. position: absolute;
  293. color: #666666;
  294. bottom: 0;
  295. left: 0;
  296. font-size: 28rpx;
  297. }
  298. .audio-box {
  299. position: absolute;
  300. bottom: 0;
  301. right: 0;
  302. width: 99rpx;
  303. height: 39rpx;
  304. background: #E3B377;
  305. border-radius: 20rpx;
  306. color: #fff;
  307. font-size: 24rpx;
  308. display: flex;
  309. justify-content: center;
  310. align-items: center;
  311. image{
  312. width: 30rpx;
  313. height: 30rpx;
  314. margin-right: 4rpx;
  315. }
  316. }
  317. .grey-audio-box {
  318. background: linear-gradient(114deg, #b0b0b0 0%, #e5e2e2 100%);
  319. }
  320. }
  321. }
  322. }
  323. .filter-wrap{
  324. background-color: #fff;
  325. padding-top: 53rpx;
  326. .top{
  327. font-size: 32rpx;
  328. justify-content: space-between;
  329. margin-bottom: 40rpx;
  330. padding: 0 34rpx;
  331. }
  332. .list-box{
  333. min-height: 30vh;
  334. max-height: 60vh;
  335. overflow-y: auto;
  336. padding: 0 34rpx;
  337. .item{
  338. background-color: #F6F6F6;
  339. color: #000000;
  340. // text-align: center;
  341. height: 76rpx;
  342. overflow: hidden;
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. // line-height: 76rpx;
  347. margin-bottom: 20rpx;
  348. }
  349. .active{
  350. background-color: #FAEEDE;
  351. }
  352. }
  353. }
  354. </style>