list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="video-list-page" v-if="isAuth">
  3. <van-sticky style="background: #fff">
  4. <view class="flex search-wrap">
  5. <view @click="goSearchPage" style="flex:1;margin-right:30rpx" >
  6. <searchBox
  7. placeholder="关键字搜索"
  8. :hasRightBtn="false"
  9. :disabled="true"
  10. ></searchBox>
  11. </view>
  12. <view class="flex" @click="showFilter=true">
  13. <image style="width:50rpx;height:50rpx" src="@/static/filter-icon.png" mode="aspectFill"/>
  14. <text style="color:#E3B377;font-size:32rpx">筛选</text>
  15. </view>
  16. </view>
  17. </van-sticky>
  18. <view class="empty-box" v-if="list.length==0&&finished">
  19. <image
  20. :src="globalImgUrls.activityNoAuth"
  21. mode="widthFix"
  22. />
  23. <view>暂无数据</view>
  24. </view>
  25. <view class="list-wrap">
  26. <view class="item" v-for="item in list" :key="item.road_video_id">
  27. <view class="title-box">
  28. <text class="tag">{{item.chart_permission_name}}</text>
  29. <text class="title">{{item.title}}</text>
  30. </view>
  31. <button
  32. class="share-btn"
  33. open-type="share"
  34. :data-item="item">
  35. <image class="share-img" src="@/static/share-icon.png" mode="aspectFill"/>
  36. </button>
  37. <video
  38. autoplay
  39. object-fit="contain"
  40. show-mute-btn
  41. :poster="item.cover_img_url"
  42. :src="item.video_url"
  43. enable-play-gesture
  44. :id="item.road_video_id"
  45. @ended="handleVideoEnd"
  46. v-if="item.road_video_id==curVideoId"
  47. ></video>
  48. <image @click="handelClickPlay(item)" v-else class="poster" :src="item.cover_img_url" mode="aspectFill" lazy-load/>
  49. <view class="time">发布时间:{{item.publish_time}}</view>
  50. <view class="user-name">{{item.admin_real_name}}</view>
  51. </view>
  52. </view>
  53. <!-- 筛选 -->
  54. <van-popup
  55. :show="showFilter"
  56. position="bottom"
  57. :safe-area-inset-bottom="true"
  58. round
  59. @close="showFilter=false"
  60. >
  61. <view class="filter-wrap">
  62. <view class="flex top">
  63. <text style="color:#000">全部筛选</text>
  64. <text style="color:#E3B377" @click="showFilter=false">取消</text>
  65. </view>
  66. <view class="list-box">
  67. <van-collapse accordion @change="change" :value="active" :border="false">
  68. <van-collapse-item
  69. :title="item.ClassifyName"
  70. :name='item.ClassifyName'
  71. :border="false"
  72. v-for="item in options"
  73. :key="item.ClassifyName"
  74. >
  75. <van-row gutter="5">
  76. <van-col
  77. :span="_item.PermissionName.length>7?16:8"
  78. v-for="_item in item.Items"
  79. :key="_item.PermissionId"
  80. >
  81. <text
  82. :class="['list-item',_item.PermissionId==selectPerId&&'list-item-active']"
  83. @click="handleSelectPerItem(_item)"
  84. >{{_item.PermissionName}}</text>
  85. </van-col>
  86. </van-row>
  87. </van-collapse-item>
  88. </van-collapse>
  89. </view>
  90. </view>
  91. </van-popup>
  92. <!-- 跳转去提问悬浮按钮 -->
  93. <dragButton :existTabBar="true">
  94. <navigator url="/pages-question/hasQuestion">
  95. <view class="to-question-fixed-box">
  96. <image src="@/static/toquestion-icon.png" mode="widthFix" />
  97. <text>我要提问</text>
  98. </view>
  99. </navigator>
  100. </dragButton>
  101. </view>
  102. <noAuth :info="noAuthData" v-else/>
  103. </template>
  104. <script>
  105. import {apiRoadShowVideoList,apiRoadShowVideoPlayLog} from '@/api/roadShow'
  106. import {apiGetSceneToParams,apiUserBindPermission} from '@/api/common'
  107. import noAuth from './components/noAuth.vue'
  108. import dragButton from '@/components/dragButton/dragButton.vue'
  109. export default {
  110. components:{
  111. noAuth,
  112. dragButton
  113. },
  114. data() {
  115. return {
  116. showFilter:false,
  117. active:'',
  118. options:[],
  119. selectPerId:0,
  120. videoId:0,
  121. page:1,
  122. pageSize:10,
  123. finished:false,
  124. list:[],
  125. curVideoId:0,
  126. curVideoIns:null,
  127. isAuth:true,
  128. noAuthData:null,
  129. }
  130. },
  131. onLoad(options){
  132. this.init(options)
  133. this.getPermissionList()
  134. },
  135. onShow(){
  136. //无权限时刷新列表
  137. if(!this.isAuth){
  138. this.getList()
  139. }
  140. },
  141. onHide(){
  142. this.showFilter=false
  143. this.curVideoId=0
  144. },
  145. onShareAppMessage({from,target}) {
  146. console.log(from,target);
  147. let path='/pages-roadShow/video/list?videoId=0'
  148. let title='FICC路演视频'
  149. let imageUrl=''
  150. if(from=='button'){
  151. title=`${target.dataset.item.chart_permission_name}:${target.dataset.item.title}`
  152. path=`/pages-roadShow/video/list?videoId=${target.dataset.item.road_video_id}`
  153. imageUrl=target.dataset.item.cover_img_url
  154. }
  155. return {
  156. title:title,
  157. path:path,
  158. imageUrl:imageUrl
  159. }
  160. },
  161. onPullDownRefresh(){
  162. this.videoId=0
  163. this.selectPerId=0
  164. this.page=1
  165. this.list=[]
  166. this.finished=false
  167. this.getList()
  168. setTimeout(() => {
  169. uni.stopPullDownRefresh()
  170. }, 1500)
  171. },
  172. onReachBottom() {
  173. if(this.finished) return
  174. this.page++
  175. this.getList()
  176. },
  177. methods: {
  178. async init(options){
  179. if(options.scene){
  180. const resScene=await apiGetSceneToParams({scene_key:options.scene})
  181. if(resScene.code===200){
  182. const obj=JSON.parse(resScene.data)
  183. this.videoId=obj.videoId||0
  184. }
  185. }else{
  186. this.videoId=options.videoId||0
  187. }
  188. this.getList()
  189. },
  190. goSearchPage(){
  191. uni.navigateTo({
  192. url: '/pages-roadShow/video/search',
  193. });
  194. },
  195. change(e){
  196. this.active=e.detail
  197. },
  198. //点击分类某项
  199. handleSelectPerItem(item){
  200. if(this.selectPerId==item.PermissionId){
  201. this.selectPerId=0
  202. }else{
  203. this.selectPerId=item.PermissionId
  204. }
  205. this.videoId=0//重置掉分享进入的状态
  206. this.curVideoId=0
  207. this.page=1
  208. this.list=[]
  209. this.finished=false
  210. this.getList()
  211. this.showFilter=false
  212. },
  213. async getList(){
  214. const res=await apiRoadShowVideoList({
  215. page_index:Number(this.page),
  216. page_size:Number(this.pageSize),
  217. video_id:Number(this.videoId),
  218. chart_permission_id:Number(this.selectPerId)
  219. })
  220. if(res.code===200){
  221. let arr=res.data.list||[]
  222. this.list=[...this.list,...arr]
  223. if(res.data.paging.is_end){
  224. this.finished=true
  225. }
  226. this.isAuth=true
  227. }else if(res.code===403){
  228. //无权限用户
  229. this.isAuth=false
  230. this.noAuthData=res.data
  231. }
  232. },
  233. //获取筛选项
  234. async getPermissionList(){
  235. const res=await apiUserBindPermission()
  236. if(res.code===200){
  237. const result = res.data.permission_list||[];
  238. this.options = result.map(item=>{
  239. let obj = {};
  240. obj.ClassifyName = item.classify_name;
  241. obj.Items = item.list.map(_item=>{
  242. return {PermissionId:_item.chart_permission_id,PermissionName:_item.chart_permission_name};
  243. })
  244. return obj;
  245. })
  246. }
  247. },
  248. handelClickPlay(item){
  249. this.curVideoId=item.road_video_id
  250. setTimeout(() => {
  251. this.curVideoIns=uni.createVideoContext(this.curVideoId.toString())
  252. }, 300);
  253. // 记录播放
  254. apiRoadShowVideoPlayLog({video_id:Number(item.road_video_id)}).then(res=>{
  255. if(res.code===200){
  256. console.log('视频埋点成功');
  257. }
  258. })
  259. },
  260. //视频播放结束
  261. handleVideoEnd(){
  262. // 此处因为如果不调用退出全屏方法 安卓和ios页面均会表现异常,安卓横屏不恢复竖屏,ios底部tabbar渲染异常
  263. this.curVideoIns.exitFullScreen()
  264. setTimeout(() => {
  265. this.curVideoId=0
  266. this.curVideoIns=null
  267. }, 200);
  268. }
  269. },
  270. }
  271. </script>
  272. <style lang='scss'>
  273. .search-wrap .van-search{
  274. padding: 0 !important;
  275. }
  276. .video-list-page{
  277. .filter-wrap{
  278. .van-cell__title, .van-cell__value{
  279. flex: none !important;
  280. }
  281. .van-cell:after{
  282. border: none !important;
  283. }
  284. .van-cell__title{
  285. font-size: 14px;
  286. }
  287. .van-hairline--top:after{
  288. border-top-width: 0 !important;
  289. }
  290. }
  291. }
  292. </style>
  293. <style lang="scss" scoped>
  294. .video-list-page{
  295. .search-wrap {
  296. background-color: #fff;
  297. padding: 30rpx 34rpx;
  298. align-items: center;
  299. .menu-icon{
  300. width: 52rpx;
  301. height: 40rpx;
  302. display: block;
  303. flex-shrink: 0;
  304. margin-left: 30rpx;
  305. }
  306. }
  307. .list-wrap{
  308. .item{
  309. border-top: 10rpx solid #f9f9f9;
  310. padding: 30rpx 34rpx;
  311. position: relative;
  312. .title-box{
  313. padding-right: 40rpx;
  314. }
  315. .share-btn{
  316. position: absolute;
  317. top: 34rpx;
  318. right: 34rpx;
  319. background-color: transparent;
  320. width: 36rpx;
  321. height: 36rpx;
  322. line-height: 1;
  323. padding: 0;
  324. &::after{
  325. border: none;
  326. }
  327. }
  328. .share-img{
  329. width: 32.5rpx;
  330. height: 32rpx;
  331. }
  332. .tag{
  333. color: #E4B478;
  334. background-color: #333;
  335. padding: 5rpx 20rpx;
  336. border-radius: 20rpx;
  337. font-size: 24rpx;
  338. margin-right: 26rpx;
  339. }
  340. .title{
  341. font-size: 32rpx;
  342. color: #000;
  343. }
  344. video{
  345. width: 100%;
  346. height: 400rpx;
  347. margin: 30rpx 0 20rpx 0;
  348. border-radius: 20rpx;
  349. }
  350. .poster{
  351. width: 100%;
  352. height: 400rpx;
  353. margin: 30rpx 0 20rpx 0;
  354. border-radius: 20rpx;
  355. position: relative;
  356. &::after{
  357. content:'';
  358. display: block;
  359. position: absolute;
  360. width: 120rpx;
  361. height: 120rpx;
  362. top: 50%;
  363. left: 50%;
  364. transform: translate(-50%,-50%);
  365. background-image: url('@/static/video-play-btn.png');
  366. background-size: cover;
  367. }
  368. }
  369. .time{
  370. font-size: 28rpx;
  371. color: #999;
  372. display: inline-block;
  373. }
  374. .user-name{
  375. float: right;
  376. font-size: 28rpx;
  377. color: #999;
  378. }
  379. }
  380. }
  381. .empty-box{
  382. text-align: center;
  383. font-size: 32rpx;
  384. color: #999;
  385. padding-top: 150rpx;
  386. image{
  387. width: 80vw;
  388. margin-bottom: 57rpx;
  389. }
  390. }
  391. }
  392. .filter-wrap{
  393. background-color: #fff;
  394. padding-top: 53rpx;
  395. padding-bottom: 100rpx;
  396. .top{
  397. font-size: 32rpx;
  398. justify-content: space-between;
  399. margin-bottom: 40rpx;
  400. padding: 0 34rpx;
  401. }
  402. .list-box{
  403. min-height: 30vh;
  404. max-height: 60vh;
  405. .list-item{
  406. display: block;
  407. margin: 10rpx;
  408. height: 76rpx;
  409. line-height: 76rpx;
  410. color: #000;
  411. background: #F6F6F6;
  412. border-radius: 4px 4px 4px 4px;
  413. text-align: center;
  414. }
  415. .list-item-active{
  416. background-color: #FAEEDE;
  417. }
  418. }
  419. }
  420. </style>