(function($) { $.Openzc = function() { this.Run =function () { Openzc.msgBox(); $('.openzc-keyup').unbind('keyup').bind('keyup',function(){ //$(this).unbind(); var othis = $(this); if(othis.val()==""){Openzc.ajaxLoding("off");return false;} $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis); }); }); $('.openzc-input').unbind('change').bind('change',function(){ //$(this).unbind(); var othis = $(this); if(othis.val()==""){Openzc.ajaxLoding("off");return false;} $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis); }); }); $('.openzc-btn').unbind('click').bind('click',function(){ var othis = $(this); $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis); }); }); $(".openzc-submit").unbind('click').bind('click',function(){ var FormData=$(this).closest(".openzc-form").serializeArray(); FormData.push({"name":"submit","value":$(this).val()}); $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.openzcForm(FormData); }); return false; }); $('.openzc-form').unbind('submit').bind('submit',function(e){ //$(this).unbind(); var FormData=$(this).serializeArray(); $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.openzcForm(FormData); }); return false; }); $('.openzc-select').unbind('change').bind('change',function(){ //$('.openzc-select').on('change', function(){ var othis = $(this); var data = othis.data(); if(othis.val()==""){Openzc.ajaxLoding("off");return false;} if(data['action']=="autoSubmit"){ $("#"+data['form']).submit(); } if(data['action']=="autoLink"){ if(data['reload']){ $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis); }); }else{ self.location.href=othis.val(); } return false; } $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis); }); }); Openzc.autoLoad(".openzc-load"); }, this.active =function (othis,data=[]) { if(data.length==0){var data=othis.data();} if(data['action']=="listFlow"){ data['url']=window.location.href; }else{ data['value']=othis.val(); } if(data['action']=="autoLink"){ data['action']="getHtml"; data['url']=othis.val(); } var position=Openzc.getCookie("position"); var url="index.php"; data['securityToken']=securityToken; data['position']=position; data["config"]=Openzc.config; if(data['url']=="javascript:void(0)"){ Openzc.ajaxLoding("off");return false; } if(data['url']){ url=data['url']; } Openzc.ajaxpost(url,"post",data); }, this.token=function(){ Openzc.ajaxLoding("on"); var data={}; data['action']="securityToken"; var token=Openzc.ajaxpost("index.php?sessions=true","get",data); return token; return false; }, this.initslideprice=function(){ Openzc.ajaxLoding("on"); var slideprice=Openzc.getCookie("slideprice"); if(slideprice!=="false"){ var data={}; data["securityToken"]=securityToken; data['action']="initslideprice"; Openzc.ajaxpost("index.php","post",data); } return false; }, this.getslideprice=function(){ var data=decodeURIComponent(Openzc.getCookie("slideprice")); data=JSON.parse(data); return data; }, this.openzcForm=function(Formdata){ var data={}; $.each(Formdata,function(){data[this.name]=this.value;}); data["securityToken"]=securityToken; var position=Openzc.getCookie("position"); data["position"]=position; data["config"]=Openzc.config; var url="index.php"; if(data['action']=="slidePrice"){ url=window.location.href; data['url']=url; } $.when(jQuery.ajax({ type:'post', url:url, data:data, async:false, success:function (result){ result=JSON.stringify(result); Openzc.ajaxRun(result); } })).then(function(){ Openzc.ajaxLoding("off"); }); return false; }, this.ajaxpost=function(url,method,data){ var rs; $.when(jQuery.ajax({ type:method, url:url, data:data, async:false, success:function(result){ rs=result; if(data['action']!=='securityToken' && result['action']!=="getUrl"){ result=JSON.stringify(result); Openzc.ajaxRun(result); } } })).then(function(){ Openzc.ajaxLoding("off"); }); if(data['action']=="securityToken"){return rs['data'];} return false; }, this.ajaxRun=function(data){ data=JSON.parse(data); Openzc.result=data; if(data['action']=="slidePrice"){history.pushState(null,null,data['url']);} if(data['action']=='initslideprice'){return false;} var scriptList=[]; $.each(data["jquery"],function(key,value){$.getScript(value);scriptList.push(value);}); $.when($,scriptList).done( $.each(data,function(action,list){ switch(action){ case "reload": if(list=="null"){ if(data.hasOwnProperty('url')){window.location.href = data['url'];} else{ window.location.reload(); } return false; } if(data.hasOwnProperty('url')){history.pushState(null,null,data['url']);} var i=0; $.each(list,function(key,value){ i++; if(list['flow']==true){ $(value["div"]).append(value["html"]); if(i==list['count']){ $(data['div']).eq(data['sort']).data('page',data['page']); if(data['page']=="null"){ var div=data['div']+':eq('+data['sort']+')'; $(div+" .openzc-load-btn").css("display","none"); $(div+" .openzc-load-none").css("display","block"); } } }else{ $(value["div"]).html(value["html"]); } if(value['custom_status']==true && data['autoReload']==false){ if($.isFunction(Openzc.customReload)){ Openzc.customReload(value['custom_action'],value); } } }); break; } }) ); if(data["system"]==true){ Openzc.Run(); } return false; }, this.getCookie=function(cookieName){ var cookieValue=""; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; if (cookie.substring(0, cookieName.length + 2).trim() == cookieName.trim() + "=") { cookieValue = cookie.substring(cookieName.length + 2, cookie.length); break; } } } return cookieValue; }, //**Ajax自定义自动刷新内容 this.autoReload=function(){ $(document).ready(function() { var html=Openzc.getCookie("html"); if(Openzc.config){ if(Openzc.config.customAutoload != "undefined" && html=="true"){ Openzc.ajaxLoding("on"); var position=Openzc.getCookie("position"); var data={"reload":Openzc.config.customAutoload,"action":"autoReload","securityToken":securityToken,"config":Openzc.config,"position":position,'autoReload':true}; Openzc.ajaxpost("index.php","post",data); }else{ if(html=="true"){ Openzc.ajaxLoding("on"); var position=Openzc.getCookie("position"); var data={"action":"autoReload","securityToken":securityToken,"position":position,'autoReload':true}; Openzc.ajaxpost("index.php","post",data); } } }else{ if(html=="true"){ Openzc.ajaxLoding("on"); var position=Openzc.getCookie("position"); var data={"action":"autoReload","securityToken":securityToken,"position":position,'autoReload':true}; Openzc.ajaxpost("index.php","post",data); } } return false; }); }, this.autoLoad=function(loadDiv){ $(loadDiv).each(function(i){ var data=$(this).data(); var action = data['action']; var type = data['type']; data['sort']=$(this).index(); data['div']=loadDiv; if (action!="undefined" && type!="undefined" ) { switch(type){ case "auto": var othis = $(this); var bheight = data['bh']; $(window).scroll(function(event){ var wh = $(window).height(), ot = $(loadDiv).eq(data['sort']).offset().top, ds = $(document.documentElement).scrollTop(), btn_h = $(loadDiv).eq(data['sort']).height(); bh = wh - btn_h -(ot-ds); n = 30 ; data['page']=$(loadDiv).eq(data['sort']).data("page"); data['pagecount']=$(loadDiv).eq(data['sort']).data("pagecount"); if(bheight!="undefined"){n=bheight;} if(bh>=n && data['page']!="null"){ $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis,data); }); } }); break; case "click": var div=loadDiv+':eq('+data['sort']+')'; $(div).unbind('click').bind('click',function(){ if(data['page']!="null"){ $.when(Openzc.ajaxLoding("on")).then(function() { Openzc.active(othis,data); }); } }); break; } } }); }, //**添加信息弹窗box this.msgBox=function(){ if($("#msgOpenzc").length == 0){ $('body').prepend('
'+"\r\n"); } }, //**以下函数Loding函数 this.ajaxLoding=function(type){ switch(type){ case "on": loading.showLoading({type:1}); break; case "off": loading.hideLoading(); break; } } }; //**Openzc-Loading const loading={_loadItem:null,_anItem:null,_tipItem:null,_tipLabel:null,_showTip:true,_type:1,showLoading(config){if(this._loadItem){this._loadItem.remove();this._loadItem=null;this._anItem=null;this._tipItem=null;this._showTip=true;this._type=1}if(typeof config=="string"){this._tipLabel=config;this._type=1}else if(typeof config=="object"){this._tipLabel=typeof config.tip=="string"?config.tip:"loading...";this._type=typeof config.type=="number"?config.type:1;this._showTip=typeof config.showTip=="boolean"?config.showTip:true}else{this._tipLabel="loading...";this._type=1}this.createEle()},createEle(){this._loadItem=$(``);this._anItem=$(``);this._tipItem=$(`