(function (f) { var a = " .webcompatiblecon{ " + " position: fixed; left:0; top:0; z-index: 8000; " + ' width: 100%; height: 100%; font-family: "microsoft yahei", "微软雅黑", "黑体"; ' + " color: #747474; } " + ".webcompatiblecon *{ padding: 0; margin:0;} " + ".webcompatiblecon .webcompatiblebg{ " + " position: absolute; left:0; top:0; width: 100%; height: 100%; _height:600px; *height:600px; " + " opacity: 0.5; filter:alpha(opacity=50); background:#000; } " + ".webcompatiblecon .webcompatiblemain{ " + " position: relative; background: #fff; " + " width: 600px; height: 300px; " + " border-radius: 3px; font-size: 14px; " + " top:200px; margin: 0 auto; } " + ".webcompatiblecon .colorblack{color:#000; } " + ".webcompatiblecon .webcompatiblepa{padding:0 30px; } " + ".webcompatiblecon .webcompatibletitle{ " + " font-size: 14px; height:45px; line-height:45px; " + " border-bottom:1px solid #dedede; margin-bottom: 10px; } " + ".webcompatiblecon .tipclose{ " + " position: absolute; right: 10px; top:8px; " + ' width: 26px; height: 26px; background:url("http://jhcj888.com/js/browsertip.png") no-repeat -7px -195px; } ' + ".webcompatiblecon .tipclose:hover{cursor: pointer;} " + ".webcompatiblecon .tip-part1{line-height: 40px; font-size: 16px;} " + ".webcompatiblecon .tip-part1 span{font-weight: bold;} " + ".webcompatiblecon .tip-part1 .redspan{color: #de2626;} " + ".webcompatiblecon .tip-part2{text-align: center; margin-top: 40px; padding:0 15px;} " + ".webcompatiblecon ul li{list-style-type: none;float:left; width: 16%;} " + ".webcompatiblecon ul li p{color: #747474;} " + ".webcompatiblecon a{text-decoration:none;}" + '.webcompatiblecon .browser{ width: 56px; height: 58px; display: inline-block; margin:0 auto; background-image:url("http://jhcj888.com/js/browsertip.png"); background-repeat:no-repeat; }' + ".webcompatiblecon .browser-google{ background-position: -5px -20px; } " + ".webcompatiblecon .browser-firefox{ background-position: -99px -19px; }" + ".webcompatiblecon .browser-360{ background-position: -200px -22px; } " + ".webcompatiblecon .browser-3602{ background-position: -4px -104px; } " + ".webcompatiblecon .browser-sougou{ background-position: -102px -106px; } " + ".webcompatiblecon .browser-ie{ background-position: -199px -102px; } "; var j = '
"; var l = window.document.head || window.document.getelementsbytagname("head")[0]; var m = { isaddeventlistener: typeof window.document.addeventlistener != "undefined", isattachevent: typeof window.document.attachevent != "undefined", isinnertext: "innertext" in l, isinnerhtml: "innerhtml" in l, addevent: function (q, p, o) { if (m.isaddeventlistener) { q.addeventlistener(p, o, false) } else { if (m.isattachevent) { q.attachevent("on" + p, o) } } }, removeevent: function (q, p, o) { if (m.isaddeventlistener) { q.removeeventlistener(p, o, false) } else { if (m.isattachevent) { q.detachevent("on" + p, o) } } } }; var n = [], k = false, c = false; function i(p) { var o = p.shift(); while (o) { o(); o = p.shift() } } function b() { if (m.isaddeventlistener) { window.document.removeeventlistener("domcontentloaded", b); k = true; i(n) } if (m.isattachevent) { if (window.document.readystate === "complete") { window.document.detachevent("onreadystatechange", b); k = true; i(n) } } } var e = f || function (o) { if (typeof o !== "function") { return } n.push(o); if (k) { i(n) } else { if (!c) { if (m.isaddeventlistener) { window.document.addeventlistener("domcontentloaded", b) } else { if (m.isattachevent) { window.document.attachevent("onreadystatechange", b) } } c = true } } }; function h() { var o = null; if (document.createstylesheet) { o = document.createstylesheet(); o.csstext = a } else { o = document.createelement("style"); if (o.setattribute) { o.setattribute("type", "text/css") } else { o.attributes.type = "text/css" } o.innerhtml = o.innertext = a; l.appendchild(o) } } function g() { var p = window.document.createelement("div"); p.innerhtml = j; var o = window.document.body; o.insertbefore(p, o.firstchild) } function d() { var q = document.body.children || document.body.childnodes; var p = 0, o = q.length, t, r; for (p; p < o; p++) { t = q[p]; if (t.tagname.touppercase() == "div") { r = t.firstchild; if (r && r.tagname.touppercase() === "div" && /webcompatiblecon/ig.test(r.classname)) { break } } } r = r.lastchild.firstchild; var s = r.lastchild; m.addevent(s, "click", function () { document.body.removechild(t) }) } e(function () { var q = window.navigator.useragent; var o = /msie|trident/ig; var p = o.test(q); var t = /msie 6/i.test(q); var s = /msie 7/i.test(q); var r = /msie 8/i.test(q); if (r || t || s) { h(); g(); d() } }) })(window.$ || window.jquery); /** * created by jiangw on 2017/2/20. * 分站信息替换(发布后的页面生效) * subname - 分站名称 * subdomain - 分站地址 * fullcustomername - 公司名称 * fixedphonenum - 固定电话 * phone400 - 400电话 * fax - 传真 * address - 地址 * contactname - 联系人姓名 * contactphonenumber - 联系人电话 * contactemail - 联系电子邮件 * qq - qq号码 */ (function () { "use strict"; var subdomain = {}; subdomain.init = function init(type) { var scope = this; if (/(\/pccms\/js\/template)/.test(top.window.location.pathname)) { return; } if (!window.$ && !window.jquery) { scope.parallelloadscripts("//cdn.bootcss.com/jquery/1.11.3/jquery.min.js", function () { scope.loadtypeparams(type); }); } else { scope.loadtypeparams(type); } }; /** * 用于区分当前访问的设备类型 * @param type - 固定类型(可选) */ subdomain.loadtypeparams = function loadtypeparams(type) { var scope = this, params = {}; var baseurl = $('[data-base]').attr('data-base') || '/'; params.url = 'http://' + window.location.host + baseurl + 'subdomain.js'; params.type = type ? string(type) : '' || scope.isphone() ? '5' : '4'; switch (params.type) { case "4": params.subbefore = new regexp('^(http:\/\/)*(' + location.host + ')\/*$'); params.subafter = "subdomain"; break; case "5": params.subbefore = new regexp('^(' + scope.getstorage() + ')$'); params.subafter = "contactphonenumber"; break; } scope.filterdata(params.type, params.url, params.subbefore, params.subafter); }; /** * 请求并筛选主站和分站信息 * @param type - 设备类型 * @param url - subdomain.js的url地址 * @param subbefore - 判断是否分站的依据 * @param subafter - 判断是否分站的依据 */ subdomain.filterdata = function filterdata(type, url, subbefore, subafter) { var scope = this; var ajax = $.ajax({ url: url, type: "get", datatype: "json", cache: false }); ajax.done(function (data) { var domainarray = [{}, []]; $.each(data, function (i, item) { if (item.ismain) { domainarray[0] = item; } if (item.projtype === type) { domainarray[1].push(item); } }); // 主站匹配 // scope.fillcontent(domainarray[0]); scope.filterdomain(domainarray[1], subbefore, subafter); }); ajax.fail(function () { console.log('当前项目没有分站信息'); }); }; /** * 筛选满足的分站信息并启动替换 * @param data - 分站列表 * @param subbefore - 判断是否分站的依据 * @param subafter - 判断是否分站的依据 */ subdomain.filterdomain = function filterdomain(data, subbefore, subafter) { var scope = this; $.each(data, function (i, item) { if (subbefore.test(item[subafter])) { scope.fillcontent(item); } }); }; /** * 获取页面对应对象进行替换 * @param domaindata - 分站信息 */ subdomain.fillcontent = function fillcontent(domaindata) { var scope = this; if (domaindata) { var attr = [ "subname", "subdomain", "fullcustomername", "fixedphonenum", "phone400", "fax", "address", "contactname", "contactphonenumber", "contactemail", "qq" ]; $.each(attr, function (index, value) { var el = $("[" + value + "]"); $.each(el, function (indexchild, elchild) { if (!$(elchild).attr(value)) { scope.autosetcontent($(elchild), value, domaindata[value]); } else { scope.userdefinedcontent($(elchild), value, domaindata[value]); } }); }); } else { localstorage.removeitem("nswtel"); } }; subdomain.autosetcontent = function autosetcontent(el, key, content) { switch (key) { case "contactphonenumber": el.attr("href", "tel:" + content); break; case "contactemail": el.attr("href", "mailto:" + content); break; case "qq": el.attr("href", "http://wpa.qq.com/msgrd?v=3&uin=" + content + "&site=qq&menu=yes"); break; case "phone400": el.attr("href", "tel:" + content); break; } this.setdomtext(el, content); }; /** * 判断文本内容并替换 * @param el - dom对象 * @param text - 内容 */ subdomain.setdomtext = function setdomtext(el, text) { if (el[0].children.length > 0) { return; } $.map(el[0].childnodes, function (item) { if (item.nodetype === 3) { el.text(text); } }); }; /** * 自定义规则内容替换 * @param el - dom对象 * @param key - 分站索引字段 * @param content - 分站内容 */ subdomain.userdefinedcontent = function userdefinedcontent(el, key, content) { var attrnames = el.attr(key).split(','); $.each(attrnames, function (index, attrname) { var attrcontent = (el.attr('sd-' + attrname) || '').replace(/(\$\$)/g, content) || content; if (attrname === 'text') { el.text(attrcontent); } else { el.attr(attrname, attrcontent); } el.removeattr('sd-' + attrname); }); }; /** * 获取localstorage的tel数据 */ subdomain.getstorage = function getstorage() { var param = this.parseurl(location.href); if (param.tel) { param = param.tel; localstorage.nswtel = param; } else { if (localstorage.nswtel) { param = localstorage.nswtel; } else { param = ""; } } return param; }; /** * 判断当前是否移动设备 * @returns {boolean} */ subdomain.isphone = function isphone() { var isphone = false; var ua = navigator.useragent; var ipad = ua.match(/(ipad).*os\s([\d_]+)/), isiphone = !ipad && ua.match(/(iphone\sos)\s([\d_]+)/), isandroid = ua.match(/(android)\s+([\d.]+)/), ismobile = isiphone || isandroid; if (ismobile) { isphone = true; } return isphone; }; /** * 转换网页地址的参数为json * @param url - 网页地址 * @returns {{}} - 参数的json对象 */ subdomain.parseurl = function parseurl(url) { var reg_url = /^[^\?]+\?([\w\w]+)$/, reg_para = /([^&=]+)=([\w\w]*?)(&|$|#)/g, arr_url = reg_url.exec(url), ret = {}; if (arr_url && arr_url[1]) { var str_para = arr_url[1], result; while ((result = reg_para.exec(str_para)) !== null) { ret[result[1]] = result[2]; } } return ret; }; /** * 动态添加js文件 * @param scripts - js地址列表 * @param callback - 回调方法 */ subdomain.parallelloadscripts = function parallelloadscripts(scripts, callback) { if (typeof(scripts) !== "object") { scripts = [scripts]; } var head = document.getelementsbytagname("head").item(0) || document.documentelement, s = [], loaded = 0; for (var i = 0; i < scripts.length; i++) { s[i] = document.createelement("script"); s[i].setattribute("type", "text/javascript"); s[i].onload = s[i].onreadystatechange = function () { if (!/*@cc_on!@*/0 || this.readystate === "loaded" || this.readystate === "complete") { loaded++; this.onload = this.onreadystatechange = null; this.parentnode.removechild(this); if (loaded === scripts.length && typeof(callback) === "function") { callback(); } } }; s[i].setattribute("src", scripts[i]); head.appendchild(s[i]); } }; subdomain.init(); })();