videoList.vue 13 KB

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