LiveDetailPageLogic.ets 2.15 KB
import { ContentDetailDTO } from 'wdBean/Index'

const TAG = 'LiveDetailPageLogic'
/**
 *   直播信息对象逻辑加工处理的工具类
 */
export class LiveDetailPageLogic {
  // 直播状态
  liveState: string = ''
  // 横屏或竖屏  general-竖屏,news-横屏
  liveLandscape: string = ''
  // 直播样式 0-正常模式,1-隐藏直播 2-隐藏大家聊
  liveStyle: number = -1
  // 预告片图片/视频url
  imgUrl: string = ''

  // 垫片资源
  padImageUri:string = ''
  // 垫片是否开启
  showPad:boolean = false


  /**
   * 直播详情页面,展示的直播信息对象
   */
  contentDetailData: ContentDetailDTO = new ContentDetailDTO

  /**
   *  横屏直播
   * @returns true:横屏直播;false:竖屏直播
   */
  isLangScapeScreenVideo(): boolean {

    return this.liveState === 'wait' || this.liveLandscape === 'news'
  }


  /**
   * 竖屏直播
   * @returns
   */
  isVerticalScreenVideo(): boolean {

    return this.liveLandscape === 'general'
  }


  /**
   *  解析直播间的图片资源
   */
  resolvingRoomImgSource() {

    // 背景图资源
    if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewUrl &&
      this.contentDetailData.liveInfo.previewUrl.length > 0) {
      this.imgUrl = this.contentDetailData.liveInfo.previewUrl
    } else if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) {
      this.imgUrl = this.contentDetailData.fullColumnImgUrls[0].url
    }

     // 垫图资源
    if (this.contentDetailData.liveInfo){

      if(this.contentDetailData.liveInfo.padImageUri.length > 0){
        this.padImageUri =this.contentDetailData.liveInfo.padImageUri
      }
      //this.padImageUri = 'https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20240515/image/display/cdb84fe86b1440d58f3fc585841b928d.jpg'

    }

    console.log(TAG, ' this.imgUrl===>',  this.imgUrl)
  }

  /**
   *  解析直播详情里面的 vlive资源
   * @param index
   */
  resolvingRoomVliveData(index:number){

    // 只有直播中的才会有垫片
    if(this.liveState === 'running'){

      this.showPad = this.contentDetailData.liveInfo.vlive[index].showPad
    }

  }
}