list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. <view class="video-content">
  56. <videoBox
  57. :videoInfo="getDanmuData(item)"
  58. :curVideoId="curVideoId"
  59. :showDanmu="showDanmu"
  60. @videoPlay="handelClickPlay"
  61. @ended="handleVideoEnd"
  62. @pause="handleVideoPause"
  63. @timeupdate="handleTimeUpdate"
  64. />
  65. </view>
  66. <comment :showDanmu="showDanmu" :videoInfo="getCommentData(item)"></comment>
  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 comment from '@/components/videoComment/comment.vue'
  126. import collectBox from '@/components/collectBox/collectBox.vue'
  127. import videoBox from '@/components/videoBox/videoBox.vue'
  128. export default {
  129. components:{
  130. noAuth,
  131. dragButton,
  132. comment,
  133. collectBox,
  134. videoBox
  135. },
  136. data() {
  137. return {
  138. showFilter:false,
  139. active:'',
  140. options:[],
  141. selectPerId:0,
  142. videoId:0,
  143. page:1,
  144. pageSize:10,
  145. finished:false,
  146. list:[],
  147. curVideoId:0,
  148. curVideoTime:0,
  149. videoRecordId:0,
  150. isAuth:true,
  151. noAuthData:null,
  152. noShareData:false,//用户从分享进入没有该分享的视频的权限
  153. showDanmu:true,//控制整个模块是否显示弹幕功能(没用了本来后台有个开关功能的 后来不要了 但是还是留着吧)
  154. }
  155. },
  156. onLoad(options){
  157. this.init(options)
  158. this.getPermissionList()
  159. },
  160. onShow(){
  161. //无权限时刷新列表
  162. if(!this.isAuth){
  163. this.getList()
  164. }
  165. },
  166. onHide(){
  167. this.showFilter=false
  168. // this.curVideoId=0
  169. },
  170. onShareAppMessage({from,target}) {
  171. console.log(from,target);
  172. let path='/pages/roadShow/video/list?videoId=0'
  173. let title='FICC线上路演'
  174. let imageUrl=''
  175. if(from=='button'){
  176. title=target.dataset.item.title
  177. path=`/pages/roadShow/video/list?videoId=${target.dataset.item.road_video_id}`
  178. imageUrl=target.dataset.item.cover_img_url
  179. }
  180. return {
  181. title:title,
  182. path:path,
  183. imageUrl:imageUrl
  184. }
  185. },
  186. onPullDownRefresh(){
  187. this.videoId=0
  188. this.noShareData=false
  189. this.selectPerId=0
  190. this.page=1
  191. this.list=[]
  192. this.finished=false
  193. this.getList()
  194. setTimeout(() => {
  195. uni.stopPullDownRefresh()
  196. }, 1500)
  197. },
  198. onReachBottom() {
  199. if(this.finished) return
  200. this.page++
  201. this.getList()
  202. },
  203. methods: {
  204. // 处理弹幕模块需要的数据
  205. getDanmuData(item){
  206. return {
  207. source:2,
  208. id:item.road_video_id,
  209. ...item
  210. }
  211. },
  212. // 处理评论模块需要的数据
  213. getCommentData(item){
  214. return {
  215. source:3,
  216. id:item.road_video_id,
  217. ...item
  218. }
  219. },
  220. async init(options){
  221. if(options.scene){
  222. const resScene=await apiGetSceneToParams({scene_key:options.scene})
  223. if(resScene.code===200){
  224. const obj=JSON.parse(resScene.data)
  225. this.videoId=obj.videoId||0
  226. }
  227. }else{
  228. this.videoId=options.videoId||0
  229. }
  230. this.getList()
  231. },
  232. goSearchPage(){
  233. uni.navigateTo({
  234. url: '/pages-roadShow/video/search',
  235. });
  236. },
  237. change(e){
  238. this.active=e.detail
  239. },
  240. //点击分类某项
  241. handleSelectPerItem(item){
  242. if(this.selectPerId==item.PermissionId){
  243. this.selectPerId=0
  244. }else{
  245. this.selectPerId=item.PermissionId
  246. }
  247. this.videoId=0//重置掉分享进入的状态
  248. this.noShareData=false
  249. this.curVideoId=0
  250. this.page=1
  251. this.list=[]
  252. this.finished=false
  253. this.getList()
  254. this.showFilter=false
  255. },
  256. async getList(){
  257. const res=await apiRoadShowVideoList({
  258. page_index:Number(this.page),
  259. page_size:Number(this.pageSize),
  260. video_id:Number(this.videoId),
  261. chart_permission_id:Number(this.selectPerId)
  262. })
  263. if(res.code===200){
  264. let arr=res.data.list||[]
  265. this.list=[...this.list,...arr]
  266. if(res.data.paging.is_end){
  267. this.finished=true
  268. }
  269. this.isAuth=true
  270. }else if(res.code===403){
  271. //无权限用户
  272. this.isAuth=false
  273. this.noAuthData=res.data
  274. }else if(res.code===4001){
  275. // 用户从分享进入没有这个视频的权限
  276. this.noShareData=true
  277. this.finished=true
  278. }
  279. },
  280. //获取筛选项
  281. async getPermissionList(){
  282. const res=await apiUserBindPermission()
  283. if(res.code===200){
  284. const result = res.data.permission_list||[];
  285. this.options = result.map(item=>{
  286. let obj = {};
  287. obj.ClassifyName = item.classify_name;
  288. obj.Items = item.list.map(_item=>{
  289. return {PermissionId:_item.chart_permission_id,PermissionName:_item.chart_permission_name};
  290. })
  291. return obj;
  292. })
  293. }
  294. },
  295. handelClickPlay(item){
  296. this.curVideoId=item.road_video_id
  297. // 记录播放
  298. apiRoadShowVideoPlayLog({video_id:Number(item.road_video_id)}).then(res=>{
  299. if(res.code===200){
  300. console.log('视频埋点成功');
  301. this.videoRecordId=res.data
  302. }
  303. })
  304. },
  305. //视频播放结束
  306. handleVideoEnd(){
  307. setTimeout(() => {
  308. this.curVideoId=0
  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-content{
  417. width: 100%;
  418. height: 400rpx;
  419. margin: 30rpx 0 20rpx 0;
  420. }
  421. .time{
  422. font-size: 28rpx;
  423. color: #999;
  424. display: inline-block;
  425. }
  426. .user-name{
  427. float: right;
  428. font-size: 28rpx;
  429. color: #999;
  430. }
  431. }
  432. }
  433. .empty-box{
  434. text-align: center;
  435. font-size: 32rpx;
  436. color: #999;
  437. padding-top: 150rpx;
  438. image{
  439. width: 80vw;
  440. margin-bottom: 57rpx;
  441. }
  442. }
  443. }
  444. .filter-wrap{
  445. background-color: #fff;
  446. padding-top: 53rpx;
  447. padding-bottom: 100rpx;
  448. .top{
  449. font-size: 32rpx;
  450. justify-content: space-between;
  451. margin-bottom: 40rpx;
  452. padding: 0 34rpx;
  453. }
  454. .list-box{
  455. min-height: 30vh;
  456. max-height: 60vh;
  457. .list-item{
  458. display: block;
  459. margin: 10rpx;
  460. height: 76rpx;
  461. line-height: 76rpx;
  462. color: #000;
  463. background: #F6F6F6;
  464. border-radius: 4px 4px 4px 4px;
  465. text-align: center;
  466. }
  467. .list-item-active{
  468. background-color: #FAEEDE;
  469. }
  470. }
  471. }
  472. </style>