debug
This commit is contained in:
257
code/public/template/shikong/huiyuan/js/cctv/index.js
Normal file
257
code/public/template/shikong/huiyuan/js/cctv/index.js
Normal file
@@ -0,0 +1,257 @@
|
||||
import { parseInt } from 'lodash';
|
||||
import CctvsJs from '../class/cctv';
|
||||
import ConfigsJs from '../class/config';
|
||||
import { downloadImage,outPutLog,layerPopup } from '../public/commonFun.js';
|
||||
const Configs = new ConfigsJs();
|
||||
|
||||
// 首页弹窗
|
||||
const IndexCctv = {
|
||||
|
||||
intPopUpsIndex: 0,
|
||||
|
||||
init() {
|
||||
const Cctvs = new CctvsJs();
|
||||
let CctvTipIndex = Cctvs.getDataByWhere(106, 211, [301]);
|
||||
console.log(CctvTipIndex)
|
||||
let CctvTipIndexDom = `
|
||||
<!--首页弹窗遮挡层-->
|
||||
<div class="index-center-tc-zdc j-close-occlusion-layer"></div>
|
||||
`
|
||||
//首页弹窗广告数量
|
||||
if (document.querySelector(".index-center-tc-num") ) {
|
||||
document.querySelector(".index-center-tc-num").innerText = (CctvTipIndex.length-1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页弹窗
|
||||
*
|
||||
*/
|
||||
CctvTipIndex.forEach((item, index) => {
|
||||
if (item) {
|
||||
if (item.title == '域名弹窗' && index == 0) {
|
||||
CctvTipIndexDom += this.CreateCctvTipIndexPupopDomainFun(item, index)
|
||||
}else{
|
||||
CctvTipIndexDom += this.CreateCctvTipIndexFun(item, index);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
//首页弹窗广告
|
||||
if (!this.isFirstLoadHomeDomanFun() && CctvTipIndex.length>0 ) {
|
||||
$("body.home-web").append(CctvTipIndexDom)
|
||||
|
||||
}
|
||||
|
||||
this.addEvent()
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 绑定点击事件-初始化
|
||||
*/
|
||||
addEvent(){
|
||||
// 保存相册
|
||||
$(".j-genimg").on('click', function () {
|
||||
if (!window.HTMLCanvasElement) {
|
||||
layerPopup("请截图保存!", 3)
|
||||
return;
|
||||
}
|
||||
const layerIndexTc = layerPopup("拼命保存中。。");
|
||||
|
||||
html2canvas(document.querySelector(".index-center-tc"), {
|
||||
useCORS: true, // 启用跨域配置
|
||||
logging: true, // 启用日志记录以进行调试
|
||||
backgroundColor: null // 保持透明背景(如果需要)
|
||||
}).then(canvas => {
|
||||
var clipImgBase64 = canvas.toDataURL();
|
||||
// 生成图片
|
||||
var clipImg = new Image();
|
||||
clipImg.src = clipImgBase64;
|
||||
downloadImage(clipImgBase64);
|
||||
layer.close(layerIndexTc);
|
||||
}).catch(err => {
|
||||
console.error("html2canvas 出错:", err);
|
||||
layer.close(layerIndexTc);
|
||||
layerPopup("请手动截图保存!", 3)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// 关闭弹窗
|
||||
$(".j-close-index-pop-ups").on('click', (event) => {
|
||||
let intPopUpsIndex = $(event.currentTarget).attr('data-index')
|
||||
this.closeIndexTcfun(intPopUpsIndex)
|
||||
})
|
||||
|
||||
// 关闭遮挡层
|
||||
$(".j-close-occlusion-layer").on('click', () => {
|
||||
console.log(this.intPopUpsIndex)
|
||||
this.closeIndexTcfun(this.intPopUpsIndex)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建首页弹窗广告
|
||||
* h5
|
||||
**/
|
||||
CreateCctvTipIndexPupopDomainFun(data, index) {
|
||||
if (typeof data == 'object') {
|
||||
if (data.title == '域名弹窗' && index == 0) {
|
||||
return `
|
||||
<div class="index-center-tc index-center-tc-index${index} df-index-center-tc df-index-center-tc" >
|
||||
<div style="width:300px">
|
||||
<i class="index-center-tc-close icon iconfont icon-shanchu1 j-close-index-pop-ups" data-index="${index}" ></i>
|
||||
<a>
|
||||
<img class="index-center-tc-bjimg jqlazyload" src="${data.cover}" data-original="${data.cover}" />
|
||||
</a>
|
||||
|
||||
<div class="index-center-tc-op-domain df-top-domain j-share" data-sharedom=".index-center-tc-op-domain-text" >
|
||||
<p class="index-center-tc-op-domain-text">${Configs.get('STANDBY_URL')}</p>
|
||||
</div>
|
||||
<!--
|
||||
<div class="index-center-tc-yj-domain tc-domain j-share" data-sharedom=".index-center-tc-yj-domain-text" >
|
||||
<p class="index-center-tc-yj-domain-text">${Configs.get('VIP_DOMAIN_1')}</p>
|
||||
</div>
|
||||
-->
|
||||
<div class="index-center-tc-vip1-domain tc-domain j-share" data-sharedom=".index-center-tc-vip1-domain-text" >
|
||||
<p class="index-center-tc-vip1-domain-text">${Configs.get('VIP_DOMAIN_1')}</p>
|
||||
</div>
|
||||
|
||||
<div class="index-center-tc-vip2-domain tc-domain j-share" data-sharedom=".index-center-tc-vip2-domain-text" >
|
||||
<p class="index-center-tc-vip2-domain-text">${Configs.get('VIP_DOMAIN_2')}</p>
|
||||
</div>
|
||||
|
||||
<div class="index-center-tc-vip3-domain tc-domain j-share" data-sharedom=".index-center-tc-vip3-domain-text" >
|
||||
<p class="index-center-tc-vip3-domain-text">${Configs.get('VIP_DOMAIN_3')}</p>
|
||||
</div>
|
||||
|
||||
<a class="index-center-tc-fs1-domain tc-domain" href="${Configs.get('TG_URL', null)}" target="_blank">
|
||||
<p class="index-center-tc-fs1-domain-text" >${Configs.get('TG_URL', null)}</p>
|
||||
</a>
|
||||
|
||||
<a class="index-center-tc-fs2-ios tc-domain" href="https://f5d3.xyz" target="_blank">
|
||||
<p ><!--点击查看解决苹果手机无法加入和查看群内容--></p>
|
||||
</a>
|
||||
|
||||
<div class="index-center-tc-new-mail tc-domain j-share" data-sharedom=".index-center-tc-new-mail-text">
|
||||
<p class="index-center-tc-new-mail-text">${Configs.get('NEW_EMAIL')}</p>
|
||||
</div>
|
||||
|
||||
<div class="index-center-tc-btn">
|
||||
<div class="index-center-tc-btn-left j-genimg" ></div>
|
||||
<div class="index-center-tc-btn-right j-share" data-sharedom=".yjfz-nr-dv" ></div>
|
||||
</div>
|
||||
<div class="yjfz-nr-dv">
|
||||
官方永久域名:<br>
|
||||
${Configs.get('VIP_DOMAIN_1')}<br>
|
||||
你的VIP专属域名:<br>
|
||||
${Configs.get('VIP_DOMAIN_1')}<br>
|
||||
${Configs.get('VIP_DOMAIN_2')}<br>
|
||||
${Configs.get('VIP_DOMAIN_3')}<br>
|
||||
官方万人粉丝群:<br>
|
||||
${Configs.get('TG_URL')}<br>
|
||||
官方自动回复最新邮箱地址:<br>
|
||||
${Configs.get('NEW_EMAIL')}<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
/**
|
||||
*
|
||||
* 创建首页弹窗广告
|
||||
* h5
|
||||
**/
|
||||
CreateCctvTipIndexFun(data, index) {
|
||||
if (typeof data == 'object') {
|
||||
//index++
|
||||
//data.href = framt_cctv_url(data.href,secretUrl)
|
||||
let strStyle = `style="display: none;"`
|
||||
if(index == 0){
|
||||
strStyle = `style="display: block;"`
|
||||
}
|
||||
return `
|
||||
<div class="index-center-tc index-center-tc-index${index}" ${strStyle}>
|
||||
<div style="width:300px">
|
||||
<i class="index-center-tc-close icon iconfont icon-shanchu1 j-close-index-pop-ups" data-index="${index}"></i>
|
||||
<a rel="nofollow" class="j-cctv-click" data-href="${data.href}" data-id="${data.id}" data-onsite-or-offsite="${data.onsite_or_offsite}" >
|
||||
<img class="index-center-tc-bjimg jqlazyload" src="${data.cover}" data-original="${data.cover}" alt="" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* 检测是否n分钟内是否访问过访问首页
|
||||
* intMinute 分钟
|
||||
*/
|
||||
isFirstLoadHomeDomanFun(intMinute = Configs.get('HOMEPAGE_LOAD_POPUPS_NUM')) {
|
||||
let currentDomain = document.domain
|
||||
let isFirstLoadHome = localStorage.getItem("isFirstLoadHome");
|
||||
let isFirstLoadHomeTime = localStorage.getItem("isFirstLoadHomeTime") ? localStorage.getItem("isFirstLoadHomeTime") : 0;
|
||||
isFirstLoadHomeTime = Number(isFirstLoadHomeTime)
|
||||
let timestamp = new Date().getTime();
|
||||
let timeLeft = timestamp - isFirstLoadHomeTime
|
||||
|
||||
outPutLog(currentDomain)
|
||||
outPutLog(isFirstLoadHome)
|
||||
outPutLog(isFirstLoadHomeTime)
|
||||
outPutLog(timestamp)
|
||||
outPutLog(timeLeft + '===' + intMinute * 60 * 1000)
|
||||
|
||||
if (isFirstLoadHome == currentDomain && timeLeft <= intMinute * 60 * 1000) {
|
||||
outPutLog('非首次访问')
|
||||
return true
|
||||
} else {
|
||||
outPutLog('首次访问')
|
||||
localStorage.setItem("isFirstLoadHome", currentDomain);
|
||||
localStorage.setItem("isFirstLoadHomeTime", timestamp);
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//点击 关闭按钮
|
||||
closeIndexTcfun(intIndex) {
|
||||
let intPopusTotal = document.querySelector(".index-center-tc-num").innerText //一共几个弹窗
|
||||
intIndex = parseInt(intIndex)
|
||||
intPopusTotal = parseInt(intPopusTotal)
|
||||
console.log(intPopusTotal)
|
||||
console.log(intIndex)
|
||||
if (intIndex >= intPopusTotal) {
|
||||
//最后一个弹窗才关闭遮挡层
|
||||
let DomOcclusionLayer = document.querySelector(".index-center-tc-zdc")
|
||||
DomOcclusionLayer.setAttribute("style", "display:none!important");
|
||||
|
||||
//关闭最后一个弹窗
|
||||
let strClassName = ".index-center-tc-index" + intIndex
|
||||
let DomPupous = document.querySelector(strClassName)
|
||||
DomPupous.setAttribute("style", "display:none!important");
|
||||
} else {
|
||||
//关当前弹窗
|
||||
let strCurrentClassName = ".index-center-tc-index" + intIndex
|
||||
let DomCurrentPupous = document.querySelector(strCurrentClassName)
|
||||
DomCurrentPupous.setAttribute("style", "display:none!important");
|
||||
|
||||
//展示下一个弹窗
|
||||
let strNextClassName = ".index-center-tc-index" + (intIndex += 1)
|
||||
let DomNextPupous = document.querySelector(strNextClassName)
|
||||
DomNextPupous.setAttribute("style", "display:block");
|
||||
}
|
||||
this.intPopUpsIndex = intIndex++
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default IndexCctv;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user