list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. console.log(this.$store)
  158. this.init(options)
  159. this.getPermissionList()
  160. },
  161. onShow(){
  162. //无权限时刷新列表
  163. if(!this.isAuth){
  164. this.getList()
  165. }
  166. },
  167. onHide(){
  168. this.showFilter=false
  169. // this.curVideoId=0
  170. },
  171. onShareAppMessage({from,target}) {
  172. console.log(from,target);
  173. let path='/pages/roadShow/video/list?videoId=0'
  174. let title='FICC线上路演'
  175. let imageUrl=''
  176. if(from=='button'){
  177. title=target.dataset.item.title
  178. path=`/pages/roadShow/video/list?videoId=${target.dataset.item.road_video_id}`
  179. imageUrl=target.dataset.item.cover_img_url
  180. }
  181. return {
  182. title:title,
  183. path:path,
  184. imageUrl:imageUrl
  185. }
  186. },
  187. onPullDownRefresh(){
  188. this.videoId=0
  189. this.noShareData=false
  190. this.selectPerId=0
  191. this.page=1
  192. this.list=[]
  193. this.finished=false
  194. this.getList()
  195. setTimeout(() => {
  196. uni.stopPullDownRefresh()
  197. }, 1500)
  198. },
  199. onReachBottom() {
  200. if(this.finished) return
  201. this.page++
  202. this.getList()
  203. },
  204. methods: {
  205. // 处理弹幕模块需要的数据
  206. getDanmuData(item){
  207. return {
  208. source:2,
  209. id:item.road_video_id,
  210. ...item
  211. }
  212. },
  213. // 处理评论模块需要的数据
  214. getCommentData(item){
  215. return {
  216. source:3,
  217. id:item.road_video_id,
  218. ...item
  219. }
  220. },
  221. async init(options){
  222. if(options.scene){
  223. const resScene=await apiGetSceneToParams({scene_key:options.scene})
  224. if(resScene.code===200){
  225. const obj=JSON.parse(resScene.data)
  226. this.videoId=obj.videoId||0
  227. }
  228. }else{
  229. this.videoId=options.videoId||0
  230. }
  231. this.getList()
  232. },
  233. goSearchPage(){
  234. uni.navigateTo({
  235. url: '/pages-roadShow/video/search',
  236. });
  237. },
  238. change(e){
  239. this.active=e.detail
  240. },
  241. //点击分类某项
  242. handleSelectPerItem(item){
  243. if(this.selectPerId==item.PermissionId){
  244. this.selectPerId=0
  245. }else{
  246. this.selectPerId=item.PermissionId
  247. }
  248. this.videoId=0//重置掉分享进入的状态
  249. this.noShareData=false
  250. this.curVideoId=0
  251. this.page=1
  252. this.list=[]
  253. this.finished=false
  254. this.getList()
  255. this.showFilter=false
  256. },
  257. async getList(){
  258. const res=await apiRoadShowVideoList({
  259. page_index:Number(this.page),
  260. page_size:Number(this.pageSize),
  261. video_id:Number(this.videoId),
  262. chart_permission_id:Number(this.selectPerId)
  263. })
  264. if(res.code===200){
  265. let arr=res.data.list||[]
  266. this.list=[...this.list,...arr]
  267. if(res.data.paging.is_end){
  268. this.finished=true
  269. }
  270. this.isAuth=true
  271. }else if(res.code===403){
  272. //无权限用户
  273. this.isAuth=false
  274. this.noAuthData=res.data
  275. }else if(res.code===4001){
  276. // 用户从分享进入没有这个视频的权限
  277. this.noShareData=true
  278. this.finished=true
  279. }
  280. },
  281. //获取筛选项
  282. async getPermissionList(){
  283. const res=await apiUserBindPermission()
  284. if(res.code===200){
  285. const result = res.data.permission_list||[];
  286. this.options = result.map(item=>{
  287. let obj = {};
  288. obj.ClassifyName = item.classify_name;
  289. obj.Items = item.list.map(_item=>{
  290. return {PermissionId:_item.chart_permission_id,PermissionName:_item.chart_permission_name};
  291. })
  292. return obj;
  293. })
  294. }
  295. },
  296. handelClickPlay(item){
  297. this.curVideoId=item.road_video_id
  298. // 记录播放
  299. apiRoadShowVideoPlayLog({video_id:Number(item.road_video_id)}).then(res=>{
  300. if(res.code===200){
  301. console.log('视频埋点成功');
  302. this.videoRecordId=res.data
  303. }
  304. })
  305. },
  306. //视频播放结束
  307. handleVideoEnd(){
  308. setTimeout(() => {
  309. this.curVideoId=0
  310. }, 200);
  311. },
  312. //时长变化
  313. handleTimeUpdate(e){
  314. // console.log(this.curVideoId,e.detail.currentTime);
  315. this.curVideoTime=e.detail.currentTime
  316. },
  317. handleVideoPause(){
  318. // console.log(`视频 pause---${this.videoRecordId}----${this.curVideoTime}`);
  319. this.handleUpdateVideoPlayTime()
  320. },
  321. // 更新播放时长
  322. handleUpdateVideoPlayTime(){
  323. if(!this.videoRecordId) return
  324. apiViewLogUpdate({
  325. id:this.videoRecordId,
  326. stop_seconds:parseInt(this.curVideoTime),
  327. source:4
  328. }).then(res=>{
  329. console.log('更新播放时长成功');
  330. })
  331. }
  332. },
  333. }
  334. </script>
  335. <style lang='scss'>
  336. .search-wrap .van-search{
  337. padding: 0 !important;
  338. }
  339. .video-list-page{
  340. .filter-wrap{
  341. .van-cell__title, .van-cell__value{
  342. flex: none !important;
  343. }
  344. .van-cell:after{
  345. border: none !important;
  346. }
  347. .van-cell__title{
  348. font-size: 14px;
  349. }
  350. .van-hairline--top:after{
  351. border-top-width: 0 !important;
  352. }
  353. }
  354. }
  355. </style>
  356. <style lang="scss" scoped>
  357. .video-list-page{
  358. .search-wrap {
  359. background-color: #fff;
  360. padding: 30rpx 34rpx;
  361. align-items: center;
  362. .menu-icon{
  363. width: 52rpx;
  364. height: 40rpx;
  365. display: block;
  366. flex-shrink: 0;
  367. margin-left: 30rpx;
  368. }
  369. }
  370. .list-wrap{
  371. .item{
  372. border-top: 10rpx solid #f9f9f9;
  373. padding: 30rpx 34rpx;
  374. position: relative;
  375. .title-box{
  376. margin-right: 110rpx;
  377. }
  378. .share-btn{
  379. position: absolute;
  380. top: 34rpx;
  381. right: 34rpx;
  382. background-color: transparent;
  383. width: 36rpx;
  384. height: 36rpx;
  385. line-height: 1;
  386. padding: 0;
  387. &::after{
  388. border: none;
  389. }
  390. }
  391. .share-img{
  392. width: 32.5rpx;
  393. height: 32rpx;
  394. }
  395. .collect-btn{
  396. right: 96rpx;
  397. }
  398. .tag{
  399. color: #E4B478;
  400. background-color: #333;
  401. padding: 5rpx 20rpx;
  402. border-radius: 20rpx;
  403. font-size: 24rpx;
  404. margin-right: 26rpx;
  405. max-width: 250rpx;
  406. overflow: hidden;
  407. text-overflow: ellipsis;
  408. white-space: nowrap;
  409. display: inline-block;
  410. vertical-align: middle;
  411. }
  412. .title{
  413. font-size: 32rpx;
  414. color: #000;
  415. vertical-align: middle;
  416. }
  417. .video-content{
  418. width: 100%;
  419. height: 400rpx;
  420. margin: 30rpx 0 20rpx 0;
  421. }
  422. .time{
  423. font-size: 28rpx;
  424. color: #999;
  425. display: inline-block;
  426. }
  427. .user-name{
  428. float: right;
  429. font-size: 28rpx;
  430. color: #999;
  431. }
  432. }
  433. }
  434. .empty-box{
  435. text-align: center;
  436. font-size: 32rpx;
  437. color: #999;
  438. padding-top: 150rpx;
  439. image{
  440. width: 80vw;
  441. margin-bottom: 57rpx;
  442. }
  443. }
  444. }
  445. .filter-wrap{
  446. background-color: #fff;
  447. padding-top: 53rpx;
  448. padding-bottom: 100rpx;
  449. .top{
  450. font-size: 32rpx;
  451. justify-content: space-between;
  452. margin-bottom: 40rpx;
  453. padding: 0 34rpx;
  454. }
  455. .list-box{
  456. min-height: 30vh;
  457. max-height: 60vh;
  458. .list-item{
  459. display: block;
  460. margin: 10rpx;
  461. height: 76rpx;
  462. line-height: 76rpx;
  463. color: #000;
  464. background: #F6F6F6;
  465. border-radius: 4px 4px 4px 4px;
  466. text-align: center;
  467. }
  468. .list-item-active{
  469. background-color: #FAEEDE;
  470. }
  471. }
  472. }
  473. </style>