list.vue 15 KB

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