reportListSearch.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="report-list-page">
  3. <van-sticky style="background: #fff">
  4. <view style="padding:30rpx 34rpx;background: #fff">
  5. <searchBox
  6. :focus="focus"
  7. placeholder="请输入报告标题或关键字"
  8. @change="onChange"
  9. @search="onSearch"
  10. ></searchBox>
  11. </view>
  12. </van-sticky>
  13. <view class="report-empty-box" v-if="finished&&list.length==0">
  14. <image :src="globalImgUrls.chartEmpty" mode="widthFix" />
  15. <view>找不到对应报告,试试别的搜索词吧</view>
  16. </view>
  17. <view class="report-list-wrap" :style="{paddingBottom:showAudioPop&&'90px'}" v-else>
  18. <view class="flex item" v-for="item in list" :key="item.report_id" @click="goReportDetail(item)">
  19. <image class="img" :src="item.report_img_url" mode="aspectFill" lazy-load />
  20. <view class="con">
  21. <view class="title" v-html="item.title"></view>
  22. <view class="info" v-html="item.classify_name_second"></view>
  23. <view class="time">{{item.stage}}期 | {{item.publish_time|formatReportTime}}</view>
  24. <view :class="['audio-box',!item.auth_ok&&'grey-audio-box']" @click.stop="handleClickAudio(item)" v-if="item.auth_ok">
  25. <image :src="curAudioReportId==item.report_id&&!curAudioPaused?'./static/audio-s.png':'./static/audio.png'" mode="aspectFill"/>
  26. <text>{{curAudioReportId==item.report_id&&!curAudioPaused?'暂停':'播放'}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 音频弹窗 -->
  32. <audioBox v-if="showAudioPop"></audioBox>
  33. </view>
  34. </template>
  35. <script>
  36. import searchBox from "./components/searchBox.vue";
  37. import audioBox from './components/audioBox.vue'
  38. import {apiReportList} from '@/api/report'
  39. export default {
  40. computed: {
  41. showAudioPop(){//是否显示音频弹窗
  42. return this.$store.state.report.audioData.show
  43. },
  44. curAudioReportId(){//当前播放的音频所属报告
  45. return this.$store.state.report.audioData.reportId
  46. },
  47. curAudioPaused(){//当前音频是否暂停状态
  48. return this.$store.state.report.audioData.paused
  49. }
  50. },
  51. components: {
  52. searchBox,
  53. audioBox
  54. },
  55. data() {
  56. return {
  57. classify_id_first:0,
  58. classifyName:'',
  59. searchVal: "",
  60. focus:true,
  61. list:[],
  62. finished:false,
  63. page:1,
  64. pageSize:20
  65. };
  66. },
  67. onLoad(options) {
  68. this.classify_id_first=options.classify_id_first
  69. this.classifyName=decodeURIComponent(options.classifyName)
  70. // 设置title
  71. uni.setNavigationBarTitle({ title: decodeURIComponent(options.classifyName) })
  72. },
  73. onReachBottom() {
  74. if(this.finished) return
  75. this.page++
  76. this.getList()
  77. },
  78. methods: {
  79. //获取研报列表
  80. async getList(){
  81. const res=await apiReportList({
  82. classify_id_first:Number(this.classify_id_first),
  83. classify_id_second:0,
  84. key_word:this.searchVal,
  85. current_index:this.page,
  86. page_size:this.pageSize
  87. })
  88. if(res.code===200){
  89. let arr=res.data.list||[]
  90. this.list=[...this.list,...arr]
  91. if(res.data.paging.is_end){
  92. this.finished=true
  93. }
  94. }
  95. },
  96. onChange(e) {
  97. this.searchVal = e;
  98. },
  99. onSearch() {
  100. console.log("搜索", this.searchVal);
  101. this.page=1
  102. this.finished=false
  103. this.list=[]
  104. if(!this.searchVal) return
  105. this.getList()
  106. },
  107. goReportDetail(item){
  108. uni.navigateTo({ url: '/pages-report/reportDetail?reportId='+item.report_id })
  109. },
  110. handleClickAudio(item){
  111. if(!item.auth_ok) return
  112. if(!item.video_list||item.video_list.length==0){
  113. uni.showToast({
  114. title: '暂无音频',
  115. icon: 'none'
  116. })
  117. return
  118. }
  119. // 判断是否为同一个音频
  120. if(this.$store.state.report.audioData.reportId==item.report_id){
  121. if(this.globalBgMusic.paused){
  122. this.globalBgMusic.play()
  123. this.$store.commit('showPopAudio')
  124. }else{
  125. this.globalBgMusic.pause()
  126. }
  127. }else{
  128. this.$store.commit('addAudio', {list:item.video_list,reportId:item.report_id})
  129. }
  130. },
  131. }
  132. }
  133. </script>
  134. <style>
  135. page{
  136. padding-bottom: 0;
  137. }
  138. </style>
  139. <style lang="scss" scoped>
  140. .report-list-wrap {
  141. padding: 0 34rpx;
  142. .item {
  143. padding-bottom: 30rpx;
  144. margin-bottom: 30rpx;
  145. border-bottom: 1px solid #EDEDED;
  146. .img {
  147. width: 120rpx;
  148. height: 160rpx;
  149. background-color: #f5f5f5;
  150. flex-shrink: 0;
  151. margin-right: 20rpx;
  152. border-radius: 16rpx;
  153. }
  154. .con {
  155. flex: 1;
  156. position: relative;
  157. overflow: hidden;
  158. .title {
  159. font-size: 32rpx;
  160. font-weight: bold;
  161. margin-bottom: 8rpx;
  162. }
  163. .time {
  164. position: absolute;
  165. color: #666666;
  166. bottom: 0;
  167. left: 0;
  168. font-size: 28rpx;
  169. }
  170. .audio-box {
  171. position: absolute;
  172. bottom: 0;
  173. right: 0;
  174. width: 99rpx;
  175. height: 39rpx;
  176. background: #E3B377;
  177. border-radius: 20rpx;
  178. color: #fff;
  179. font-size: 24rpx;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. image{
  184. width: 30rpx;
  185. height: 30rpx;
  186. margin-right: 4rpx;
  187. }
  188. }
  189. .grey-audio-box {
  190. background: linear-gradient(114deg, #b0b0b0 0%, #e5e2e2 100%);
  191. }
  192. }
  193. }
  194. }
  195. </style>