hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
1
2
"use strict";function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!_instanceof(e,t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}var Demo=function(){function e(t,n){_classCallCheck(this,e),this.options=Object.assign({prefix:"demo",theme:"light",name:"demo",ajax:!0,scroll:!0,api:"",ajaxCode:200,ajaxCookie:!1,debugger:!1,log:!0,plugins:[]},t||{}),this.const("version","1.0.62"),this.$={dom:function(e){return e?document.querySelector(e):null},all:function(e){if(!e)return[];var t=document.querySelectorAll(e);return t.length>0?Array.from(t):[]},id:function(e){return e?document.getElementById(e):null},name:function(e){if(!e)return[];var t=document.getElementsByName(e);return t.length>0?Array.from(t):[]},tag:function(e){if(!e)return[];var t=document.getElementsByTagName(e);return t.length>0?Array.from(t):[]}},this.model={error:function(e,t){return{code:0,err:e,by:t||"validate"}},success:function(e,t){return{code:1,err:e||"success",by:t||"validate"}}},this._init(function(e){n&&n(e)})}return _createClass(e,[{key:"js",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e,r=this;return t&&(n=this.$.dom(e)),n?{dom:function(){return n},html:function(e){if(!arguments.length)return n.innerHTML;var t=r._is_obj(e).code;4!==t&&6!==t||(e=JSON.stringify(e)),n.innerHTML=e},text:function(e){if(!arguments.length)return n.innerText;n.innerText=e},brother:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e?n.parentNode.querySelector(e):n},addClass:function(e){if(4===r._is_obj(e).code)return e.forEach(function(e){n.classList.add(e)}),1;n.classList.add(e)},removeClass:function(e){var t=n.className;if(4===r._is_obj(e).code)return e.forEach(function(r){t.indexOf(r)>=0&&n.classList.remove(e)}),1;t.indexOf(e)>=0&&n.classList.remove(e)},toggleClass:function(e){var t=function(t){n.className.indexOf(t)>=0?n.classList.remove(e):n.classList.add(e)};if(4===r._is_obj(e).code)return e.forEach(function(e){t(e)}),1;t(e)},append:function(e){if(!e)return 0;n.innerHTML+=e},appendChild:function(e){if(!e)return 0;n.appendChild(e)},remove:function(){n.parentNode.removeChild(n)},style:function(e){var t="";if(6===r._is_obj(e).code)for(var o in e)t+="".concat(o,":").concat(e[o],";");else t=e;n.setAttribute("style",t)},attr:function(e,t){if(!(arguments.length>1))return n.getAttribute(e);n.setAttribute(e,t)},click:function(e){arguments.length>0?n.onclick=function(t){r.focus(this),e(this,t)}:n.click()},json:function(e){e=e||{},n.innerHTML=r.showJson(e)},width:function(e){if(!arguments.length)return n.clientWidth;n.style.width=isNaN(e)?e:e+"px"},height:function(e){if(!arguments.length)return n.clientHeight;n.style.height=isNaN(e)?e:e+"px"},square:function(e,t){if(!e)return{w:n.clientWidth,h:n.clientHeight};t||(t=e),r.js(n,0).width(e),r.js(n,0).height(t)},form:function(e){var t=n.querySelectorAll("[data-input]"),o=[];if(t.length)for(var i=0;i<t.length;i++)t[i]&&o.push({key:t[i],val:t[i].value||t[i].getAttribute("data-value")||"",name:t[i].name||t[i].getAttribute("data-name")||"form-"+r.rand(1e3,9999),rule:t[i].getAttribute("data-rule")||"",range:(t[i].getAttribute("data-range")||"6-18").split("-"),message:t[i].getAttribute("data-error")||t[i].getAttribute("data-message")||""});return arguments.length&&e(o),o},val:function(e){if(!arguments.length)return n.value;n.value=e},input:function(e){arguments.length&&(n.oninput=function(t){e(this,t)})},keydown:function(e){arguments.length&&(n.onkeydown=function(t){t=t||window.event;var r={event:t,code:t.keyCode,value:this.value,key:t.key,dom:n};e(r,this)})},find:function(e){var t=function(e){var t=[];return e.forEach(function(e){t.push({name:e.replace(/[.|#]/,""),dom:Array.from(n.querySelectorAll(e))})}),t};return 4===r._is_obj(e).code?t(e):arguments.length>1?t([e])[0].dom:n.querySelector(e)},video:function(e){for(var t in e=Object.assign({"x5-video-player-type":"h5","x5-video-player-fullscreen":"false"},e||{}),e)n.setAttribute(t,e[t])},index:function(){var e=0;do{e++}while(n=n.previousElementSibling);return e},offset:function(){var e=n.getBoundingClientRect(),t=document.body;return{top:e.top+t.scrollTop,left:e.left+t.scrollLeft,self:{top:e.top,left:e.left}}},replaceVal:function(e){e=e||/[^\u4e00-\u9fa5]/g;var t=function(t){var n=t.value;t.value=n.replace(new RegExp(e),"")};n.onfocus=function(e){t(e.target)},n.onkeyup=function(e){t(e.target)},n.onblur=function(e){t(e.target)}},child:function(e){return Array.from(e?n.querySelectorAll(e):n.children)},bgc:function(e){var t=r.js(n,0).child("[data-background-list]");return t.length&&(e=e||"green|#18bc9c",t.forEach(function(t){var n=t.getAttribute("data-bgc")||e;n=n.split("|"),1===n.length&&(n[1]=n[0]),t.style.background=r.algorithm().gradients(1*(n[2]||90),n[0],n[1]||"")})),t},show:function(){var e=n.getAttribute("data-fade")||"hide";if("hide"===e){var t=0;n.style.display="",n.setAttribute("data-fade","show");var r=function e(){n.style.opacity=t>1?1:t,t+=Math.random()/10,t<1.001&&setTimeout(function(){e()},50)};r()}return n},hide:function(){var e=n.getAttribute("data-fade")||"show";if("show"===e){var t=1,r=function e(){n.style.opacity=t<0?0:t,t-=Math.random()/10,t>-.001?setTimeout(function(){e()},50):(n.style.display="none",n.setAttribute("data-fade","hide"))};r()}return n},toggle:function(){var e=n.getAttribute("data-fade")||"";return r.js(n,0)["show"===e?"hide":"show"]()}}:{}}},{key:"validate",value:function(e,t,n){var r,o,i,a=2,c="error";switch(e.toLowerCase()){case"number":case"num":a=1!==this._is_obj(1*t).code||isNaN(t)?0:1;break;case"array":case"arr":a=4===this._is_obj(t).code&&t.length?1:0;break;case"object":case"obj":a=6===this._is_obj(t).code?1:0;break;case"string":case"str":a=3===this._is_obj(t).code?1:0;break;case"tel":case"phone":a=/^[1][3,4,5,7,8][0-9]{9}$/.test(t)?1:0;break;case"email":a=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(t)?1:0;break;case"equal":case"null":a=""!==t&&null!=t&&""!==(t+"").split("").join("")?1:0;break;case"length":t=t||{},o=t.min||6,i=t.max||18,r=t.val||"",r.length<o?(a=0,c="length is small"):r.length>i?(a=0,c="length is lang"):a=1;break;case"age":a=t<=199&&t>0?1:0,c="age is 1-199";break;case"sex":t*=1,a=[0,1,2].indexOf(t)>=0?1:0,c="sex is 0-2"}return a=a?this.model.success():this.model.error(c),n&&n(a),a}},{key:"form",value:function(e,t){var n,r,o=this.js(e).form(),i=this.model.success();if(o.length){for(var a=0;a<o.length;a++)if(i="length"===o[a].rule?this.validate(o[a].rule,{val:o[a].val,min:o[a].range[0],max:o[a].range[1]}):this.validate(o[a].rule,o[a].val),!i.code){n=o[a].name,r=o[a].key,o[a].message&&(i.err=o[a].message);break}i.event=[],i.val=o.map(function(e){return i.event.push(e.key),{val:e.val,name:e.name,event:e.key}}),i.obj={},i.val.length&&i.val.forEach(function(e){i.obj[e.name]=e.val})}return n&&(i.by=n,i.target=r),arguments.length>1&&t(i),i}},{key:"loading",value:function(e){var t=Object.assign({theme:this.options.theme,dom:"body"},e||{}),n=this,r=n.options.prefix+"_loading",o=n.$.dom("."+r);if(o&&"body"===t.dom)return o.className=r+(""===t.theme?"":" "+t.theme),!1;var i=document.createElement("div");return i.setAttribute("class",r+(""===t.theme?"":" "+t.theme)),t.id&&i.setAttribute("id",n.options.prefix+"-"+t.id),"body"===t.dom?document.body.appendChild(i):(i.setAttribute("style","position:absolute"),n.$.dom(t.dom).appendChild(i)),i}},{key:"alert",value:function(e,t,n,r){var o=Object.assign({title:"",timeout:2e3,screen:0,sty:"alert",btnSuccessText:"确定",btnErrorText:"取消",btnSuccessStyle:"",btnErrorStyle:""},n||{});t=t||0;var i=this,a=null,c=arguments.length>3;o.screen&&(a=i.loading({theme:i.options.theme+" model",id:"loading-"+i.rand(1e3,9999)}));var s=function(e,t){var n=arguments.length;e&&(e.classList.add("hidden"),setTimeout(function(){e&&(i.remove(e),e=null),a&&(i.remove(a),a=null),n>1&&t(),c&&r({code:1,type:"all",status:"remove",options:o.data||{}})},200))};if(t>99){var u=i.js("body").find("[id^='"+i.options.prefix+"-alert-']"),l=i.js("body").find('[id^="'+i.options.prefix+'-loading-"]');return u&&(l&&(a=l),s(u)),l=null,u=null,0}var d=i.options.prefix+"_model."+o.sty,f=i.$.dom("."+d);if(f)return s(f,function(){f=null,i.alert(e,t,n)}),!1;var h=document.createElement("div"),m=["error","success","warning","default"];t=t>=m.length?m.length-1:t,h.setAttribute("class",d.replace("."," ")+" hidden "+m[t]),h.setAttribute("id",i.options.prefix+"-alert-"+i.rand(1e3,9999)),"object"===i._is_obj(e).type&&(e=JSON.stringify(e));var v="",p="_"+i.rand(1e3,9999)+"-";o.title&&(v+='<h3 class="title">'+o.title+"</h3>"),v+='<i class="close"></i>',v+='<p class="msg">'+(void 0===e?"":e)+"</p>","alert"!==o.sty&&(v+='<div class="btn">',v+='<button class="m_btn '+o.btnSuccessStyle+'" id="'+p+'s">'+o.btnSuccessText+"</button>",v+='<button class="m_btn '+o.btnErrorStyle+'" id="'+p+'e">'+o.btnErrorText+"</button>",v+="</div>"),h.innerHTML=v,document.body.appendChild(h);var g=h.querySelector(".close"),y=h.querySelector("#"+p+"s"),b=h.querySelector("#"+p+"e");"alert"===o.sty&&c&&r({code:1,type:"alert",status:"create",options:o.data||{}}),g&&(g.onclick=function(){s(h)}),c&&(r({code:3e3,box:h}),y&&(y.onclick=function(){i.btn(y,function(){r({btn:"success",t:y,code:1,box:h,options:o.data||{}}),s(h)})}),b&&(b.onclick=function(){i.btn(b,function(){r({btn:"error",t:b,code:0,box:h,options:o.data||{}}),s(h)})})),setTimeout(function(){h.classList.remove("hidden")},50),o.timeout>500&&i._timers("alert_timer",function(e){e&&s(h)},0,o.timeout)}},{key:"btn",value:function(e,t,n){var r=this;if(n=n||0,null!==r.btn_timer)return t({code:0,err:"click error"}),!1;var o=arguments.length>1?1:0,i=Date.now();if(o&&t({code:1,err:"click start",time:i}),n=n<1?0:n,n<1)return r.btn_timer&&(clearInterval(r.btn_timer),r.btn_timer=null),!1;3===r._is_obj(e).code&&(e=r.$.dom(e)),e.setAttribute("disabled","disabled");var a=e.innerHTML;e.innerHTML=n+"s",r.btn_timer=setInterval(function(){n--,e.innerHTML=n+"s",o&&t({code:3,err:"loading",time:n}),n<=0&&(e.innerHTML=a,e.removeAttribute("disabled"),clearInterval(r.btn_timer),r.btn_timer=null,a=null,o&&t({code:2,err:"click reset"}))},1e3)}},{key:"rand",value:function(e,t){return e*=1,1===arguments.length?(e=e>9?9:e<1?1:e,t=1*("1e"+e)-1,e=1*("1e"+(e-1)),Math.floor(Math.random()*(t-e+1)+e)):!t&&arguments.length>1?Math.floor(Math.random()*e):(t*=1,Math.floor(Math.random()*(t-e+1)+e))}},{key:"remove",value:function(e){return e&&e.parentNode&&(e.parentNode.removeChild(e),e=null),1}},{key:"timeout",value:function(e,t,n){function r(e){return"星期"+["日","一","二","三","四","五","六"][e]}function o(e){return e<10?"0"+e:e}function i(e,t,n){return n?e.y+t+e.m:e.y+t+e.m+t+e.d}function a(e,t,n){return n?e.h+t+e.i:e.h+t+e.i+t+e.s}function c(e,t){return e.m+t+e.d}e&&!isNaN(e)||(e=Date.now()),e=parseInt(e),n=n||"/",(e+"").length>10&&(e=Math.floor(e/1e3));var s=new Date(1e3*e),u=s.getDay(),l={y:s.getFullYear(),m:s.getMonth()+1,d:s.getDate(),h:s.getHours(),i:s.getMinutes(),s:s.getSeconds(),ms:s.getMilliseconds(),default:e,w:r(u),week:u};u=null,s=null,e=null,l.m=o(l.m),l.d=o(l.d),l.h=o(l.h),l.i=o(l.i),l.s=o(l.s);var d="";switch(t){case"alls":d=i(l,n)+" "+a(l,":");break;case"ymd":d=i(l,"");break;case"y-m-d":d=i(l,"-");break;case"y/m/d":d=i(l,n);break;case"y/m":d=i(l,n,1);break;case"m/d":d=c(l,n);break;case"m/d:h":d=c(l,n)+" "+l.h;break;case"m/d:h:i":d=c(l,n)+" "+a(l,":",1);break;case"m/d:h:i:s":d=c(l,n)+" "+a(l,":");break;case"his":d=a(l,"");break;case"h:i:s":d=a(l,":");break;case"h:i":d=a(l,":",1);break;case"i:s":d=l.i+":"+l.s;break;case"i:s:ms":d=l.i+":"+l.s+":"+l.ms;break;case"array":d=[l.y,l.m,l.d,l.h,l.i,l.s,l.ms];break;case"object":d=l;break;case"zero":d=new Date(i(l,"/")+" 00:00:00").getTime();break;case"day":d=l.week;break;case"rotate":d={s:6*l.s,i:6*(l.i+l.s/60),h:30*(l.h%12+l.i/60)};break;default:d=i(l,n)+" "+a(l,":",1)}return d}},{key:"local",value:function(){return this._storage("localStorage")}},{key:"session",value:function(){return this._storage("sessionStorage")}},{key:"getUrl",value:function(e){if(void 0===e)var t=decodeURI(location.search);else t="?"+e.split("?")[1];var n=new Object;if(-1!=t.indexOf("?"))for(var r=t.substr(1),o=r.split("&"),i=0;i<o.length;i++)n[o[i].split("=")[0]]=decodeURI(o[i].split("=")[1]||"");return n}},{key:"getUrlParam",value:function(e,t){var n=window.location.search.substring(1);arguments.length>1&&(n=t.split("?")[1]);for(var r=decodeURI(n),o=r.split("&"),i=0;i<o.length;i++){var a=o[i].split("=");if(a[0]==e)return a[1]}return null}},{key:"scroll",value:function(e,t){if(!this.$scroll)return!1;var n=new this.$scroll(e,Object.assign({scrollX:!1,scrollY:!0,bounce:!0,click:!0,mouseWheel:!0,probeType:1,scrollbar:!0,preventDefaultException:{tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT|DIV|P)$/}},t||{}));return n}},{key:"click",value:function(e,t){var n=this;if(3===n._is_obj(e).code&&(e=n.js(e).dom()),!(arguments.length>1))return e.click();if(e.length>=1)for(var r=function(){var r="data-tab-click-index";e[o].setAttribute(r,o),e[o].onclick=function(e){n.focus(this),t({index:1*this.getAttribute(r),e:e,dom:this})}},o=0;o<e.length;o++)r();else e.onclick=function(e){n.focus(this),t({index:0,e:e,dom:this})}}},{key:"class",value:function(e){3===this._is_obj(e).code&&(e=this.js(e).dom());var t=[];if(e.length>=1)for(var n=0;n<e.length;n++)t.push(e[n]);else t=[e];return{add:function(e){if(""===e||!e)return!1;t.forEach(function(t){t&&t.className.indexOf(e)<0&&t.classList.add(e)})},remove:function(e){if(""===e||!e)return!1;t.forEach(function(t){t&&t.className.indexOf(e)>=0&&t.classList.remove(e)})},name:function(e){t.forEach(function(t){t&&(t.className=e||"")})}}}},{key:"ajax",value:function(e){var t=this;if(!window.Promise)return{};var n=function(e){var n="";return 6===t._is_obj(e).code?(Object.keys(e).forEach(function(t){n+=t+"="+e[t]+"&"}),n=n.substr(0,n.length-1)):n=e,n};return e=e||"",{get:function(n,r,o,i){var a=t.copy(i||{});"json"===o&&(a["Content-Type"]="application/json"),6===t._is_obj(o).code&&(a=o);var c=arguments.length>1;t.$axios({url:t.options.api+e,method:"get",params:n,timeout:60000,headers:a,withCredentials:t.options.ajaxCookie}).then(function(e){200===e.status&&c&&r(e.data)}).catch(function(e){c&&(e.response?r({code:0,data:e.response,err:e.response.data}):r({code:0,data:e,err:e.message}))})},post:function(n,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3?arguments[3]:void 0,a=arguments.length>1,c=t.copy(i||{});if("json"===o)c["Content-Type"]="application/json";else if("object"===_typeof(n)){var s="";for(var u in n)s+=u+"="+n[u]+"&";n=s.substring(0,s.length-1)}6===t._is_obj(o).code&&(c=o),t.$axios({url:t.options.api+e,method:"post",data:n,timeout:8e4,headers:c,withCredentials:t.options.ajaxCookie}).then(function(e){200===e.status&&a&&r(e.data)}).catch(function(e){a&&(e.response?r({code:0,data:e.response,err:e.response.data}):r({code:0,data:e,err:e.message}))})},upload:function(n,r){var o=arguments.length>1,i=new FormData;if(6===t._is_obj(n).code)for(var a in n)i.append(a,n[a]);else i=n;t.$axios({url:t.options.api+e,method:"post",data:i,headers:{"Content-Type":"multipart/form-data"},withCredentials:t.options.ajaxCookie,timeout:2e4,onUploadProgress:function(e){var t=parseInt(e.loaded/e.total*100)/100;r({code:2,type:"progress",progress:t})}}).then(function(e){200===e.status&&o&&r(e.data)}).catch(function(e){o&&(e.response?r({code:0,data:e.response,err:e.response.data}):r({code:0,data:e,err:e.message}))})},other:function(n,r,o,i,a){var c=t.copy(a||{});if("json"===i)c["Content-Type"]="application/json";else if("object"===_typeof(r)){var s="";for(var u in r)s+=u+"="+r[u]+"&";r=s.substring(0,s.length-1)}6===t._is_obj(i).code&&(c=i);var l=arguments.length>1;t.$axios({url:t.options.api+e,method:n||"get",data:r,timeout:8e3,headers:c,withCredentials:t.options.ajaxCookie}).then(function(e){200===e.status&&l&&o(e.data)}).catch(function(e){l&&(e.response?o({code:0,data:e.response,err:e.response.data}):o({code:0,data:e,err:e.message}))})},plain:function(r,o,i){var a=n(r),c=((i?"":t.options.api)+e).split("?")[0]+(a?"?"+a:""),s=new XMLHttpRequest;s.open("GET",c,!0),s.onreadystatechange=function(){(4==s.readyState&&200==s.status||304==s.status)&&o.call(this,s.responseText)},s.send()},cipher:function(r,o,i){var a=new XMLHttpRequest;a.open("POST",(i?"":t.options.api)+e,!0),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.onreadystatechange=function(){4!=a.readyState||200!=a.status&&304!=a.status||o.call(this,a.responseText)},a.send(n(r))}}}},{key:"$get",value:function(e,t,n){return this.ajax(e).plain(t,n,!0)}},{key:"$post",value:function(e,t,n){return this.ajax(e).cipher(t,n,!0)}},{key:"jsonp",value:function(e,t,n){function r(){return(Math.floor(1e5*Math.random())*Date.now()).toString(16)}function o(e,t){e=e.replace(/=/g,"");var n=[];switch(t.constructor){case String:case Number:case Boolean:n.push(encodeURIComponent(e)+"="+encodeURIComponent(t));break;case Array:t.forEach(function(t){n=n.concat(o(e+"[]=",t))});break;case Object:Object.keys(t).forEach(function(r){var i=t[r];n=n.concat(o(e+"["+r+"]",i))})}return n}function i(e){var t=[];return e.forEach(function(e){"string"==typeof e?t.push(e):t=t.concat(i(e))}),t}return t=t||{},n=n||this.jsonp_timeout,new Promise(function(a,c){function s(e){u(),clearTimeout(m),c({status:400,statusText:"Bad Request"})}function u(){p.removeEventListener("error",s)}if("string"!=typeof e)throw new Error('[jsonp] Type of param "url" is not string.');var l=t.callbackQuery||"callback",d=t.callbackName||"jsonp_"+r();t[l]=d,delete t.callbackQuery,delete t.callbackName;var f=[];Object.keys(t).forEach(function(e){f=f.concat(o(e,t[e]))});var h=i(f).join("&"),m=null;"number"==typeof n&&(m=setTimeout(function(){u(),v.removeChild(p),delete window[d],c({statusText:"Request Timeout",status:408})},n)),window[d]=function(e){clearTimeout(m),u(),v.removeChild(p),a(e),delete window[d]};var v=document.querySelector("head"),p=document.createElement("script");p.addEventListener("error",s),p.src=e+(/\?/.test(e)?"&":"?")+h,v.appendChild(p)})}},{key:"platform",value:function(){var e=navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);if(e){var t=window.navigator.userAgent,n=(window.navigator.appVersion,t.indexOf("Android")>-1||t.indexOf("Linux")>-1),r=!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);if(n)return 1;if(r)return 2}var o=document.body.clientWidth;return o<750?1:0}},{key:"touch",value:function(e,t){function n(n){if(n.preventDefault(),"touchstart"==n.type){var f=n.touches[0];r=Math.floor(f.pageX),o=Math.floor(f.pageY)}else if("touchmove"==n.type)f=n.touches[0],Math.floor(f.pageX),Math.floor(f.pageY);else if("touchend"==n.type||"touchcancel"==n.type){i=Math.floor(n.changedTouches[0].pageX),a=Math.floor(n.changedTouches[0].pageY),c=i-r,s=a-o,u=180*Math.atan2(s,c)/Math.PI;var h={};Math.abs(c)<=1||Math.abs(s)<=1?h={code:0,text:"点击",dire:"click"}:u<45&&u>=-45?h={code:2,text:"右",dire:"right"}:u<135&&u>=45?h={code:3,text:"下",dire:"down"}:u<=180&&u>=135||u>=-180&&u<-135?h={code:4,text:"左",dire:"left"}:u<=-45&&u>=-135&&(h={code:1,text:"上",dire:"up"}),l=Object.assign(l,h),l.target=e,d>0&&t(l)}}"string"==typeof e&&(e=this.$.dom(e));var r,o,i,a,c,s,u,l={view:["pc","android","iphone"][this.$web],code:-1},d=arguments.length;if(!e||!this.$web)return d>1&&t(l),!1;e.addEventListener("touchstart",n,!1),e.addEventListener("touchmove",n,!1),e.addEventListener("touchend",n,!1)}},{key:"showJson",value:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,void 0,2)),e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(e){var t="#ff9b26";return/^"/.test(e)?t=/:$/.test(e)?"#ff4c2f":"#67e66e":/true|false/.test(e)?t="#414fff":/null/.test(e)&&(t="#999"),'<span style="color:'+t+'">'+e+"</span>"})}},{key:"resize",value:function(e,t,n){e=this.$.dom(e)||document.body;var r=arguments.length>1?1:0,o={w:e.clientWidth,h:e.clientHeight},i=this;e.onresize=function(){i._timers("resize_timer",function(n){if(n){var i={w:e.clientWidth,h:e.clientHeight};i.h!==o.h&&i.w!==o.w?i.dire="auto":i.w!==o.w?i.dire="width":i.dire="height",r&&t(i)}},0,n||800)}}},{key:"checkbox",value:function(e){e=Object.assign({name:"check",class:"",type:"checkbox"},e);var t=this;return{add:function(n,r){n=n||[];var o=arguments.length>1?1:0,i=t.model.error("data is []","checkbox");if(!n.length)return o&&r(i),i;n.forEach(function(n,r){n.id=n.id||"check"+t.rand(1e3,9999)+"-"+r,n.value=n.value||"",n.text=n.text||"",n.index=n.index||r,n.disabled=n.disabled||0,n.name=n.name||e.name,n.class=n.class||e.class,n.checked=n.checked||0}),n.sort(function(e,t){return e.index-t.index});var a="",c=[];return n.forEach(function(n,r){delete n.index;var o='<div class="'.concat(t.options.prefix,"_checkbox").concat(n.class?" "+n.class:"",'" data-click><input value="').concat(n.value,'" type="').concat(e.type,'" name="').concat(n.name,'" id="').concat(n.id,'" ').concat(n.disabled?"disabled":""," ").concat(n.checked?"checked":"",'><label for="').concat(n.id,'"><i></i>').concat(n.text,"</label></div>");a+=o,c.push({key:r,val:o,text:n.text})}),i=t.model.success("success","checkbox"),i.str=a,i.val=c,a="",c=null,o&&r(i),i},get:function(e,n){return e=e||{},e=Object.assign({id:"check"+t.rand(1e3,9999),value:"",text:"",index:"",disabled:0,name:"check",class:"",checked:0},e),arguments.length>1&&n(e),e},click:function(e,n){e=t.$.dom(e);var r=arguments.length>1,o=t.model.error("dom is null","checkbox");if(!e)return r&&n(o),o;var i=e.querySelectorAll("[data-click]");if(i.length)for(var a=0;a<i.length;a++)i[a].querySelector("input").onchange=function(e){var t={checked:this.checked,value:this.value||0,t:this,event:e,code:1};r&&n(t)};i=null},all:function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=t.$.dom(e);var o=arguments.length>1,i=t.model.error("dom is null","checkbox");if(!e)return o&&n(i),i;var a=e.querySelectorAll("[data-click]"),c=[];if(a.length)for(var s=0;s<a.length;s++){var u=a[s].querySelector("input");u.disabled||(u.checked=r,u.checked&&c.push({value:u.value||0,id:u.id,text:u.parentNode.querySelector("label").innerText}))}return a=null,i=t.model.success("success","checkbox"),i.data=c,c=null,o&&n(i),i},reverse:function(e,n){e=t.$.dom(e);var r=arguments.length>1?1:0,o=t.model.error("dom is null","checkbox");if(!e)return r&&n(o),o;var i=e.querySelectorAll("[data-click]"),a=[];if(i.length)for(var c=0;c<i.length;c++){var s=i[c].querySelector("input");s.disabled||(s.checked=!s.checked,s.checked&&a.push({value:s.value||0,id:s.id,text:s.parentNode.querySelector("label").innerText}))}return i=null,o=t.model.success("success","checkbox"),o.data=a,a=null,r&&n(o),o},checked:function(e,n){e=t.$.dom(e);var r=arguments.length>1?1:0,o=t.model.error("dom is null","checkbox");if(!e)return r&&n(o),o;var i=e.querySelectorAll("[data-click]"),a=[];if(i.length)for(var c=0;c<i.length;c++){var s=i[c].querySelector("input");s.checked&&a.push({value:s.value||0,id:s.id,text:s.parentNode.querySelector("label").innerText})}return i=null,o=t.model.success("success","checkbox"),o.data=a,a=null,r&&n(o),o}}}},{key:"eval",value:function(e,t){if(!t){var n="(function(){"+e+"})()";return this.fn(n)}var r=document.createElement("script");r.type="text/javascript",r.text=e,document.getElementsByTagName("head")[0].appendChild(r),document.head.removeChild(document.head.lastChild),r=null}},{key:"fn",value:function(e){var t=new Function("return "+e)();return t}},{key:"frame",value:function(e,t){function n(){c=null,s=null,o=null,u=null,l=null,d=null,f=null}e=Object.assign({dom:"body",type:"frame",theme:"shadow_right",title:"Title",header:!0,close:!0,scroll:!1,style:{},move:!1,moveDom:"",id:"frame-"+this.rand(1e3,9999)},e);var r=arguments.length>1,o=this.model.error("dom is null","frame-dom"),i=this.$.dom(e.dom);if(!i)return r&&t(o),o;e.theme=e.theme?e.theme+(e.header?"":" auto"):e.header?"":"auto",e.style["z-index"]||(e.style["z-index"]=Math.ceil((Date.now()-new Date(this.timeout("","y/m/d")).getTime())/1e3));var a="";switch(a+='<div class="'.concat(this.options.prefix,"_frame").concat(e.theme?" "+e.theme:"",' hidden" data-frame id="').concat(e.id,'">'),e.header?(a+='<header class="frame_header"><b>'.concat(e.title,"</b>"),e.close&&(a+='<span class="close" data-frame-close>X</span>'),a+="</header>"):e.close&&(a+='<span class="close" data-frame-close>X</span>'),a+='<div class="frame_main" id="'.concat(e.id,'-main">'),e.type){case"frame":a+='<iframe src="'.concat(e.src,'" frameborder="0"></iframe>');break;case"template":a+='<div class="content" data-frame-content>'.concat(e.template,"</div>");break;default:a+='<div class="content" data-frame-content></div>'}if(a+="</div>",e.foot&&(a+='<div class="frame_foot" id="'.concat(e.id,'-foot"></div>')),a+="</div>","frame"===e.type&&!e.src)return o=this.model.error("frame src is null","frame-src"),r&&t(o),o;if("template"===e.type&&!e.template)return o=this.model.error("frame template is null","frame-template"),r&&t(o),o;i.innerHTML=a,a=null,o=this.model.success("frame create end","frame-create"),r&&t(o);var c=i.querySelector("[data-frame]"),s=i.querySelector("[data-frame-close]"),u=i.querySelector("[data-frame-content]"),l=null,d=null,f=null;if(e.foot&&(d=i.querySelector(".frame_foot"),u.style["padding-bottom"]=d.clientHeight+"px"),e.header&&(f=i.querySelector(".frame_header")),e.style){var h="";for(var m in e.style)m&&(h+="".concat(m,":").concat(e.style[m],";"));h&&c.setAttribute("style",h)}var v=this;if(c)return s&&(s.onclick=function(){c.classList.add("hidden"),setTimeout(function(){v.remove(c),o=v.model.success("frame is delete","frame-delete"),r&&t(o),n()},1e3)}),e.scroll&&u&&(l=v.scroll("#"+e.id+"-main"),o=v.model.success("frame scroll is create success","frame-scroll"),r&&t(o)),e.move&&v.move(c,function(t){t.code?v.js(c,0).style(Object.assign({left:t.left,top:t.top,margin:"0",bottom:"auto",right:"auto",transition:"all 0s"},e.style)):c.style.transition="all .8s"},e.moveDom),o=v.model.success("frame all success","frame-all-"+e.type),o.dom=c,o.doms={scroll:l,close:s,content:u,header:f,footer:d,main:v.$.id(e.id+"-main")},r&&t(o),setTimeout(function(){c.classList.remove("hidden")},50),o;o=v.model.error("frame dom is null","frame-dom-null"),r&&t(o),n()}},{key:"downTime",value:function(e,t,n){function r(e){return e=parseInt(e),e>=10?e+"":"0"+e}n=n||Date.now();var o=arguments.length>1,i=Math.ceil((e-n)/1e3);i=i<1?0:i;var a={all:i,startTime:e,endTime:n};return i>0&&(a.d=r(i/86400),a.h=r(i/3600%24),a.m=r(i/60%60),a.s=r(i%60),a.arr=[a.d,a.h,a.m,a.s]),o&&t(a),a}},{key:"location",value:function(e,t,n){function r(){if(!window.open)return a.alert("window.open is null"),0;var t=window.open("_blank");return t.location=e,t}function o(){return e===window.location.href?(window.location.reload(),!1):"open"===t.target?(r(e),!1):(window.location.href=e,!0)}var i=arguments.length>2,a=this;if(!e)return!1;if(t=Object.assign({time:0,target:""},t),t.time<1)o();else{if(i)var c=1*t.time,s=setInterval(function(){if(c<0)return clearInterval(s),s=null,!1;i&&n(c),c--},1e3);setTimeout(function(){o()},1e3*t.time)}}},{key:"tree",value:function(e,t,n){t=t||"id",n=n||"by";var r=[];if(!Array.isArray(e))return r;e.forEach(function(e){delete e.children});var o={};return e.forEach(function(e){o[e[t]]=e}),e.forEach(function(e){var t=o[e[n]];t?(t.children||(t.children=[])).push(e):r.push(e)}),r}},{key:"focus",value:function(e){return 3===this._is_obj(e).code&&(e=this.$.dom(e)),e.blur?e.blur():this.$.dom("body").focus(),e}},{key:"script",value:function(e,t,n){if(!e)return!1;var r=document.createElement("script");r.type="text/javascript",arguments.length>2?r.text=n:(r.async=!0,r.src=e),arguments.length>1&&(r.onload=t);var o=document.getElementsByTagName("script")[0];return o.parentNode.insertBefore(r,o),r=null,o=null,!0}},{key:"hover",value:function(e,t,n){var r=arguments.length>1,o=arguments.length>2;if(3===this._is_obj(e).code&&(e=this.$.all(e)),!r)return e;if(e.length>=1)for(var i=0;i<e.length;i++)e[i].setAttribute("data-tab",i),e[i].onmouseenter=function(e){t({index:1*this.getAttribute("data-tab"),e:e,dom:this,type:"enter"})},e[i].onmousemove=function(e){t({index:1*this.getAttribute("data-tab"),e:e,dom:this,type:"move"})},o&&(e[i].onmouseleave=function(e){n({index:1*this.getAttribute("data-tab"),e:e,dom:this,type:"leave"})});else e.onmouseenter=function(e){t({index:0,e:e,dom:this})},o&&(e.onmouseleave=function(e){n({index:0,e:e,dom:this})})}},{key:"tab",value:function(e,t,n){t=Object.assign({index:0,event:"click",list:"[data-tab-list]"},t);var r=this;3===r._is_obj(e).code&&(e=r.$.dom(e));var o=Array.from(e.querySelectorAll("[data-tab]"));o.length&&(r.class(o).name(""),o.forEach(function(e,t){e&&!r.js(e,0).attr("data-index")&&r.js(e,0).attr("data-index",t)}),"hover"===t.event&&r.hover(o,function(e){"enter"===e.type&&e.dom.click()}),r.click(o,function(e){var i=e.dom,a=r.js(i,0).attr("data-index");if(void 0===a&&(a=t.index),r.class(o).name(""),r.js(i,0).addClass("active"),r.focus(i),n&&n({index:1*a,that:i}),t.list){var c=r.$.all(t.list);c&&c.length&&(r.class(c).name(""),r.js(c[1*a],0).addClass("show"))}return""}),setTimeout(function(){t.index<o.length&&o[1*t.index].click()},200))}},{key:"progress",value:function(e,t,n){t=Object.assign({max:100,now:0,range:[30,60,90],color:["#34d834","orange","tomato","red"],sty:{height:"2px"},remove:!1},t);var r=arguments.length>2;if(3===this._is_obj(e).code&&(e=this.$.dom(e)),!e)return"";var o=e.className;o.indexOf(this.options.prefix+"_progress")<0&&this.class(e).add(this.options.prefix+"_progress"),e.setAttribute("data-length",t.max),e.setAttribute("data-now",t.now),e.innerHTML='<i class="run"></i>',this.js(e,0).style(t.sty);var i=e.querySelector(".run"),a=t.now/t.max*100,c="";if(t.color.length&&Array.isArray(t.color)&&(c=t.color[0]),t.range.length>1){t.range[t.range.length-1]<=100&&(t.range[t.range.length-1]=999);for(var s=0;s<t.range.length;s++)a<t.range[s]&&a>(t.range[s-1]||0)&&t.color[s]&&(c=t.color[s])}if(c&&(i.style.background=c),this.js(i,0).width(a+"%"),r&&n(a),a>=100&&t.remove){var u=this;setTimeout(function(){u.remove(e)},500)}return a}},{key:"move",value:function(e,t,n){if(n&&3===this._is_obj(n).code&&(n=this.$.dom(n)),3===this._is_obj(e).code&&(e=this.$.dom(e)),!e)return null;var r=n?n.clientWidth:window.innerWidth,o=n?n.clientHeight:window.innerHeight;e.onmousedown=function(n){var i=n||window.event,a=i.clientX-e.offsetLeft,c=i.clientY-e.offsetTop;void 0!==e.setCapture&&e.setCapture();var s=0,u=0;document.onmousemove=function(n){var i=n||window.event,l=i.clientX-a,d=i.clientY-c;l=l>r-e.offsetWidth?r-e.offsetWidth:l<0?0:l,d=d>o-e.offsetHeight?o-e.offsetHeight:d<0?0:d,s=l,u=d,t&&t({left:l+"px",top:d+"px",code:1})},document.onmouseup=function(){this.onmousemove=null,this.onmouseup=null,void 0!==e.releaseCapture&&e.releaseCapture(),t&&t({left:s,top:u,code:0}),s=null,u=null}}}},{key:"array",value:function(e){var t=this;return e.length&&4===t._is_obj(e).code?{rand:function(){var n=t.copy(e);return n.sort(function(){return Math.random()-.5})},agg:function(t){var n={};return t?(e.forEach(function(e){var r=e[t];void 0!==r&&""!==r&&(n[r]?n[r].push(e):n[r]=[e])}),n):n},unique:function(t){if(arguments.length){
var n=new Map;return e.filter(function(e){return!n.has(e[t])&&n.set(e[t],1)})}for(var r=[],o=0;o<e.length;o++)-1===r.indexOf(e[o])&&r.push(e[o]);return r},max:function(){return Math.max.apply(null,e)},min:function(){return Math.min.apply(null,e)},sort:function(t){return{reverse:function(){return t?e.sort(function(e,n){return n[t].localeCompare(e[t])}):e.sort(function(e,t){return e-t})},sort:function(){return t?e.sort(function(e,n){return e[t].localeCompare(n[t])}):e.sort(function(e,t){return t-e})}}},sum:function(t,n){return t=t||0,n=n||0,e.reduce(function(e,t){e+="",t+="";var r="0";e.indexOf(".")>=0&&(r=e),t.indexOf(".")>=0&&(r=t),e.indexOf(".")>=0&&t.indexOf(".")>=0&&(r=e.length>t.length?e:t);var o=0;r.indexOf(".")>=0&&(o=r.length-r.indexOf(".")-1,o=1*("1e"+o),e*=o,t*=o),e*=1,t*=1,o=o<1?1:o;var i=(e+t)/o;switch(n){case 1:i=(e-t)/o;break;case 2:i=e*t/o;break;case 3:i=e/t;break;case 4:i=e/o%(t/o)}return r=null,o=null,i})+1*t},chunk:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=e;if(t<=0)return n;for(;r.length;)n.push(r.splice(0,t));return n}}:{}}},{key:"month",value:function(){var e=this;return{date:function(e,t){e=1*e>3e3?2020:1*e<1970?2020:e,t=1*t>12?12:1*t<1?1:t;var n=new Date(e,t,0);return n.getDate()},day:function(t){var n=e.timeout(t,"object"),r=new Date(n.y,1*n.m,0);return r.getDate()},month:function(t){var n=new Date;t=t||n.getMonth(),1!==e._is_obj(t).code&&(t=Date.now()),t<12?n.setMonth(t):n=new Date(e.timeout(t,"y-m-d"));for(var r=e.month().day(n.getTime()),o=[],i=1;i<=r;i++){var a=n.setDate(i),c=e.timeout(a,"object"),s={week:c.w,index:c.week,time:c.y+"/"+c.m+"/"+c.d,timeout:c.default,month:1*c.m,day:1*c.d,year:c.y};o.push(s)}return o},time:function(t,n,r,o){o||(o=Date.now()),n=n||0;for(var i=1e3*(t||60),a=36e5*(r||1),c=Math.ceil(a/i)+1,s=e.timeout(o,"zero")+(n>0?6e4*n:0),u=[],l=0;l<c;l++){var d=s;u.push(e.timeout(d,"alls")),s+=i}return u},week:function(t,n,r){n||(n=Date.now()),t&&!isNaN(t)||(t=7),t<0&&(t*=-1);for(var o=e.timeout(n,"zero"),i=[],a=0;a<1*t;a++)i.push(o+864e5*a);return i=i.map(function(t,n){var r=e.timeout(t,"object");return{time:r.y+"/"+1*r.m+"/"+1*r.d,day:r.w,index:n,timeout:t}}),r&&r(i),i},current:function(){var t=e.month().month(0),n=e.timeout("","object");return t=t.filter(function(e){return e.timeout<=n.default}),t}}}},{key:"calculate",value:function(){var e=this,t=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e._is_obj(t).code,o=e._is_obj(n).code,i=[0],a=[0];return 4===r?i=i.concat(t):i.push(1*t),4===o?a=a.concat(n):a.push(1*n),i=e.array(i).sum(),a=e.array(a).sum(),r=null,o=null,{s:i,e:a}};return{add:function(n,r){var o=t(n,r);return e.array([o.s,o.e]).sum()},sub:function(n,r){var o=t(n,r);return e.array([o.s,o.e]).sum(0,1)},mul:function(n,r){var o=t(n,r);return e.array([o.s,o.e]).sum(0,2)},exc:function(n,r){r=r||1;var o=t(n,r);return e.array([o.s,o.e]).sum(0,3)},sur:function(n,r){r=r||1;var o=t(n,r);return e.array([o.s,o.e]).sum(0,4)}}}},{key:"copy",value:function(e){return""===e||null==e||NaN===e?"":JSON.parse(JSON.stringify(e))}},{key:"header",value:function(){var e=new XMLHttpRequest;e.open("GET",document.location.href,!1),e.send(null);var t=e.getAllResponseHeaders().split("\n"),n={};return t.forEach(function(e){if(""!==e){var t=e.indexOf(":"),r=e.slice(0,t),o=e.slice(t+1).trim();n[r]=o}}),n}},{key:"font",value:function(e){e=e||1920,document.documentElement.style.fontSize=window.innerWidth*(100/e)+"px",this.font_em=!0}},{key:"cssLazy",value:function(e){e=e||"css-lazy";var t=document.head.children,n=!1;if(t.length)for(var r=0;r<t.length;r++)t[r].id===e&&(n=!0);return{link:function(t){if(!t)return 0;if(!n){var r=document.createElement("link");r.setAttribute("rel","stylesheet"),r.setAttribute("id",e),r.setAttribute("href",t),document.getElementsByTagName("head")[0].appendChild(r),r=null}},text:function(t){if(!t)return 0;if(!n){var r=document.createElement("style");r.setAttribute("type","text/css"),r.setAttribute("id",e);try{r.appendChild(document.createTextNode(t))}catch(e){style.styleSheet.cssText=t}document.getElementsByTagName("head")[0].appendChild(r),r=null}}}}},{key:"hash",value:function(e,t,n){function r(){var r=setTimeout(function(){clearTimeout(r),r=null,o.hash(function(t){e(t)},t,n)},200)}t=0===t?0:t||"",n=n||"";var o=this,i=window.location.hash;if(n)try{i=o.eval("return "+n)}catch(t){n="",i="",e({code:0,data:t+""})}i!=t&&(t=i,e({code:1,data:t})),r()}},{key:"refresh",value:function(e){var t=this;t.loading_timer=null,t.alert_timer=null,t.btn_timer=null,t.resize_timer=null,t.timer_timer=null,t.jsonp_timer=null,t.down_timer=null,t.toast_timer=null,t.jsonp_timeout=8e3;var n=t.$config.select("api");return n&&(t.options.api=n),t.options.scroll&&window.BScroll&&(t.$scroll=window.BScroll),t.options.ajax&&window.axios&&(t.$axios=window.axios),console.log("%c 欢迎使用!当前版本:%c"+t.version+"。%c 更新时间:"+t.__TIME__+"。 %c by:"+t.__DEMO__,"color:tomato","color:green","color:orange","color:#ccc"),t.options.debugger&&(console.log("%c 禁止调试!","color:orange"),setInterval(function(){var e=Date.now();return e},100)),e||console.log("%c 重置成功","color:#99cc33"),{option:t.options,scroll:t.$scroll||"",ajax:t.$axios||"",ver:t.version}}},{key:"route",value:function(){function e(e,t,n,r){return{path:e,title:n||"",id:t||1,by:r||-1}}function t(e){i.js("title").html(e)}function n(e,n){var r=i.$routeConfig.now;r.path?(window.location.hash=r.path,t(r.title),o(function(t){e&&e(t)})):n&&n()}function r(e){if(e<=0)return{};var t=i.$routeConfig.path.filter(function(t){return t.id===e});return t.length?t[0]:{}}function o(e){var t=i.$routeConfig.now,n={lazy:t.path.replace(/\//g,"_"),params:t.params.join("&"),path:t.path,back:{},id:t.id,title:t.title,code:1};n.back=r(n.by),n.params=i.getUrl("?"+n.params);var o=i.$.all('script[src*="'+i.$routeConfig.prefix+'"]');if(o.length)for(var a=0;a<o.length;a++)i.remove(o[a]);i.script(i.$routeConfig.prefix+n.lazy+i.$routeConfig.suffix),i.$routeConfig.now=n,e(n),n=null}var i=this;return{create:function(e,t,n){if(4===i._is_obj(e).code&&e.length>0){var r=e.filter(function(e){return""!==e.path});return i.$routeConfig.path=i.array(r).unique("path"),i.$route.config(),t&&t(),1}return n&&n(),0},init:function(e){n(function(t){e&&e(t)},function(){i.$route.push(window.location.hash||"/")})},push:function(e,n){var r=e.substr(1);r=r||"index",r=r.split("/");var a=r.filter(function(e){return e.indexOf("=")<0&&e}).join("/"),c=i.$routeConfig.path.filter(function(e){return e.path===a});if(!c.length)return c=null,n?n({code:0,err:"错误路由"}):demo.alert("错误路由"),0;c=c[0],window.location.hash=c.path,t(c.title);var s=[];r=r.join("/").replace(a,"").split("/"),r.length>1&&(s=r.splice(1)),c.params=s,i.$routeConfig.now=c,c=null,o(function(e){n&&n(e)})},back:function(e){var t=(i.$routeConfig.now||{}).back||{};i.$routeConfig.now=t,n(function(t){e&&e(t)},function(){window.history.go(-1)}),t=null},array:function(t){if(4===i._is_obj(t).code&&t.length>0){var n=t.map(function(t){return e(t[0],t[1],t[2],t[3])});return n}return[]},title:function(e){t(e)},reset:function(e,t,n){i.$route.create(e||[]),i.$route.config(t||{}),n&&n()},destroy:function(){i.$routeConfig={path:[],now:{},prefix:"",suffix:""}},config:function(e){e=e||{},i.$routeConfig.prefix=e.prefix||"./lazy/",i.$routeConfig.suffix=e.suffix||".base.js?v="+Date.now()}}}},{key:"lazy",value:function(){var e=this;return{page:function(t,n,r){3===e._is_obj(t).code&&(t=e.js(t).dom()),e.js(t,0).html(""),n=Object.assign({vue:!0,id:"lazy-"+Date.now(),class:"app_view",html:"html",style:"",link:"",suffix:".base.css?v="+Date.now(),prefix:""},n);var o=e._div("div",n.class);o.setAttribute("id",n.id),n.vue&&o.setAttribute("v-clock",""),o.innerHTML=n.html,n.style&&e.cssLazy("css-text-"+n.id).text(n.style),n.link&&(4===e._is_obj(n.link).code?n.link.length&&n.link.forEach(function(t,r){e.cssLazy("css-link-"+n.id+"-"+r).link(n.prefix+t.replace(/\.css/,"")+n.suffix)}):e.cssLazy("css-link-"+n.id).link(n.prefix+n.link.replace(/\.css/,"")+n.suffix)),t.appendChild(o),r&&r()},image:function(t){t=t||"img";for(var n=e.$.all(t),r=n.length,o=document.documentElement.clientHeight,i=document.documentElement.scrollTop||document.body.scrollTop,a=0;a<r;a++){var c=n[a].offsetTop;if(c<o+i){var s=n[a].dataset.src;n[a].src=s}}},scroll:function(e){var t=document.documentElement,n=t.clientHeight,r=t.scrollTop,o=t.scrollHeight;n+r>=o&&e&&e()},bulk:function(t,n,r,o,i,a,c){return i=i||"li",a=a||"",window.requestAnimationFrame&&document.createDocumentFragment?arguments.length<4||5!==e._is_obj(arguments[3]).code?"传入正确参数":void setTimeout(function(){function s(){for(var t=document.createDocumentFragment(),n=0;n<d;n++){f++;var r=e._div(i,a),c=o(f,m,h);c&&(r.innerHTML=c,t.appendChild(r)),r.setAttribute("data-bulk-id",f)}v.appendChild(t),m+=1,u()}function u(){if(m<h){if(m+1===h){var e=l%d;d=e>0?e:d}window.requestAnimationFrame(s)}else c&&c(Array.from(v.querySelectorAll("[data-bulk-id]")))}var l=t||100,d=n||20,f=0,h=Math.ceil(l/d),m=0,v=r;3===e._is_obj(r).code&&(v=e.$.dom(r)),u()},0):"不支持"}}}},{key:"debounce",value:function(e,t){var n=null;return function(){var r=arguments,o=this;null!==n&&clearTimeout(n),n=setTimeout(function(){e.apply(o,r)},t)}}},{key:"throttle",value:function(e,t){var n=Date.now();return function(){var r=this,o=arguments,i=Date.now();i-n>=t&&(e.apply(r,o),n=Date.now())}}},{key:"use",value:function(){function e(e,t){window.addEventListener(e,function(){t()})}var t=this;return{scroll:function(t){e("scroll",function(){t()})},throttle:function(n,r){e("scroll",t.throttle(function(){n()},r||800))},debounce:function(n,r){e("scroll",t.debounce(function(){n()},r||800))},use:function(e,n){return t[e]&&"use"!==e?(n&&n(t[e]),t[e]):t},downTime:function(e,n){if(t.down_timer<0)return clearTimeout(t.down_timer),t.down_timer=null,0;e=e||Date.now()+1e3,t.downTime(e,function(e){n&&n(e)}),e>Date.now()&&(t.down_timer=setTimeout(function(){t.$use.downTime(e,function(e){n&&n(e)})},1e3))}}}},{key:"access",value:function(e,t,n){var r="接入成功";return this[e]?(r="该方法已存在",n&&n({c:!1,m:r}),r):(this[e]=t,n&&n({c:!0,m:r}),r)}},{key:"destroy",value:function(){var e=this;return{banner:function(t,n){if(!t)return 0;var r=3===e._is_obj(t).code?e.$.dom(t):t,o=r.innerHTML;e.banner_timer&&(clearInterval(e.banner_timer),e.banner_timer=null),r.innerHTML="",setTimeout(function(){r.innerHTML=o,o="",n&&n(r)},20)},downTime:function(){e.down_timer=-1,setTimeout(function(){e.down_timer=null},1e3)},own:function(t){return window[t]&&3===e._is_obj(t).code?(window[t].version===e.version&&(window[t]=null),1):0}}}},{key:"ver",value:function(){var e=this.options.name+"-version",t={version:this.version,author:"mr.x",email:"2439227131@qq.com",desc:"This is a simple, self created JS, fool type operation, suitable for small white use",github:"",www:this.__DEMO__,loc:e},n=this.$local.get(e)||{};return this.copy(Object.assign(t,n))}},{key:"ctrl",value:function(){var e=this,t="position: fixed;left: -100vw;top: -100vh;z-index: -1000";return{c:function(n,r){var o=r,i=document.execCommand("copy");if(!i)return e.alert("不支持"),0;if(n)try{3===e._is_obj(n).code&&(n=e.$.dom(n)),o=n.getAttribute("data-copy")||""}catch(e){o=""}var a=e._div("textarea"),c="copy-"+Date.now()+"-"+e.rand(6);return a.value=o||"copy",a.setAttribute("id",c),a.setAttribute("style",t),e.$.dom("body").appendChild(a),a.select(),document.execCommand("copy"),setTimeout(function(){e.remove(a)},300),1},r:function(t,n,r){function o(){l&&(clearTimeout(l),l=null)}if(3===e._is_obj(t).code&&(t=e.$.dom(t)),n=Object.assign({item:[]},n),!n.item.length)return t.oncontextmenu=function(){return r&&r({type:"right"}),!1},1;var i=e._div("div",e.options.prefix+"_right"),a=n.item.length>6?"scroll":"";n.id=n.id||"right-menu-"+Date.now()+"-"+e.rand(6),i.setAttribute("id",n.id);var c='<i class="close fa fa-close"></i><i class="before fa fa-hand-o-up"></i><div class="tab '+a+'"><ul>';n.item.forEach(function(e,t){c+='<li><span title="'+e.text+'" data-index="'+t+'">'+e.text+"</span></li>"}),c+="</ul></div>",i.innerHTML=c,e.$.dom("body").appendChild(i);var s="#"+n.id,u=null,l=null,d=n.timeout||3e3;d=d<100?100:d,a&&(u=e.scroll(s+" .tab",{})),e.click(s+" .close",function(){o(),e.js(s).style({opacity:0})}),e.click(e.$.all(s+" .tab li span"),function(t){var o=t.dom.getAttribute("data-index"),i={data:e.copy(n.item[1*o]),type:"click",scroll:u,res:t,leave:d};i.data.callback&&delete i.data.callback,n.item[o].callback?n.item[o].callback(i):r&&r(i),e.click(s+" .close"),i=null}),t.oncontextmenu=function(t){return e.js(s).style({left:t.clientX+"px",top:t.clientY+"px"}),!1},e.$.dom(s).oncontextmenu=function(){return!1},e.hover(s,function(){o()},function(){o(),l=setTimeout(function(){e.click(s+" .close")},d)})},d:function(t,n){var r=(3===e._is_obj(t).code?t.split(","):t)||[],o=[];r.length&&(o=r.map(function(e){var t=(e+"").split("-"),n={c:"c"===t[0],s:"s"===t[0]};return n.key=t[1]||t[0],n})),r.indexOf("right")>=0&&(document.oncontextmenu=function(){return!1}),document.onkeydown=function(e){var t=e.key.toLowerCase(),i=o.filter(function(n){return n.key.toLowerCase()===t&&e.ctrlKey===n.c&&e.shiftKey===n.s});if(r.indexOf("f12")>=0&&e.ctrlKey&&e.shiftKey&&"i"===t)return n&&n({key:"f12"}),!1;if(i.length){if(i=i[0],e.ctrlKey===i.c&&t===i.key&&!i.s)return n&&n(i),!1;if(e.shiftKey===i.s&&!i.cal&&t===i.key)return n&&n(i),!1}return!0}},k:function(n,r,o){3===e._is_obj(n).code&&(n=e.$.dom(n));var i="ctrl-k-input-keydown",a=function(e,t,n){return{code:t,key:e,val:n}};e.js(n,0).click(function(n){e.$.id(i)&&e.js("#"+i).remove();var c=e._div("input","m_inp");c.setAttribute("id",i),c.setAttribute("style",t),c.setAttribute("autocomplete","off"),n.appendChild(c),c.focus();var s=[];c.onkeydown=function(e){var t={};if(!e.shiftKey&&!e.ctrlKey){var n=e.keyCode;switch(n){case 38:case 87:case 104:t=a("up",0,n);break;case 39:case 68:case 102:t=a("right",1,n);break;case 40:case 83:case 98:t=a("bottom",2,n);break;case 37:case 65:case 100:t=a("left",3,n);break;default:t=a(e.key,4,n)}}c.value="",o&&(t.event=e,s.push(t.key),t.his=s),r&&r(t),t=null}})}}}},{key:"algorithm",value:function(){var e=this;return{sortSum:function(t,n,r){function o(){r?e.array(i).sort().sort():e.array(i).sort().reverse();var t=i[1];if(void 0!==t){var n=i[0]+t;a.push(n),i.splice(0,2,n),o()}}var i=e.copy(t);if(4!==e._is_obj(i).code||!i.length)return{};var a=[];i=i.filter(function(e){return void 0!==e}),o();var c={max:e.array(a).sum(),arr:t,new:a,sum:e.array(t).sum()};return n&&n(c),c},adj:function(t,n,r){if(4!==e._is_obj(t).code||!t.length)return t;var o=e.copy(t);switch(r){case 1:e.array(o).sort().reverse();break;case 2:e.array(o).sort().sort()}for(var i=0;i<o.length;i++)void 0!==o[i]&&o[i]+1===o[i+1]&&(o[i]+="-"),os.push(o[i]+"");var a=os.join(",").replace(/-,/g,"-");return a=a.split(","),a=a.filter(function(e){return isNaN(e)}),n&&"-"!==n&&(a=JSON.parse(JSON.stringify(a).replace(/-/g,n))),a},grid:function(e){var t=e.split("x"),n=1*t[0],r=1*t[1];if(n<=0||r<=0)return[];for(var o=[],i=0;i<n;i++)o.push(i);for(i=1;i<r;i++)o.push(n*i+n-1);for(i=n-1;i>0;i--)o.push(n*(r-1)+i-1);for(i=r-2;i>0;i--)o.push(n*i);return o},rgb:function(t,n){return t=t||0,n=n||255,"rgb("+e.rand(t,n)+","+e.rand(t,n)+","+e.rand(t,n)+")"},rgba:function(t,n,r){return n=n||0,r=r||255,t=t||.1,"rgba("+e.rand(n,r)+","+e.rand(n,r)+","+e.rand(n,r)+","+t+")"},color:function(){return"#"+("00000"+(16777216*Math.random()<<0).toString(16)).substr(-6)},gradients:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=n[0],i=n;return 1===e._is_obj(o).code?i=i.splice(1):o=0,i=i.filter(function(t){return 3===e._is_obj(t).code&&""!==t}),i.length<2&&(i=[e.algorithm().rgb(),e.algorithm().rgb()]),i=i.join(","),"linear-gradient("+o+"deg,"+i+")"}}}},{key:"cookie",value:function(){var e=this,t=function(t){return e.options.prefix+"_"+t},n=function(e){return e.replace(t(""),"")};return{set:function(n,r,o){o=o||"d7";var i=o.substr(0,1),a=o.substr(1);a=isNaN(a)?7:1*a;var c=1e3*("d"===i?86400:"h"===i?3600:1e3)*a,s=new Date;return s.setTime(s.getTime()+c),7!==e._is_obj(n).code&&7!==e._is_obj(r).code&&(document.cookie=t(n)+"="+escape(r)+";expires="+s.toGMTString()),i=null,a=null,c=null,s=null,!0},get:function(r,o){var i=e.cookie().getter(r);if(o)return i;var a=e._is_obj(i).code;return 6===a?i.key=n(i.key):4===a&&(i=i.filter(function(e){return 0===e.key.indexOf(t(""))}),i=i.map(function(e){return e.key=n(e.key),e})),i},getter:function(n){var r=document.cookie||"";return r=r.split(";"),r.length?(r=r.map(function(e){var t=e.split("=");return{key:t[0].trim(),val:unescape(t[1])}}),r=r.filter(function(e){return""!==e.key}),3===e._is_obj(n).code?(r=r.filter(function(e){return e.key===t(n)}),r[0]||{}):r):[]},del:function(n){var r=new Date;r.setTime(r.getTime()-1);var o=e.cookie().getter(n).val;return null!=o&&(document.cookie=t(n)+"="+escape(o)+";expires="+r.toGMTString()),r=null,o=null,!0},clear:function(){var r=e.cookie().getter();return r.length&&(r=r.filter(function(e){return 0===e.key.indexOf(t(""))}),r.length&&r.forEach(function(t){e.cookie().del(n(t.key))})),r=null,!0}}}},{key:"wait",value:async function(e,t){var n=function(e){return new Promise(function(t,n){return setTimeout(t,e)})},r=function(e){return new Promise(function(t,n){e?t("done"):n("fail")})};try{var o=await r(e),i=(new Date).getTime();await n(1e3),t&&t(o,(new Date).getTime()-i)}catch(e){t&&t("error",e)}}},{key:"sizeof",value:function(e,t){var n,r,o,i=0;if(t=t?t.toLowerCase():"","utf-16"===t||"utf16"===t)for(r=0,o=e.length;r<o;r++)n=e.charCodeAt(r),i+=n<=65535?2:4;else for(r=0,o=e.length;r<o;r++)n=e.charCodeAt(r),i+=n<=127?1:n<=2047?2:n<=65535?3:4;return i}},{key:"cache",value:function(){var e=this,t="cache_",n=5033164.8,r=function(n){return e.options.prefix+"_"+t+n},o=function(t){return e.sizeof(t)<n},i=function(t,n){e.$session.set(t,n)},a=function(t){var n=e.$session.get(r(t));return 7!==e._is_obj(n).code&&""!==n&&n};return{set:function(t,n){return n+="",o(n)&&3===e._is_obj(n).code?!1!==a(t)?0:(i(r(t),n),1):0},edit:function(t,n){return n+="",!1===a(t)?0:o(n)&&3===e._is_obj(n).code?(i(r(t),n),1):0},get:function(e){return a(e)},del:function(t){return!1===a(t)?0:(e.$session.clear(r(t)),1)},name:function(e){return{key:r(e),val:a(e)}}}}},{key:"log",value:function(e,t){if(!this.options.log)return e;switch(t){case 1:console.group(e);break;case 2:console.groupCollapsed(e);break;case 3:console.groupEnd();break;case 4:console.warn(e);break;case 5:console.error(e);break;case 6:e=Object.assign({text:"log",sty:"color:orange"},e||{}),console.log("%c "+e.text,e.sty),e=e.text;break;default:console.log(e)}return this}},{key:"status",value:function(){var e=this,t=function(t){return(e.options.prefix+"status"+t).toUpperCase()},n=function(n){return e.$session.get(t(n))||{}},r=function(n,r){e.$session.set(t(n),r)},o=function(t,o,i){var a=n(t);return e._is_obj(i).code<7&&(a[o]=i,r(t,a)),a[o]||""},i=function(e,t){if(a[e])return 0;a[e]=function(n,r){return o(e,n,r)||t}},a={page:function(e,t){return o("page",e,t)||1},status:function(e,t){return o("status",e,t)||{}},code:function(e,t){return o("code",e,t)||400},add:function(e,t){i(e,t||"")}};return a}},{key:"const",value:function(e,t){if(this[e])return!1;try{Object.defineProperty(this,e,{enumerable:!0,value:t,configurable:!1,writable:!1})}catch(e){console.log(e+"")}}},{key:"plugIn",value:function(){var e=this,t=e.options.prefix+"_plugins",n=function(t){e.ajax(e.__DEMO_API__).plain({send:t,type:"plugins"},function(t){var n=JSON.parse(t);n.code&&n.data.forEach(function(t){e.script(t.url,function(){e.access(t.name,e.fn(t.fn),function(e){e.c&&r(t.name)}),e.js("script").remove()})})},!0)},r=function(n){var r=e.$config.select(t)||[];r.indexOf(n)<0&&r.push(n),e.$config.edit(t,r)};return{add:function(r){var o=e.$config.select(t)||[];4===e._is_obj(r).code?(n(r.join(",")),o=o.concat(r)):(n(r),o.push(r)),e.$config.edit(t,e.array(o).unique())},del:function(n){var r=e.$config.select(t)||[];4===e._is_obj(n).code?n.forEach(function(e){r=r.filter(function(t){return t!==e})}):r=r.filter(function(e){return e!==n}),e.$config.edit(t,r)},init:function(){var r=e.options.plugins.concat(e.$config.select(t)||[]);e.$config.add(t,r),r.length&&n(r.join(","))}}}},{key:"toast",value:function(e,t){var n=this,r=n.options.prefix+"_toast",o=n.$.dom("."+r),i=n._is_obj(e).code,a=isNaN(t)?3e3:t<1e3?1e3:+t,c=function(t){4===i||6===i?n.js(t,0).json(e):t.innerHTML=e},s=function(t){0===n.$web?n.class(t).add("pc"):n.font_em&&n.class(t).add("em"),n.class(t).add("show"),null!==n.toast_timer?(clearTimeout(n.toast_timer),u(t)):u(t),t.onclick=function(){var t=e;4!==i&&6!==i||(t=JSON.stringify(e)),n.ctrl().c("",t),n.log("copy success",1).log(t,0).log("",3)}},u=function(e){n.toast_timer=setTimeout(function(){n.class(e).remove("show"),clearTimeout(n.toast_timer),n.toast_timer=null},a)};if(o)c(o),s(o);else{var l=n._div("div",r);c(l),n.js("body").appendChild(l),s(l)}}},{key:"_init",value:function(e){var t=this;t.$model=t._model(),t.$fixed=t._fixed(),t.$web=t.platform(),t.$local=t.local(),t.$session=t.session(),t.route().destroy(),t.$route=t.route(),t.$lazy=t.lazy(),t.$use=t.use(),t.$destroy=t.destroy(),t.$check=t.checkbox(),t.$version=t.ver(),t.$month=t.month(),t.$sum=t.calculate(),t.$ctrl=t.ctrl(),t.$alg=t.algorithm(),t.$config=t._config(),t.$cookie=t.cookie(),t.$cache=t.cache(),t.$save=t.status(),t.const("__DEMO__","http://148.70.132.221:2020/base/"),t.const("__DEMO_API__",t.__DEMO__+"api/"),t.const("__TIME__","2021-01-19 08:00:00"),t.$plug=t.plugIn(),t.$plug.init(),t.font_em=!1,delete t.$plug.init,e(t.refresh(1))}},{key:"_fixed",value:function(){var e=this;return{bgc:function(t,n){if(n=n||"body",3===e._is_obj(n).code&&(n=e.$.dom(n)),6===e._is_obj(t).code){var r="";for(var o in t)r+="".concat(o,":").concat(t[o],";")}else t=t.replace("background:",""),r="background:"+t;if(n){var i=e.options.prefix+"_fixed";e.$.dom("."+i)&&e.remove("."+i);var a=e._div("div",i);a.setAttribute("style",r),n.appendChild(a),a=null}},image:function(t,n){if(n=n||"body",3===e._is_obj(n).code&&(n=e.$.dom(n)),n){var r=e.options.prefix+"_fixed";e.$.dom("."+r)&&e.remove("."+r);var o=e._div("div",r);o.setAttribute("style","background:url('"+t+"') no-repeat 0 0 transparent scroll;background-size:100% 100%"),n.appendChild(o),o=null}},gray:function(t){var n="css-lazy-gray";if(t)try{e.js('style[id="'+n+'"]').remove()}catch(e){}else e.cssLazy(n).text("html{filter:grayscale(1);}")}}}},{key:"_model",value:function(){var e=this;return{success:function(t,n){e.alert(t,1,{title:n})},error:function(t,n){e.alert(t,0,{title:n})},warning:function(t,n){e.alert(t,2,{title:n})},model:function(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3,i=arguments.length;e.alert(n,o,{title:t,sty:"model",timeout:0},function(e){i>2&&(e.time=Date.now(),r(e))})},popup:function(t,n,r){e.alert(t,3,{sty:"model",timeout:0,screen:!!r},function(t){3e3===t.code?e.js(t.box,0).addClass("popup"):n&&n(t)})},info:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e.alert(t,n,{timeout:r})}}}},{key:"_timers",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,o=this;if(null!==o[e])return n&&(clearTimeout(o[e]),o[e]=null),!1;t(0),o[e]=setTimeout(function(){clearTimeout(o[e]),o[e]=null,t(1)},r||500)}},{key:"_storage",value:function(e){function t(){var t=window[e].getItem(i)||"{}";try{t=JSON.parse(t)}catch(e){t={}}return t}function n(t){return t?(window[e].setItem(i,JSON.stringify(t)),t):0}function r(e,t){var n=c._is_obj(a[e]).code;return n>6||5===n?t:a[e]}function o(){a=t()}var i=(this.options.name+"-local-"+this.version.replace(/\./g,"")).toUpperCase(),a=t(),c=this;return{all:function(){return o(),a},get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return o(),r(e,t)},set:function(e,t){return e||(e=c.options.prefix+"-null"),o(),a[e]=t,n(a)},clear:function(e){return o(),4===c._is_obj(e).code&&e.length?e.forEach(function(e){a[e]=null,delete a[e]}):(a[e]=null,delete a[e]),n(a)},reset:function(){return n({})}}}},{key:"_style",value:function(e,t){if(6===this._is_obj(t).code)for(var n in t)e.style[n]=t[n]}},{key:"_config",value:function(){function e(e){return 7===n._is_obj(r[e]).code}function t(e){return 3===n._is_obj(e).code}var n=this,r=n.$local.get("config",{});return{delete:function(t){return e(t)?0:(delete r[t],n.$local.set("config",r),1)},add:function(o,i){return t(o)&&e(o)?(r[o]=i,n.$local.set("config",r),1):0},edit:function(o,i){return t(o)&&!e(o)?(r[o]=i,n.$local.set("config",r),1):0},select:function(n){return e(n)?t(n)?"":r:r[n]},switch:function(e,t,r){var o=n._config()[e];return"switch"!==e&&o?o(t,r):0}}}},{key:"_is_obj",value:function(e){var t=0,n="";switch(Object.prototype.toString.call(e)){case"[object Number]":t=1,n="number";break;case"[object Boolean]":t=2,n="boolean";break;case"[object String]":t=3,n="string";break;case"[object Array]":t=4,n="array";break;case"[object Function]":t=5,n="function";break;case"[object Object]":t=6,n="object";break;case"[object Undefined]":t=7,n="undefined";break;case"[object Null]":t=8,n="null"}return{code:t,type:n}}},{key:"_div",value:function(e,t,n){var r=document.createElement(e||"div"),o=this._is_obj(n).code;return 7!==o&&(4!==o&&6!==o||(n=JSON.stringify(n)),r.appendChild(document.createTextNode(n))),o=null,r.setAttribute("class",t||""),r}}]),e}();(function(){if(!window.demo)window.demo=new Demo})();