123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view class="video-search-page">
- <van-sticky style="background: #fff">
- <view style="padding:30rpx 34rpx">
- <searchBox
- :focus="focus"
- placeholder="关键字搜索"
- @change="onChange"
- @search="onSearch"
- ></searchBox>
- </view>
- </van-sticky>
- <view class="empty-box" v-if="list.length==0&&finished">
- <image
- :src="globalImgUrls.activityNoAuth"
- mode="widthFix"
- />
- <view>暂无数据,试试别的搜索词吧~</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.chart_permission_name}}</text>
- <text class="title">{{item.title}}</text>
- </view>
- <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>
- <video
- autoplay
- object-fit="contain"
- show-mute-btn
- :poster="item.cover_img_url"
- :src="item.video_url"
- enable-play-gesture
- :id="item.community_video_id"
- @ended="handleVideoEnd"
- v-if="item.community_video_id==curVideoId"
- ></video>
- <image @click="handelClickPlay(item)" v-else class="poster" :src="item.cover_img_url" mode="aspectFill" lazy-load/>
- <commnet :videoInfo="item"></commnet>
- </view>
- </view>
- </view>
- </template>
- <script>
- import searchBox from '@/components/searchBox/searchBox.vue'
- import {apiVideoList,apiVideoPlayLog} from '@/api/video'
- import commnet from './components/comment.vue'
- export default {
- components: {
- searchBox,
- commnet
- },
- data() {
- return {
- searchVal:'',
- focus:true,
- list:[],
- finished:false,
- page:1,
- pageSize:10,
- curVideoId:0,
- curVideoIns:null
- }
- },
- onReachBottom() {
- if(this.finished) return
- this.page++
- this.getList()
- },
- 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.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
- }
- },
- methods: {
- onChange(e){
- this.searchVal=e
- },
- async onSearch(){
- this.finished=false
- this.page=1
- this.list=[]
- if(!this.searchVal){
- this.finished=true
- return
- }
- this.getList()
- },
- async getList(){
- this.curVideoId=0
- const res=await apiVideoList({
- page_index:Number(this.page),
- page_size:Number(this.pageSize),
- keywords:this.searchVal
- })
- if(res.code===200){
- let arr=res.data||[]
- this.list=[...this.list,...arr]
- if(arr.length===0){
- this.finished=true
- }
- }
- },
- handelClickPlay(item){
- this.curVideoId=item.community_video_id
- setTimeout(() => {
- this.curVideoIns=uni.createVideoContext(this.curVideoId.toString())
- }, 300);
- // 记录播放
- apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
- if(res.code===200){
- console.log('视频埋点成功');
- }
- })
- },
- //视频播放结束
- handleVideoEnd(){
- // 此处因为如果不调用退出全屏方法 安卓和ios页面均会表现异常,安卓横屏不恢复竖屏,ios底部tabbar渲染异常
- this.curVideoIns.exitFullScreen()
- setTimeout(() => {
- this.curVideoId=0
- this.curVideoIns=null
- }, 200);
- }
- },
- }
- </script>
- <style>
- .van-sticky-wrap--fixed{
- background-color: #fff;
- }
- page{
- padding-bottom: 0;
- }
- </style>
- <style lang="scss" scoped>
- .video-search-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{
- padding-right: 40rpx;
- }
- .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: 32rpx;
- height: 32rpx;
- }
- .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{
- width: 100%;
- height: 400rpx;
- margin: 30rpx 0 20rpx 0;
- border-radius: 20rpx;
- }
- .poster{
- width: 100%;
- height: 400rpx;
- margin: 30rpx 0 20rpx 0;
- border-radius: 20rpx;
- position: relative;
- &::after{
- content:'';
- display: block;
- position: absolute;
- width: 120rpx;
- height: 120rpx;
- top: 50%;
- left: 50%;
- transform: translate(-50%,-50%);
- background-image: url('@/static/video-play-btn.png');
- background-size: cover;
- }
- }
- .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;
- }
- }
- }
- </style>
|