list.vue 15 KB

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