list.vue 16 KB

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