(function () {
// @charset="utf-8";
window.cctvMallConfig = {
adtext: "聚创考研",
adtext2: "考研培训",
bigPic: "https://cdn.yxbrand.com/Mbp_1590660485310.jpg",
smallPic: "https://cdn.yxbrand.com/Msp_1590660485310.jpg",
mbigPic: "https://cdn.yxbrand.com/MbBp_1590660485310.jpg",
msmallPic: "https://cdn.yxbrand.com/MpSp_1590660485310.jpg"
}
//判断访问终端
var browser = {
versions: function () {
var u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
qq: u.match(/\sQQ/i) == " qq" //是否QQ
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
var brandSn = "YXPP0014105";
function setCookie(name, value) {
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
var value = getCookie("BRAND");
if (value == "OK") {
// return;
}
//console.log(value);
setCookie("BRAND", 'OK');
var isPhone = browser.versions.mobile || browser.versions.android || browser.versions.ios;
var width = document.body.clientWidth;
if (width > 950) {
isPhone = false;
}
if (isPhone) {
window.cctvMallConfig.bigPic = window.cctvMallConfig.mbigPic;
window.cctvMallConfig.smallPic = window.cctvMallConfig.msmallPic;
}
var Tween = {
Linear: function (t, b, c, d) {
return c * t / d + b;
}
}
var fn = {
getElement: function (id) {
return typeof id == "string" ? document.getElementById(id) : id;
},
objType: function (obj) {
switch (Object.prototype.toString.call(obj)) {
case "[object Object]":
return "Object";
case "[object Number]":
return "Number";
case "[object Array]":
return "Array";
}
},
getStyle: function (elem, name) { //
var w3style;
if (document.defaultView) {
var style = document.defaultView.getComputedStyle(elem, null);
name == "borderWidth" ? name = "borderLeftWidth" : name; // 解决标准浏览器解析问题
w3style = name in style ? style[name] : style.getPropertyValue(name);
w3style == "auto" ? w3style = "0px" : w3style;
}
return elem.style[name] ||
(elem.currentStyle && (elem.currentStyle[name] == "auto" ? "0px" : elem.currentStyle[name])) || w3style;
},
getOriCss: function (elem, cssObj) { // 此处只能获取属性值为数值类型的style属性
var cssOri = [];
for (var prop in cssObj) {
if (!cssObj.hasOwnProperty(prop)) continue;
//if (prop != "opacity") cssOri.push(parseInt(fn.getStyle(elem, prop)));
//else cssOri.push(100 * fn.getStyle(elem, prop));
if (fn.getStyle(elem, prop) == "transparent" || /^#|rgb\(/.test(fn.getStyle(elem, prop))) {
if (fn.getStyle(elem, prop) == "transparent") {
cssOri.push([255, 255, 255]);
}
if (/^#/.test(fn.getStyle(elem, prop))) {
cssOri.push(color.GetColors(fn.getStyle(elem, prop)));
}
if (/^rgb\(/.test(fn.getStyle(elem, prop))) {
//cssOri.push([fn.getStyle(elem, prop).replace(/^rgb\(\)/g, "")]);
var regexp = /^rgb\(([0-9]{0,3}),\s([0-9]{0,3}),\s([0-9]{0,3})\)/g;
var re = fn.getStyle(elem, prop).replace(regexp, "$1 $2 $3").split(" ");
//cssOri.push(re); // re为字符串数组
cssOri.push([parseInt(re[0]), parseInt(re[1]), parseInt(re[2])]);
}
} else if (prop == "opacity") {
cssOri.push(100 * fn.getStyle(elem, prop));
} else {
cssOri.push(parseInt(fn.getStyle(elem, prop)));
}
}
return cssOri;
},
getEndCss: function (cssobj) {
var cssEnd = [];
for (var prop in cssobj) {
if (!cssobj.hasOwnProperty(prop)) continue;
//if (prop != "opacity") cssEnd.push(parseInt(cssobj[prop]));
//else cssEnd.push(100 * cssobj[prop]);
if (prop == "opacity") {
cssEnd.push(100 * cssobj[prop]);
} else if (/^#/.test(cssobj[prop])) {
cssEnd.push(color.GetColors(cssobj[prop]));
} else {
cssEnd.push(parseInt(cssobj[prop]));
}
}
return cssEnd;
}
}
function _anim(/*elemId, cssObj, time, animType, funObj*/) {
this.init.apply(this, arguments[0]);
}
_anim.prototype = {
init: function () {
this.elem = fn.getElement(arguments[0]);
this.cssObj = arguments[1];
this.cssOri = fn.getOriCss(this.elem, arguments[1]);
this.cssEnd = fn.getEndCss(arguments[1]);
this.durtime = arguments[2];
this.animType = "Tween.Linear";
this.funObj = null;
this.start = false;
this.complete = false;
this.onPause = false;
this.onRestart = false;
if (arguments.length < 3) {
throw new Error("至少要传入3个参数");
} else if (arguments.length == 4) {
if (fn.objType(arguments[3]) == "Object") {
this.funObj = arguments[3];
for (var p in this.funObj) {
if (p.toString() == "start") this.start = true;
if (p.toString() == "complete") this.complete = true;
}
}
if (typeof (arguments[3]) == "string") {
this.animType = arguments[3];
}
} else if (arguments.length == 5) {
this.animType = arguments[3];
if (fn.objType(arguments[4]) == "Object") {
this.funObj = arguments[4];
for (var p in this.funObj) {
if (p.toString() == "start") this.start = true;
if (p.toString() == "complete") this.complete = true;
}
}
}
this.startAnim();
},
startAnim: function () {
if (this.start) this.funObj["start"].call(this, this.elem);
var that = this;
var t = 0;
var props = [];
for (var pro in this.cssObj) {
if (!this.cssObj.hasOwnProperty(pro)) continue;
props.push(pro);
}
var tt = new Date().getTime();
clearInterval(this.timer);
this.timer = setInterval(function () {
if (that.onPause) {
clearInterval(that.timer);
return;
}
if (t < that.durtime / 10) {
t++;
for (var i = 0; i < props.length; i++) {
var b, c;
fn.objType(that.cssOri[i]) != "Array" && (b = that.cssOri[i]); //开始值
fn.objType(that.cssEnd[i]) != "Array" && (c = that.cssEnd[i] - that.cssOri[i]); // 变化量
var d = that.durtime / 10; // 持续时间
if (fn.objType(that.cssOri[i]) == "Array" && fn.objType(that.cssEnd[i]) == "Array") {
var b1 = that.cssOri[i][0], b2 = that.cssOri[i][1], b3 = that.cssOri[i][2];
var c1 = that.cssEnd[i][0] - that.cssOri[i][0],
c2 = that.cssEnd[i][1] - that.cssOri[i][1],
c3 = that.cssEnd[i][2] - that.cssOri[i][2];
var r = color.hex(Math.ceil((eval(that.animType))(t, b1, c1, d))),
g = color.hex(Math.ceil((eval(that.animType))(t, b2, c2, d))),
b = color.hex(Math.ceil((eval(that.animType))(t, b3, c3, d)));
that.elem.style[props[i]] = "#" + r + g + b;
} else if (props[i].toString() == "opacity") {
that.elem.style[props[i]] = Math.ceil((eval(that.animType))(t, b, c, d)) / 100;
} else {
that.elem.style[props[i]] = Math.ceil((eval(that.animType))(t, b, c, d)) + "px";
}
}
} else {
for (var i = 0; i < props.length; i++) {
if (fn.objType(that.cssOri[i]) == "Array" && fn.objType(that.cssEnd[i]) == "Array") {
var c1 = that.cssEnd[i][0],
c2 = that.cssEnd[i][1],
c3 = that.cssEnd[i][2];
var r = color.hex(Math.ceil((eval(that.animType))(t, b1, c1, d))),
g = color.hex(Math.ceil((eval(that.animType))(t, b2, c2, d))),
b = color.hex(Math.ceil((eval(that.animType))(t, b3, c3, d)));
that.elem.style[props[i]] = "#" + r + g + b;
} else if (props[i].toString() == "opacity") {
that.elem.style[props[i]] = that.cssEnd[i] / 100;
} else {
that.elem.style[props[i]] = that.cssEnd[i] + "px";
}
}
clearInterval(that.timer);
if (that.complete) that.funObj["complete"].call(that, that.elem);
//alert(new Date().getTime() - tt);
}
}, 10); // 一般要给10毫秒异步调用时间,不能是1
},
pause: function () {
this.onPause = true;
}
}
window.anim = function () {
return new _anim(arguments);
};
var div = document.createElement('div'), firstNode = document.body.childNodes[0];
window.onresize = function() {
if (!isPhone) {
var newWidth = document.documentElement.scrollWidth || document.body.scrollWidth;
div.style.width = newWidth + "px";
}
};
var maid = '1';
if (!isPhone) {
var width = document.documentElement.scrollWidth || document.body.scrollWidth;
var cssText = 'position:relative;display:block;z-index:100000;height:300px; width: ' + width + 'px;margin:0 auto;overflow:hidden;';
//background:url(' + cctvMallConfig.bigPic + ') no-repeat center top;
if(maid === '1' && width > 1920) {
cssText += 'background:url(https://www.yxbrand.com/img/get/bg-1-2150-big.jpg) no-repeat center top;'
} else {
cssText += 'background:url(' + cctvMallConfig.bigPic + ') no-repeat center top;'
}
div.style.cssText = cssText;
div.id = "CCTVMALLAD";
div.title = "点击查看电子证书";
var height = 150;
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获
' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
} else {
var width = document.body.clientWidth;
var height = parseInt(width / 640 * 200);
div.style.cssText = 'position:relative;display:block;z-index:100000;height:' + height + 'px;margin:0 auto;background:url(' + cctvMallConfig.bigPic + ') no-repeat center top;overflow:hidden; background-size: ' + width + 'px ';
div.id = "CCTVMALLAD";
div.title = "点击查看电子证书";
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获
' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
}
document.body.insertBefore(div, firstNode);
var time = value == "OK" && brandSn != "YXPP0009135" && brandSn != 'YXPP0009003' ? 0 : 3000;
if (value == "OK" && brandSn != "YXPP0009135" && brandSn != 'YXPP0009003') {
document.getElementById('CCTVMALLAD').style.height = (height / 2) + 'px';
if (!isPhone) {
if(maid === '1' && width > 1920) {
div.style.backgroundImage = 'url(https://www.yxbrand.com/img/get/bg-1-2150-small.jpg)';
} else {
div.style.backgroundImage = 'url(' + cctvMallConfig.smallPic + ')';
}
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
document.getElementById('CCTVMALLCLOSE').onclick = function (argument) {
document.getElementById('CCTVMALLAD').style.display = "none";
}
} else {
div.style.backgroundImage = 'url(' + cctvMallConfig.smallPic + ')';
div.style.backgroudSize = width + "px";
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
document.getElementById('CCTVMALLCLOSE').onclick = function (argument) {
document.getElementById('CCTVMALLAD').style.display = "none";
}
}
return;
}
setTimeout(function () {
var a = anim("CCTVMALLAD", {
height: (height / 2) + 'px'
}, 1500, 'Tween.Linear', {
complete: function (el) {
if (!isPhone) {
if(maid === '1' && width > 1920) {
div.style.backgroundImage = 'url(https://www.yxbrand.com/img/get/bg-1-2150-small.jpg)';
} else {
div.style.backgroundImage = 'url(' + cctvMallConfig.smallPic + ')';
}
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
document.getElementById('CCTVMALLCLOSE').onclick = function (argument) {
document.getElementById('CCTVMALLAD').style.display = "none";
}
} else {
div.style.backgroundImage = 'url(' + cctvMallConfig.smallPic + ')';
div.style.backgroudSize = width + "px";
div.innerHTML = '' + window.cctvMallConfig.adtext + ' 荣获' + window.cctvMallConfig.adtext2 + '行业中国优选品牌称号';
document.getElementById('CCTVMALLCLOSE').onclick = function (argument) {
document.getElementById('CCTVMALLAD').style.display = "none";
}
}
}
}
);
}, time);
})();