list.vue 16 KB

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