list.vue 14 KB

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