(function () { // @charset="utf-8"; window.cctvMallConfig = { adtext: "DOLLARCOME", adtext2:"外贸软件", bigPic:"http://otorbmh27.bkt.clouddn.com/2017121415153299.jpg", smallPic:"http://otorbmh27.bkt.clouddn.com/2017110614520676.jpg", mbigPic : "http://otorbmh27.bkt.clouddn.com/2017092817093613.jpg", msmallPic : "http://otorbmh27.bkt.clouddn.com/2017092817092734.jpg" } var brandSn = "YXPP0009567"; 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 = false ; 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]; if (!isPhone) { var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; div.style.cssText='position:relative;display:block;z-index:100000;height:300px; width: '+ width+'px;margin:0 auto;background:url('+ cctvMallConfig.bigPic +') no-repeat center top;overflow:hidden;'; div.id = "CCTVMALLAD"; div.title = "点击查看品牌档案"; // div.href = "http://search.cctv.com/search.php?qtext="+window.CCTVMALLADTEXT+"&type=web"; // div.target = "_blank"; 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) { 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) { 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) })();