(function () { // @charset="utf-8"; window.cctvMallConfig = { adtext: "红顶尚国体系", adtext2: "功能性食品", adtext3: "典范企业", type: "2", bigPic: "https://www.bsan.org.cn/images/bg_big.png", smallPic: "https://www.bsan.org.cn/images/bg_small.png", mbigPic: "https://www.bsan.org.cn/images/mbrand/h5_bg_big.png", msmallPic: "https://www.bsan.org.cn/images/mbrand/h5_bg_big.png", guanbiH5: "https://www.bsan.org.cn/images/mbrand/guanbi_h5.png", guanbi: "https://www.bsan.org.cn/images/guanbi.png", } var isClose = false; //判断访问终端 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 = "SF2022P7VIKBU9V2H"; 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 = window.innerWidth; 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"; } }; if (!isPhone) { var fixBanner = 'position: relative;display: block;text-align:center;'; var fixBannerBig = 'height: 300px;;background-image: url('+cctvMallConfig.bigPic+'); background-repeat: no-repeat;background-size: cover; background-position: center center;'; var fixBannerFixLogo = 'text-align: center;line-height: 60px;color: #fff;font-size: 25px;display: inline-block;margin-top: 90px;'; var fixBannerFixLogoImg = 'display: block;border-radius: 4px;margin-right:20px; height: 100px;float:left;margin-top: 10px;'; var fixBannerClose = 'display: none;position: absolute;right: 5%;margin-top: -60px;width: 30px;height: 30px;cursor: pointer;background-image: url('+cctvMallConfig.guanbi+');background-repeat: no-repeat;background-size: 100% 100%;'; div.id = "examId"; div.title = "点击查看电子证书"; div.style.height = 300 + 'px'; div.innerHTML = ' ' + ''+ ' '; } else { var width = window.innerWidth; var height = parseInt(width / 640 * 200); var fixBanner = 'position: relative;display: -moz-box;display: -ms-flexbox;display: -webkit-box;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-pack: center;-webkit-justify-content: center;-moz-justify-content: center;-ms-justify-content: center;-o-justify-content: center;justify-content: center -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center;align-items: center;'; var fixBannerBig = 'height: 6.25rem;background-image: url('+cctvMallConfig.mbigPic+'); background-repeat: no-repeat;background-size: cover; background-position: center center;'; var fixBannerFixLogo = 'display: -moz-box;display: -ms-flexbox;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-align: center;-webkit-align-items: center;-ms-flex-align: center;align-items: center;color: #fff;padding: 0 0.8rem;font-size: 0.937rem;'; var fixBannerFixLogoSpan = 'color: white !important;text-align: center;';//'white-space: nowrap;overflow: hidden;text-overflow: ellipsis;'; var fixBannerFixLogoImg = 'margin-right: 0.625rem;width: 30%;'; var fixBannerClose = 'display: none;position: absolute;right: 2%;top: 5%;width: 1.2rem;height: 1.2rem;cursor: pointer;background-image: url('+cctvMallConfig.guanbiH5+');background-repeat: no-repeat;background-size: 100% 100%;'; div.id = "examId"; div.title = "点击查看电子证书"; div.innerHTML = '' + ''+ ' '; } document.body.insertBefore(div, firstNode); var time = value == "OK" ? 0 : 3000; if (value == "OK") { // document.getElementById('examId').style.height = (height / 2) + 'px'; if (!isPhone) { var fixBanner = 'position: relative;display: block;text-align:center;'; var fixBannerSmall = 'height: 80px;background-image: url('+cctvMallConfig.smallPic+');background-repeat: no-repeat;background-size: cover;background-position: center center;'; var fixBannerSmallClose = 'display: block;'; var fixBannerFixLogo = 'color: #fff;font-size: 25px;text-align:center;display:inline-block;margin-top:10px;'; var fixBannerFixLogoImg = 'margin-right: 10px;border-radius: 4px;float:left;'; var fixBannerClose = 'position: absolute;right: 5%;margin-top: -60px;width: 30px;height: 30px;cursor: pointer;background-image: url('+cctvMallConfig.guanbi+');background-repeat: no-repeat;background-size: 100% 100%;'; document.getElementById('examId').style.height = 80 + 'px'; div.innerHTML = ' ' + ''+ ' '; document.getElementById('close').onclick = function (argument) { document.getElementById('examId').remove(); isClose = true; } } else { var fixBanner = 'position: relative;display: -moz-box;display: -ms-flexbox;display: -webkit-box;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-pack: center;-webkit-justify-content: center;-moz-justify-content: center;-ms-justify-content: center;-o-justify-content: center;justify-content: center -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center;align-items: center;'; var fixBannerSmall = 'height: 3.75rem;background-image: url('+cctvMallConfig.msmallPic+');background-repeat: no-repeat;background-size: cover;background-position: center center;'; var fixBannerSmallClose = 'display: block;'; var fixBannerFixLogo = 'display: -moz-box;display: -ms-flexbox;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-align: center;-webkit-align-items: center;-ms-flex-align: center;align-items: center;color: #fff;padding: 0 0.8rem;font-size: 0.937rem;'; var fixBannerFixLogoSpan = 'text-align: center;color: white !important;';//'white-space: nowrap;overflow: hidden;text-overflow: ellipsis;'; var fixBannerFixLogoImg = 'margin-right: 0.625rem;width: 30%;'; var fixBannerClose = 'position: absolute;right: 2%;top: 5%;width: 1.2rem;height: 1.2rem;cursor: pointer;background-image: url('+cctvMallConfig.guanbiH5+');background-repeat: no-repeat;background-size: 100% 100%;'; div.innerHTML = ' ' + ''+ ' '; document.getElementById('close').onclick = function (argument) { document.getElementById('examId').remove(); isClose = true; } } // return; } var runBrandGet = function () { var exam = document.getElementById('examId'); exam.style.overflow = 'hidden'; var examHeight = exam.style.height.replace('px' , ''); var a = anim("examId", { height: isPhone ? (parseFloat(examHeight) * 3.75 / 6.25) + 'px' : '80px' }, 1500, 'Tween.Linear', { complete: function (el) { if (!isPhone) { var fixBanner = 'position: relative;display: block;text-align:center;'; var fixBannerSmall = 'height: 80px;background-image: url('+cctvMallConfig.smallPic+');background-repeat: no-repeat;background-size: cover;background-position: center center;'; var fixBannerSmallClose = 'display: block;'; var fixBannerFixLogo = 'color: #fff;font-size: 25px;text-align:center;display:inline-block;margin-top:10px;'; var fixBannerFixLogoImg = 'margin-right: 10px;border-radius: 4px;float:left;'; var fixBannerClose = 'position: absolute;right: 5%;margin-top: -60px;width: 30px;height: 30px;cursor: pointer;background-image: url('+cctvMallConfig.guanbi+');background-repeat: no-repeat;background-size: 100% 100%;'; div.innerHTML = ' ' + ''+ ' '; document.getElementById('close').onclick = function (argument) { document.getElementById('examId').remove(); isClose = true; } } else { var fixBanner = 'position: relative;display: -moz-box;display: -ms-flexbox;display: -webkit-box;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-pack: center;-webkit-justify-content: center;-moz-justify-content: center;-ms-justify-content: center;-o-justify-content: center;justify-content: center -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center;align-items: center;'; var fixBannerSmall = 'height: 3.75rem;background-image: url('+cctvMallConfig.msmallPic+');background-repeat: no-repeat;background-size: cover;background-position: center center;'; var fixBannerSmallClose = 'display: block;'; var fixBannerFixLogo = 'display: -moz-box;display: -ms-flexbox;display: -webkit-flex;display: box;display: flexbox;display: flex; -webkit-box-align: center;-webkit-align-items: center;-ms-flex-align: center;align-items: center;color: #fff;padding: 0 0.8rem;font-size: 0.937rem;'; var fixBannerFixLogoSpan = 'text-align: center;color: white !important;';//'white-space: nowrap;overflow: hidden;text-overflow: ellipsis;'; var fixBannerFixLogoImg = 'margin-right: 0.625rem;width: 30%;border-radius: 4px;'; var fixBannerClose = 'position: absolute;right: 2%;top: 5%;width: 1.2rem;height: 1.2rem;cursor: pointer;background-image: url('+cctvMallConfig.guanbiH5+');background-repeat: no-repeat;background-size: 100% 100%;'; div.innerHTML = ' ' + ''+ ' '; document.getElementById('close').onclick = function (argument) { document.getElementById('examId').remove(); isClose = true; } } } } ); } runBrandGet(); var checkBrandGetSafe = function () { var needRun = false; var iframmeCheck = document.getElementById("examId"); if(!iframmeCheck || iframmeCheck === undefined || iframmeCheck === null) { needRun = true; } if(needRun) { div.id = "examId"; div.title = "点击查看电子证书"; if (!isClose){ document.body.insertBefore(div, firstNode); } } console.log(1111); setTimeout(checkBrandGetSafe , 3000); }; setTimeout(function () { runBrandGet(); checkBrandGetSafe(); }, time); })();