import CctvsJs from '../class/cctv.js'; const Cctvs = new CctvsJs(); import ConfigsJs from '../class/config.js'; const Configs = new ConfigsJs(); let arrConfigs = Configs.getAll() // 公共广告 const CommonCctv = { init(){ if(document.querySelector(".j-cctv-list-page")){ this.initVideoList() } // this.initBannerBottomPiao() this.initPlBannerBottomPiao() Cctvs.addEvent() //切勿多次调用监听事件 }, /** * 视频列表 */ initVideoList(arrPageId=[300,302]) { let CctvBannerBottomPiaoList = Cctvs.getDataByWhere(105, 209, arrPageId); //列表页-猜你喜欢 if (CctvBannerBottomPiaoList.length > 0) { //列表页-1 $(".j-cctv-list-page .j-cctv-list-ul").children().eq(0).remove() $(".j-cctv-list-page .j-cctv-list-ul").children().eq(0).before(this.CreatListCctv(CctvBannerBottomPiaoList[0])) } if (CctvBannerBottomPiaoList.length > 1) { //列表页-2 $(".j-cctv-list-page .j-cctv-list-ul").children().eq(5).remove() $(".j-cctv-list-page .j-cctv-list-ul").children().eq(5).before(this.CreatListCctv(CctvBannerBottomPiaoList[1])) } if (CctvBannerBottomPiaoList.length > 2) { //列表页-2 $(".j-cctv-list-page .j-cctv-list-ul").children().eq(8).remove() $(".j-cctv-list-page .j-cctv-list-ul").children().eq(8).before(this.CreatListCctv(CctvBannerBottomPiaoList[2])) } }, /** * 底飘初始化 * --随机生成 */ initBannerBottomPiao() { return let CctvBannerBottomPiaoList = Cctvs.getDataByWhere(101, 217, [300, 303]); let CctvBannerBottomPiaoListDom = ''; let intRandNum = Math.floor(Math.random() * CctvBannerBottomPiaoList.length) //生成随机开屏广告 let intFindActioveIndex = CctvBannerBottomPiaoList.findIndex((item, index) => index == intRandNum) if (intFindActioveIndex != -1) { CctvBannerBottomPiaoListDom = this.CreateCctvBottomDomList(CctvBannerBottomPiaoList[intFindActioveIndex], intFindActioveIndex, '底瓢'); } if (CctvBannerBottomPiaoList.length > 0) { $(".foot-dp-fix").html(CctvBannerBottomPiaoListDom); } else { $(".foot-dp-fix").addClass('yc') } }, /** * 跑量页面-底飘初始化 * --随机生成 */ initPlBannerBottomPiao() { let CctvBannerBottomPiaoPlList = Cctvs.getDataByWhere(101, 217, [305]); let CctvBannerBottomPiaoPlListDom = ''; let intRandNum = Math.floor(Math.random() * CctvBannerBottomPiaoPlList.length) //生成随机开屏广告 let intFindActioveIndex = CctvBannerBottomPiaoPlList.findIndex((item, index) => index == intRandNum) if (intFindActioveIndex != -1) { CctvBannerBottomPiaoPlListDom = this.CreateCctvBottomDomPlList(CctvBannerBottomPiaoPlListDom[intFindActioveIndex], intFindActioveIndex, '底瓢'); } if (CctvBannerBottomPiaoPlList.length > 0) { $(".foot-fix").html(CctvBannerBottomPiaoPlListDom); } }, /** * * 创建底瓢 -- 随机生成 **/ CreateCctvBottomDomList(data, index, page) { if (data) { return `
${data.title} ${data.title} 立即进入
` } }, /** * * 创建底瓢 -- 随机生成 -- 跑量页 **/ CreateCctvBottomDomPlList(data, index, page) { if (data) { return `
${data.title} ${data.title}
` } }, /** * * 视频列表dom * ***/ CreatListCctv(list,arrConfigs=[]) { var cctvListStr = ""; if (list) { cctvListStr += `
  • ${list.title}

    ${list.title}

  • `; return cctvListStr; } }, } export default CommonCctv;