aq_auth.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. (function(b,g){
  2. var f=function(){
  3. var d="http:"===document.location.protocol?"http://":"https://";
  4. this.authTypeMap={realname:"实名验证",personal:"个人验证",business:"行业验证",official:"官网验证",enterprise:"企业验证"};
  5. this.authStarMap={personal:0,realname:1,enterprise:1,business:2,official:4};
  6. this._AQ_outer=d+"outer.anquan.org";
  7. this._AQ_domain=d+"www.anquan.org";
  8. this._AQ_static=d+"static.anquan.org";
  9. this._AQ_certificate_url="http://www.anquan.org/authenticate/cert/";
  10. this._AQ_profile_url="http://www.anquan.org/s/";
  11. this._AQ_credit_url="http://v.anquan.org"
  12. };
  13. var a=b,e=g;
  14. f.prototype={
  15. constructor:f,
  16. getById:function(d){
  17. return e.getElementById(d)
  18. },
  19. filter:function(i){
  20. var d=/[<>&"'\x00]/g;
  21. var h={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"};
  22. i=i||"";
  23. return i.replace(d,function(j){
  24. return h[j]||""
  25. })
  26. },
  27. transtyle:function(n){
  28. var m=Array.isArray||function(i){
  29. return Object.prototype.toString.call(i)==="[object Array]"
  30. };
  31. var s="prop:style;";
  32. var q="selector{rule}";
  33. var p=function(i){
  34. if(i.selector){
  35. return q.replace("selector",i.selector).replace("rule",i.rule)
  36. }
  37. if(i.prop){
  38. return s.replace("prop",i.prop).replace("style",i.style)
  39. }
  40. };
  41. var l="";
  42. for( var jinn){
  43. var o="";
  44. var r=n[j];
  45. for( var hinr){
  46. var d=r[h];
  47. if(m(d)){
  48. for(var k=0;k<d.length;k++){
  49. o+=p({prop:h,style:d[k]})
  50. }
  51. }else{
  52. o+=p({prop:h,style:d})
  53. }
  54. }
  55. l+=p({selector:j,rule:o})
  56. }
  57. return l
  58. },
  59. listen_to:function(i,h,d){
  60. if(i.addEventListener){
  61. i.addEventListener(h,d,false)
  62. }else{
  63. if(i.attachEvent){
  64. i.attachEvent("on"+h,function(j){
  65. j||(j=a.event);
  66. if(!j.target){
  67. j.target=j.srcElement
  68. }
  69. d(j)
  70. },false)
  71. }
  72. }
  73. },
  74. ready:function(d){
  75. var j=false;
  76. var k=[];
  77. var l;
  78. ready=function(m){
  79. if(j){
  80. m.call(document)
  81. }else{
  82. k.push(function(){
  83. return m.call(this)
  84. })
  85. }
  86. return this
  87. };
  88. var h=function(){
  89. for(var m=0;m<k.length;m++){
  90. k[m].apply(document)
  91. }
  92. k=null
  93. };
  94. var i=function(m){
  95. if(j){
  96. return
  97. }
  98. j=true;
  99. h.call(window);
  100. if(document.removeEventListener){
  101. document.removeEventListener("DOMContentLoaded",i,false)
  102. }else{
  103. if(document.attachEvent){
  104. document.detachEvent("onreadystatechange",i);
  105. if(window==window.top){
  106. clearInterval(l);
  107. l=null
  108. }
  109. }
  110. }
  111. };
  112. if(document.addEventListener){
  113. document.addEventListener("DOMContentLoaded",i,false)
  114. }else{
  115. if(document.attachEvent){
  116. document.attachEvent("onreadystatechange",function(){
  117. if((/loaded|complete/).test(document.readyState)){
  118. i()
  119. }
  120. });
  121. if(window==window.top){
  122. l=setInterval(function(){
  123. try{
  124. j||document.documentElement.doScroll("left")
  125. }catch(m){
  126. return
  127. }
  128. i()
  129. },5)
  130. }
  131. }
  132. }
  133. ready(d)
  134. },
  135. getElementsByClassName:function(m,k,l){
  136. var h=m.getElementsByTagName(k);
  137. var d=[];
  138. for(var j=0;j<h.length;j++){
  139. if(h[j].className==l){
  140. d[d.length]=h[j]
  141. }
  142. }
  143. return d
  144. },
  145. script_onload:function(d,i,j){
  146. var h=e.createElement("script");
  147. if(h.readyState){
  148. h.onreadystatechange=function(){
  149. if(h.readyState=="loaded"||h.readyState=="complete"){
  150. h.onreadystatechange=null;
  151. j()
  152. }
  153. }
  154. }else{
  155. h.onload=function(){
  156. j()
  157. }
  158. }
  159. h.src=i;
  160. h.type="text/javascript";
  161. h.setAttribute("async","true");
  162. d.appendChild(h)
  163. },
  164. getElByAttr:function(h,p){
  165. var m=[],k=e.getElementsByTagName(p||"*");
  166. for(var n=0,o=k.length;n<o;n++){
  167. var q=k[n],d=true;
  168. for(var l=0;l<h.length;l++){
  169. if(!q.getAttribute(h[l])){
  170. d=false;
  171. break
  172. }
  173. }
  174. if(d){
  175. m.push(q)
  176. }
  177. }
  178. return m
  179. },
  180. getRealWarpNode:function(k,h){
  181. var d,h=h||0;
  182. var i=k.parentNode;
  183. var j=function(l){
  184. return (l.getAttribute("logo_type")&&l.getAttribute("logo_size"))||(l.getAttribute("logo_style")==="fixed")
  185. };
  186. if(!!j(i)){
  187. d=i
  188. }else{
  189. d=this.getElByAttr(["logo_size","logo_type"],"a")[h]||this.getElByAttr(["logo_style","href"],"a")[0]
  190. }
  191. return d
  192. },
  193. insertStyle:function(h){
  194. h=this.transtyle(h);
  195. var d=document.head||document.getElementsByTagName("head")[0];
  196. var i=document.createElement("style");
  197. i.type="text/css";
  198. if(i.styleSheet){
  199. i.styleSheet.cssText=h
  200. }else{
  201. i.appendChild(document.createTextNode(h))
  202. }
  203. d.appendChild(i)
  204. },
  205. fixedSymbol:function(k,t){
  206. var o=this;
  207. o.insertStyle({".AQ__auth-fixed":{position:"fixed",_position:"absolute",right:"0",top:"40%","line-height":"1.5","font-size":"12px","z-index":"2147483646"},".AQ__auth-wrap":{position:"relative"},".AQ__auth-icon":{background:"url("+o._AQ_static+"/static/outer/image/fixed-bg.png) -36px 0 no-repeat",height:"176px",width:"35px",position:"absolute",top:"0",right:"-6px","z-index":"2"},".AQ__auth-icon.active":{"background-position":"0 0",right:"0"},".AQ__auth-info":{position:"absolute",padding:"3px 0",height:"153px",_width:"230px","min-width":"230px",background:"#fff",top:"6px",right:"23px",display:"none",border:"1px solid #ddd"},".AQ__auth-info-hd":{padding:"0px 10px 2px","border-bottom":"1px solid #ddd","font-size":"14px","line-height":"30px",overflow:"hidden"},
  208. ".AQ__auth-info-icon":{"float":"left",background:"url("+o._AQ_static+"/static/outer/image/fixed-bg.png) -70px 2px no-repeat",height:"30px",width:"30px"},".AQ__auth-info-title":{"font-size":"14px",color:"#b48b33","margin-right":"3px","float":"left"},".AQ__auth-info-star":{"float":"left","margin-top":"7px",background:"url("+o._AQ_static+"/static/outer/image/fixed-bg.png) -77px -30px no-repeat",height:"16px",width:"12px"},".AQ__auth-info-bd":{padding:"12px 10px 2px",background:"#f9f9f9","border-bottom":"1px solid #ddd","font-size":"12px"},".AQ__auth-info-bd p":{margin:"0 0 8px 0","white-space":"nowrap",_overflow:"hidden"},".AQ__auth-info-ft":{padding:"5px 10px"},".AQ__auth-info-ft a":{color:"#b48b33","font-size":"12px","margin-right":"14px","text-decoration":"underline"},
  209. ".AQ__auth-info-ft a:hover":{color:"#CF9F39"}});
  210. var r=['<div class="AQ__auth-wrap">','<a class="AQ__auth-icon AQ__js-auth-icon" href="javascript:;"></a>','<div class="AQ__auth-info">','<div class="AQ__auth-info-hd">','<i class="AQ__auth-info-icon"></i><span class="AQ__auth-info-title">{{auth_type}}</span>{{star}}',"</div>",'<div class="AQ__auth-info-bd">','<p title="{{name}}">{{name}}</p>','<p style="color: #737373;">单位类型:{{type}}</p>','<p style="color: #737373;">信用累计:<span style="color: #b48b33">{{year}}</span></p>',"</div>",'<div class="AQ__auth-info-ft">','<a href="{{certificate_url}}" target="_blank">诚信档案</a>','<a href="{{profile_url}}" target="_blank">用户评论</a><a href="{{credit_url}}" target="_blank">防伪查询</a>',"</div>","</div>","</div>"];
  211. var p=e.createElement("div");
  212. p.className="AQ__auth-fixed";
  213. p.id="AQ__js-auth-fixed";
  214. o.listen_to(p,"click",function(v){
  215. var i=v.target;
  216. var d=i.className;
  217. if(/AQ__js-auth-icon/.test(d)){
  218. if(/active/.test(d)){
  219. i.className=d.replace("active","");
  220. i.nextSibling.style.display="none"
  221. }else{
  222. i.className=d+" active";
  223. i.nextSibling.style.display="block"
  224. }
  225. }
  226. });
  227. var l="",n=o.authStarMap[t]||0;
  228. for(var m=0;m<n;m++){
  229. l+='<i class="AQ__auth-info-star"></i>'
  230. }
  231. var j=t==="realname"?"id":t;
  232. var s={auth_type:o.authTypeMap[t],star:l,name:k.org_name,type:k.site_type,year:"第"+k[j+"_verify_year"]+"年",profile_url:o._AQ_profile_url+k.domain+"?tab=comment",credit_url:o._AQ_credit_url+"?domain="+k.domain,certificate_url:o._AQ_certificate_url+"?site="+k.domain+"&at="+t};
  233. var u=r.join("");
  234. for( var qins){
  235. var h=new RegExp("\\{\\{"+q+"\\}\\}","g");
  236. u=u.replace(h,s[q])
  237. }
  238. p.innerHTML=u;
  239. e.getElementsByTagName("body")[0].appendChild(p)
  240. },isMatchedAuth:function(i,h){
  241. var d=false;
  242. if(i.is_match){
  243. if(h){
  244. return h
  245. }
  246. switch(true){
  247. case i.personal_auth&&i.type==="personal":
  248. d="personal";
  249. break;
  250. case i.realname_auth&&i.type==="realname":
  251. d="realname";
  252. break;
  253. case i.business_auth&&i.type==="business":
  254. d="business";
  255. break;
  256. case i.official_auth&&i.type==="official":
  257. d="official";
  258. break;
  259. case i.enterprise_auth&&i.type==="enterprise":
  260. d="enterprise";
  261. break
  262. }
  263. }
  264. return d
  265. },init:function(){
  266. var i=this;
  267. var h="AQ_fn_aq_auth_callback";
  268. a.LOGO__aq_num__=a.LOGO__aq_num__||1;
  269. var d="AQ_logo_span_init_"+a.LOGO__aq_num__;
  270. a[h]=function(n,s,o){
  271. try{
  272. if(!(ninstanceofObject)){
  273. return false
  274. }
  275. }catch(r){
  276. }
  277. var t=i.getRealWarpNode(i.getById("AQ_logo_span_init_1"));
  278. s&&(t=i.getRealWarpNode(s,o));
  279. a.LOGO__aq_callback_data__=n;
  280. var l=i.filter(t.getAttribute("logo_style"));
  281. var j={is_match:/true/.test(n.is_match.toLowerCase()),personal_auth:/successful/.test(n.personal_status.toLowerCase()),realname_auth:/successful/.test(n.realname_status.toLowerCase()),official_auth:/successful/.test(n.official_status.toLowerCase()),business_auth:/successful/.test(n.business_status.toLowerCase()),enterprise_auth:/successful/.test(n.enterprise_status.toLowerCase()),identify_data:n.identify_data};
  282. if(l==="fixed"){
  283. if(j.official_auth){
  284. j.type="official"
  285. }else{
  286. if(j.business_auth){
  287. j.type="business"
  288. }else{
  289. if(j.realname_auth){
  290. j.type="realname"
  291. }else{
  292. if(j.enterprise_auth){
  293. j.type="enterprise"
  294. }else{
  295. if(j.personal_auth){
  296. j.type="personal"
  297. }else{
  298. j.type=false
  299. }
  300. }
  301. }
  302. }
  303. }
  304. var u=i.isMatchedAuth(j,j.type);
  305. if(i.getById("AQ__js-auth-fixed")||!u){
  306. return
  307. }
  308. i.fixedSymbol(j.identify_data,u)
  309. }else{
  310. j.size=i.filter(t.getAttribute("logo_size").toLowerCase());
  311. j.type=i.filter(t.getAttribute("logo_type"));
  312. var m=e.createElement("img"),p=j.size.toLowerCase(),q,k;
  313. switch(j.type){
  314. case "personal":
  315. k="gr_";
  316. break;
  317. case "realname":
  318. k="sm_";
  319. break;
  320. case "business":
  321. k="hy_";
  322. break;
  323. case "official":
  324. k="gw_";
  325. break;
  326. case "enterprise":
  327. k="qy_";
  328. break;
  329. default:
  330. k=void 0
  331. }
  332. if((j.size!="124x47"&&j.size!="83x30")||k===void 0){
  333. return false
  334. }
  335. q=i.isMatchedAuth(j)?".png":"_gray.png";
  336. m.src=i._AQ_static+"/static/outer/image/"+k+p+q;
  337. m.style.border="none";
  338. m.setAttribute("alt","安全联盟认证");
  339. m.width=parseInt(j.size.split(/x/)[0]);
  340. m.height=parseInt(j.size.split(/x/)[1]);
  341. t.appendChild(m)
  342. }
  343. };
  344. e.write("<span style='display:none;' class='LOGO_aq_jsonp_wrap_' id='"+d+"'></span>");
  345. a.LOGO__aq_num__++;
  346. i.ready(function(){
  347. if(a.LOGO__aq_callback_flag__){
  348. return false
  349. }
  350. var k=i.getElementsByClassName(document,"span","LOGO_aq_jsonp_wrap_");
  351. var s="";
  352. for(var n=0;n<k.length;n++){
  353. var p=k[n];
  354. var r=i.getRealWarpNode(p);
  355. var j=r.getAttribute("logo_type");
  356. var l=r.getAttribute("logo_style");
  357. if("fixed"===l){
  358. for(typeini.authTypeMap){
  359. if(-1!==s.indexOf(type)){
  360. continue
  361. }
  362. s+="&logo_type="+type
  363. }
  364. }else{
  365. if(-1!==s.indexOf(j)){
  366. continue
  367. }
  368. s+="&logo_type="+j
  369. }
  370. }
  371. var m=k[0],r=i.getRealWarpNode(m),q=top.location.href.split("#")[0].split("?")[0],q=q.replace(/(https?:\/\/)([^\.]+\.[^\.\/]+\/)/,"$1www.$2/$3"),o=i._AQ_outer+"/query_auth_status/?callback="+h+"&url="+q+s;
  372. i.script_onload(m,o,function(){
  373. for(var x=0;x<k.length;x++){
  374. var v=i.getRealWarpNode(k[x]);
  375. var w=i.filter(v.getAttribute("logo_type"));
  376. v.href=i._AQ_domain.replace("https://","http://")+"/authenticate/cert/?site="+e.domain+"&at="+w;
  377. v.target="_blank";
  378. if(x<1){
  379. continue
  380. }
  381. var u=a[h],t=a.LOGO__aq_callback_data__;
  382. u(t,k[x],x)
  383. }
  384. a.LOGO__aq_callback_flag__=null;
  385. a.LOGO__aq_callback_data__=null;
  386. a.LOGO__aq_num__=null
  387. });
  388. a.LOGO__aq_callback_flag__=!!1
  389. })
  390. }};
  391. var c=new f();
  392. c.init()
  393. })(window,document);