123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 |
- <template>
- <view class="video-list-page" v-if="isAuth">
- <van-sticky style="background: #fff">
- <view class="flex search-wrap">
- <view @click="goSearchPage" style="flex:1;margin-right:30rpx" >
- <searchBox
- placeholder="关键字搜索"
- :hasRightBtn="false"
- :disabled="true"
- ></searchBox>
- </view>
- <view class="flex" @click="showFilter=true">
- <image style="width:50rpx;height:50rpx" src="@/static/filter-icon.png" mode="aspectFill"/>
- <text style="color:#E3B377;font-size:32rpx">筛选</text>
- </view>
- </view>
- </van-sticky>
- <view class="empty-box" v-if="list.length==0&&finished">
- <image
- :src="globalImgUrls.activityNoAuth"
- mode="widthFix"
- />
- <view v-if="videoId">
- <view>该视频不存在</view>
- <view>请刷新页面后重试</view>
- </view>
- <view v-else>暂无数据</view>
- </view>
- <view class="list-wrap">
- <view class="item" v-for="item in list" :key="item.community_video_id">
- <view class="title-box">
- <text class="tag">{{item.variety_tag_name}}</text>
- <text class="title">{{item.title}}</text>
- </view>
- <collectBox
- :type="2"
- :primaryId="item.community_video_id"
- :collectId="item.collection_id"
- class="share-btn collect-btn"
- />
- <button
- class="share-btn"
- open-type="share"
- :data-item="item">
- <image class="share-img" src="@/static/share-icon.png" mode="aspectFill"/>
- </button>
- <view class="time">发布时间:{{item.publish_time}}</view>
- <view class="video-content">
- <videoBox
- :videoInfo="getDanmuData(item)"
- :curVideoId="curVideoId"
- :showDanmu="showDanmu"
- @videoPlay="handelClickPlay"
- @ended="handleVideoEnd"
- @pause="handleVideoPause"
- @timeupdate="handleTimeUpdate"
- />
- </view>
- <comment :showDanmu="showDanmu" :videoInfo="getCommentData(item)"></comment>
- </view>
- </view>
- <!-- 筛选 -->
- <van-popup
- :show="showFilter"
- position="bottom"
- :safe-area-inset-bottom="true"
- round
- @close="showFilter=false"
- >
- <view class="filter-wrap" @touchmove.stop>
- <view class="flex top">
- <text style="color:#000">全部筛选</text>
- <text style="color:#E3B377" @click="showFilter=false">取消</text>
- </view>
- <view class="list-box">
- <van-collapse accordion @change="change" :value="active" :border="false">
- <van-collapse-item
- :title="item.ClassifyName"
- :name='item.ClassifyName'
- :border="false"
- v-for="item in options"
- :key="item.ClassifyName"
- >
- <van-row gutter="5">
- <van-col
- :span="_item.PermissionName.length>7?16:8"
- v-for="_item in item.Items"
- :key="_item.PermissionId"
- >
- <text
- :class="['list-item',_item.PermissionId==selectPerId&&'list-item-active']"
- @click="handleSelectPerItem(_item)"
- >{{_item.PermissionName}}</text>
- </van-col>
- </van-row>
- </van-collapse-item>
- </van-collapse>
- </view>
- </view>
- </van-popup>
- <!-- 跳转去提问悬浮按钮 -->
- <dragButton :existTabBar="true">
- <navigator url="/pages-question/hasQuestion">
- <view class="to-question-fixed-box">
- <image src="@/static/toquestion-icon.png" mode="widthFix" />
- <text>我要提问</text>
- </view>
- </navigator>
- </dragButton>
- </view>
- <noAuth :info="noAuthData" v-else/>
- </template>
- <script>
- import {apiVideoList,apiVideoPlayLog} from '@/api/video'
- import {apiOptionList} from '@/api/question'
- import {apiGetSceneToParams,apiGetTagTree,apiViewLogUpdate} from '@/api/common'
- import noAuth from './components/noAuth.vue'
- import dragButton from '@/components/dragButton/dragButton.vue'
- import comment from '@/components/videoComment/comment.vue'
- import collectBox from '@/components/collectBox/collectBox.vue'
- import videoBox from '@/components/videoBox/videoBox.vue'
- export default {
- components:{
- noAuth,
- comment,
- dragButton,
- collectBox,
- videoBox
- },
- data() {
- return {
- showFilter:false,
- active:'',
- options:[],
- selectPerId:0,
- videoId:0,
- page:1,
- pageSize:10,
- finished:false,
- list:[],
- curVideoId:0,
- curVideoTime:0,
- videoRecordId:0,
- isAuth:true,
- noAuthData:null,
- showDanmu:true,//控制整个模块是否显示弹幕功能(没用了本来后台有个开关功能的 后来不要了 但是还是留着吧)
- }
- },
- onLoad(options){
- this.init(options)
- this.getPermissionList()
- },
- onShow(){
- //无权限时刷新列表
- if(!this.isAuth){
- this.getList()
- }
- },
- onHide(){
- this.showFilter=false
- },
- onShareAppMessage({from,target}) {
- console.log(from,target);
- let path='/pages/video/videoList?videoId=0'
- let title='FICC视频社区'
- let imageUrl=''
- if(from=='button'){
- title=`${target.dataset.item.chart_permission_name}:${target.dataset.item.title}`
- path=`/pages/video/videoList?videoId=${target.dataset.item.community_video_id}`
- imageUrl=target.dataset.item.cover_img_url
- }
- return {
- title:title,
- path:path,
- imageUrl:imageUrl
- }
- },
- onPullDownRefresh(){
- this.videoId=0
- this.selectPerId=0
- this.page=1
- this.list=[]
- this.finished=false
- this.getList()
- setTimeout(() => {
- uni.stopPullDownRefresh()
- }, 1500)
- },
- onReachBottom() {
- if(this.finished) return
- this.page++
- this.getList()
- },
- methods: {
- // 处理弹幕模块需要的数据
- getDanmuData(item){
- return {
- source:1,
- id:item.community_video_id,
- ...item
- }
- },
- // 处理评论模块需要的数据
- getCommentData(item){
- return {
- source:2,
- id:item.community_video_id,
- ...item
- }
- },
- async init(options){
- if(options.scene){
- const resScene=await apiGetSceneToParams({scene_key:options.scene})
- if(resScene.code===200){
- const obj=JSON.parse(resScene.data)
- this.videoId=obj.videoId||0
- }
- }else{
- this.videoId=options.videoId||0
- }
- this.getList()
- },
- goSearchPage(){
- uni.navigateTo({
- url: '/pages/video/videoSearch',
- });
- },
- change(e){
- this.active=e.detail
- },
- //点击分类某项
- handleSelectPerItem(item){
- if(this.selectPerId==item.PermissionId){
- this.selectPerId=0
- }else{
- this.selectPerId=item.PermissionId
- }
-
- this.videoId=0//重置掉分享进入的状态
- this.curVideoId=0
- this.page=1
- this.list=[]
- this.finished=false
- this.getList()
- this.showFilter=false
- },
- async getList(){
- const res=await apiVideoList({
- page_index:Number(this.page),
- page_size:Number(this.pageSize),
- video_id:Number(this.videoId),
- variety_tag_id:Number(this.selectPerId)
- })
- if(res.code===200){
- let arr=res.data||[]
- this.list=[...this.list,...arr]
- if(arr.length===0){
- this.finished=true
- }
- this.isAuth=true
- }else if(res.code===403){
- //无权限用户
- this.isAuth=false
- this.noAuthData=res.data
- }
- },
- //获取筛选项
- async getPermissionList(){
- /* const res=await apiOptionList()
- if(res.code===200){
- this.options=res.data
- } */
- const res=await apiGetTagTree()
- if(res.code===200){
- const result = res.data||[];
- this.options = result.map(item=>{
- let obj = {};
- obj.ClassifyName = item.classify_name;
- obj.Items = item.tags.map(_item=>{
- return {PermissionId:_item.tag_id,PermissionName:_item.tag_name,PriceDrivenState:_item.price_driven_state};
- })
- return obj;
- })
- }
- },
- handelClickPlay(item){
- this.curVideoId=item.community_video_id
- // 记录播放
- apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
- if(res.code===200){
- console.log('视频埋点成功');
- this.videoRecordId=res.data
- }
- })
- },
- //视频播放结束
- handleVideoEnd(){
- setTimeout(() => {
- this.curVideoId=0
- }, 200);
- },
- //时长变化
- handleTimeUpdate(e){
- // console.log(this.curVideoId,e.detail.currentTime);
- this.curVideoTime=e.detail.currentTime
- },
- handleVideoPause(){
- // console.log(`视频 pause---${this.videoRecordId}----${this.curVideoTime}`);
- this.handleUpdateVideoPlayTime()
- },
- // 更新播放时长
- handleUpdateVideoPlayTime(){
- if(!this.videoRecordId) return
- apiViewLogUpdate({
- id:this.videoRecordId,
- stop_seconds:parseInt(this.curVideoTime),
- source:3
- }).then(res=>{
- console.log('更新播放时长成功');
- })
- }
- },
- }
- </script>
- <style lang='scss'>
- .search-wrap .van-search{
- padding: 0 !important;
- }
- .video-list-page{
- .filter-wrap{
- .van-cell__title, .van-cell__value{
- flex: none !important;
- }
- .van-cell:after{
- border: none !important;
- }
- .van-cell__title{
- font-size: 14px;
- }
- .van-hairline--top:after{
- border-top-width: 0 !important;
- }
- }
- }
- </style>
- <style lang="scss" scoped>
- .video-list-page{
- .search-wrap {
- background-color: #fff;
- padding: 30rpx 34rpx;
- align-items: center;
- .menu-icon{
- width: 52rpx;
- height: 40rpx;
- display: block;
- flex-shrink: 0;
- margin-left: 30rpx;
- }
- }
-
- .list-wrap{
- .item{
- padding: 30rpx 34rpx;
- position: relative;
- .title-box{
- margin-right: 110rpx;
- }
- .share-btn{
- position: absolute;
- top: 34rpx;
- right: 34rpx;
- background-color: transparent;
- width: 36rpx;
- height: 36rpx;
- line-height: 1;
- padding: 0;
- &::after{
- border: none;
- }
- }
- .share-img{
- width: 32.5rpx;
- height: 32rpx;
- }
- .collect-btn{
- right: 96rpx;
- }
- .tag{
- color: #E4B478;
- background-color: #333;
- padding: 5rpx 20rpx;
- border-radius: 20rpx;
- font-size: 24rpx;
- margin-right: 26rpx;
- }
- .title{
- font-size: 32rpx;
- color: #000;
- }
- .video-content{
- width: 100%;
- height: 400rpx;
- margin: 30rpx 0 20rpx 0;
- }
- .time{
- font-size: 28rpx;
- color: #999;
- margin-top: 20rpx;
- }
- }
- }
- .empty-box{
- text-align: center;
- font-size: 32rpx;
- color: #999;
- padding-top: 150rpx;
- image{
- width: 80vw;
- margin-bottom: 57rpx;
- }
- }
- }
- .filter-wrap{
- background-color: #fff;
- padding-top: 53rpx;
- padding-bottom: 100rpx;
- .top{
- font-size: 32rpx;
- justify-content: space-between;
- margin-bottom: 40rpx;
- padding: 0 34rpx;
- }
- .list-box{
- min-height: 30vh;
- max-height: 60vh;
- .list-item{
- display: block;
- margin: 10rpx;
- height: 76rpx;
- line-height: 76rpx;
- color: #000;
- background: #F6F6F6;
- border-radius: 4px 4px 4px 4px;
- text-align: center;
- }
- .list-item-active{
- background-color: #FAEEDE;
- }
- }
- }
- </style>
|