list.vue 16 KB

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