156 lines
5.5 KiB
JavaScript
156 lines
5.5 KiB
JavaScript
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 `
|
|
<div class="app-content">
|
|
<a class="j-cctv-click-dp" data-href="${data.href}" data-id="${data.id}" data-onsite-or-offsite="${data.onsite_or_offsite}"
|
|
rel="nofollow">
|
|
<img class="logo-img" src="${data.cover}" alt="${data.title}">
|
|
<span class="dp-cctv-title" >${data.title}</span>
|
|
<span class="dp-lj-into" >立即进入 </span>
|
|
</a>
|
|
</div>
|
|
`
|
|
}
|
|
},
|
|
|
|
/**
|
|
*
|
|
* 创建底瓢 -- 随机生成 -- 跑量页
|
|
**/
|
|
CreateCctvBottomDomPlList(data, index, page) {
|
|
if (data) {
|
|
return `
|
|
<div class="app-content">
|
|
<a class="j-cctv-click" data-href="${data.href}" data-id="${data.id}" data-onsite-or-offsite="${data.onsite_or_offsite}" rel="nofollow">
|
|
<img class="logo-img" class="logo-img" src="${data.cover}" alt="${data.title}">
|
|
<span class="dp-cctv-title" >${data.title}</span>
|
|
</a>
|
|
<i class="close-img icon iconfont icon-shanchu1" id="close-di-but"></i>
|
|
</div>
|
|
`
|
|
}
|
|
},
|
|
|
|
/**
|
|
*
|
|
* 视频列表dom
|
|
*
|
|
***/
|
|
CreatListCctv(list,arrConfigs=[]) {
|
|
|
|
var cctvListStr = "";
|
|
if (list) {
|
|
cctvListStr += `
|
|
<li class="video_li swiper-slide">
|
|
<a class="j-cctv-click" data-href="${list.href}" data-id="${list.id}" data-onsite-or-offsite="${list.onsite_or_offsite}" rel="nofollow">
|
|
<div class="cover_dv">
|
|
<img class="lazyLoad videoCover jqlazyload"
|
|
alt="${list.title}"
|
|
src="${arrConfigs['STATIC_SOURCE_DOMAIN']}/siteConfig/img/video.webp" data-wh=0.69
|
|
data-original="${list.cover}"/>
|
|
</div>
|
|
<h3>${list.title}</h3>
|
|
</a>
|
|
</li>
|
|
|
|
`;
|
|
return cctvListStr;
|
|
}
|
|
},
|
|
|
|
}
|
|
|
|
export default CommonCctv;
|
|
|
|
|
|
|
|
|