gis-common 1.0.11 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/resource.min.js +2479 -2
  2. package/package.json +1 -1
@@ -1,2 +1,2479 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mqtt")):"function"==typeof define&&define.amd?define("Gis",["mqtt"],e):"object"==typeof exports?exports.Gis=e(require("mqtt")):t.Gis=e(t.mqtt)}(window,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=1)}([function(e,n){e.exports=t},function(t,e,n){"use strict";n.r(e),n.d(e,"AnimateUtils",(function(){return r})),n.d(e,"ArrayUtils",(function(){return o})),n.d(e,"BrowserUtils",(function(){return a})),n.d(e,"Cookie",(function(){return s})),n.d(e,"CoordsUtils",(function(){return c})),n.d(e,"DateUtils",(function(){return u})),n.d(e,"DomUtils",(function(){return h})),n.d(e,"GeoUtils",(function(){return d})),n.d(e,"FileUtils",(function(){return v})),n.d(e,"MathUtils",(function(){return y})),n.d(e,"OptimizeUtils",(function(){return m})),n.d(e,"StringUtils",(function(){return g})),n.d(e,"Utils",(function(){return M})),n.d(e,"EventType",(function(){return E})),n.d(e,"ErrorType",(function(){return b})),n.d(e,"LayerType",(function(){return w})),n.d(e,"AudioPlayer",(function(){return _})),n.d(e,"CanvasDrawer",(function(){return O})),n.d(e,"ElQuery",(function(){return x})),n.d(e,"EventDispatcher",(function(){return P})),n.d(e,"HashMap",(function(){return L})),n.d(e,"MqttClient",(function(){return q})),n.d(e,"WebSocketClient",(function(){return Q})),n.d(e,"WebStorage",(function(){return V}));var r={animate:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"swing",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5;for(var o in e)e[o]={target:"opacity"===o?parseInt(100*e[o]):e[o],iNow:"opacity"===o?parseInt(100*getComputedStyle(t)[o]):parseInt(getComputedStyle(t)[o])};"liner"===r&&(i=e[o].iNow<e[o].target?Math.abs(i):-Math.abs(i)),clearInterval(t.timer),t.timer=setInterval((function(){for(var o in e){var a=e[o].target,s=e[o].iNow;if("swing"===r&&(i=(i=(a-s)/20)>0?Math.ceil(i):Math.floor(i)),Math.abs(a-s)<=Math.abs(i)){for(var c in t.style[o]="opacity"===o?a/100:a+"px",delete e[o],e)return!1;clearInterval(t.timer),"function"==typeof n&&n()}else e[o].iNow+=i,t.style[o]="opacity"===o?e[o].iNow/100:e[o].iNow+"px"}}),30)}};function i(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}Array.prototype.groupBy=function(t){var e={};return this.forEach((function(n){var r=JSON.stringify(t(n));e[r]=e[r]||[],e[r].push(n)})),Object.keys(e).map((function(t){return e[t]}))},Array.prototype.distinct=function(t){var e=[],n={};return this.forEach((function(r){var i=t(r);!n[i]&&(n[i]=e.push(r))})),e},Array.prototype.max=function(){return Math.max.apply({},this)},Array.prototype.min=function(){return Math.min.apply({},this)},Array.prototype.sum=function(){return this.length>0?this.reduce((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t+e})):0},Array.prototype.desc=function(t){return this.sort((function(e,n){return(t?t(n):n)-(t?t(e):e)}))},Array.prototype.asc=function(t){return this.sort((function(e,n){return(t?t(e):e)-(t?t(n):n)}))},Array.prototype.clear=function(){return this.length=0,this};var o={asArray:function(t){return isEmpty(t)?[]:Array.isArray(t)?t:[t]},generateArray:function(t){return[].concat(i(new Array(t).keys()))},union:function(){for(var t=[],e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.forEach((function(e){Array.isArray(e)&&(t=t.concat(e.filter((function(e){return!t.includes(e)}))))})),t},intersection:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e[0]||[];return e.forEach((function(t){Array.isArray(t)&&(r=r.filter((function(e){return t.includes(e)})))})),r},unionAll:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return[].concat(i(e)).flat().filter((function(t){return!!t}))},difference:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.union.apply(this,i(n)).filter((function(e){return!t.intersection.apply(t,i(n)).includes(e)}))}},a={getUrlParams:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=/([^&=]+)=([\w\W]*?)(&|$|#)/g,r=new URL(t),i=r.search,o=r.hash,a=[i,o],s={},c=0;c<a.length;c++){var u=a[c];if(u){var l=u.replace(/#|\//g,""),f=l.split("?");if(f.length>1)for(var h=1;h<f.length;h++)for(var d=void 0;d=n.exec(f[h]);)s[d[1]]=e?decodeURIComponent(d[2]):d[2]}}return s},getExplorer:function(){var t=window.navigator.userAgent;return t.indexOf("MSIE")>=0||window.ActiveXObject||"ActiveXObject"in window?"IE":t.indexOf("Firefox")>=0?"Firefox":t.indexOf("Chrome")>=0?"Chrome":t.indexOf("Opera")>=0?"Opera":t.indexOf("Safari")>=0?"Safari":void 0},switchFullScreen:function(t){if(t){var e=document.documentElement;e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}else document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},refreshScale:function(){var t=document.documentElement.clientWidth,e=document.documentElement.clientHeight,n=document.getElementById("app").style,r=t/1920;t/e>16/9&&(r=e/1080),n.transformOrigin="left top",n.transform="scale("+r+") translateX(-49.99%)",n.width=t/r+"px"},getHtmlFontSize:function(){var t=document.documentElement.clientWidth||document.body.clientWidth;document.querySelector("html").style.fontSize=t/192+"px"}},s={set:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3),document.cookie=t+"="+escape(e)+";expires="+r.toGMTString()},remove:function(t){var e=new Date;e.setTime(e.getTime()-1);var n=getCookie(t);null!=n&&(document.cookie=t+"="+n+";expires="+e.toGMTString())},get:function(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return null!=e?e[2]:""}},c={PI:3.141592653589793,XPI:52.35987755982988,delta:function(t,e){var n=6378245,r=.006693421622965943,i=this.transformLat(e-105,t-35),o=this.transformLon(e-105,t-35),a=t/180*this.PI,s=Math.sin(a);s=1-r*s*s;var c=Math.sqrt(s);return{lat:i=180*i/(n*(1-r)/(s*c)*this.PI),lon:o=180*o/(n/c*Math.cos(a)*this.PI)}},gcjEncrypt:function(t,e){if(this.outOfChina(t,e))return{lat:t,lon:e};var n=this.delta(t,e);return{lat:t+n.lat,lon:e+n.lon}},gcjDecrypt:function(t,e){if(this.outOfChina(t,e))return{lat:t,lon:e};var n=this.delta(t,e);return{lat:t-n.lat,lon:e-n.lon}},gcjDecryptExact:function(t,e){for(var n=.01,r=.01,i=t-n,o=e-r,a=t+n,s=e+r,c=void 0,u=void 0,l=0;;){c=(i+a)/2,u=(o+s)/2;var f=this.gcj_encrypt(c,u);if(n=f.lat-t,r=f.lon-e,Math.abs(n)<1e-9&&Math.abs(r)<1e-9)break;if(n>0?a=c:i=c,r>0?s=u:o=u,++l>1e4)break}return{lat:c,lon:u}},bdEncrypt:function(t,e){var n=e,r=t,i=Math.sqrt(n*n+r*r)+2e-5*Math.sin(r*this.XPI),o=Math.atan2(r,n)+3e-6*Math.cos(n*this.XPI);return bdLon=i*Math.cos(o)+.0065,bdLat=i*Math.sin(o)+.006,{lat:bdLat,lon:bdLon}},bdDecrypt:function(t,e){var n=e-.0065,r=t-.006,i=Math.sqrt(n*n+r*r)-2e-5*Math.sin(r*this.XPI),o=Math.atan2(r,n)-3e-6*Math.cos(n*this.XPI),a=i*Math.cos(o);return{lat:i*Math.sin(o),lon:a}},mercatorEncrypt:function(t,e){var n=20037508.34*e/180,r=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return{lat:r=20037508.34*r/180,lon:n}},mercatorDecrypt:function(t,e){var n=e/20037508.34*180,r=t/20037508.34*180;return{lat:r=180/this.PI*(2*Math.atan(Math.exp(r*this.PI/180))-this.PI/2),lon:n}},distance:function(t,e,n,r){var i=Math.cos(t*this.PI/180)*Math.cos(n*this.PI/180)*Math.cos((e-r)*this.PI/180)+Math.sin(t*this.PI/180)*Math.sin(n*this.PI/180);i>1&&(i=1),i<-1&&(i=-1);var o=6371e3*Math.acos(i);return o},outOfChina:function(t,e){return e<72.004||e>137.8347||(t<.8293||t>55.8271)},transformLat:function(t,e){var n=2*t-100+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(e*this.PI)+40*Math.sin(e/3*this.PI))/3,n+=2*(160*Math.sin(e/12*this.PI)+320*Math.sin(e*this.PI/30))/3},transformLon:function(t,e){var n=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(t*this.PI)+40*Math.sin(t/3*this.PI))/3,n+=2*(150*Math.sin(t/12*this.PI)+300*Math.sin(t/30*this.PI))/3}};Date.prototype.format=function(t){var e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var n in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),e)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?e[n]:("00"+e[n]).substr((""+e[n]).length)));return t},Date.prototype.addDate=function(t,e){var n=new Date(this);switch(t){case"y":n.setFullYear(this.getFullYear()+e);break;case"q":n.setMonth(this.getMonth()+3*e);break;case"M":n.setMonth(this.getMonth()+e);break;case"w":n.setDate(this.getDate()+7*e);break;case"d":n.setDate(this.getDate()+e);break;case"h":n.setHours(this.getHours()+e);break;case"m":n.setMinutes(this.getMinutes()+e);break;case"s":n.setSeconds(this.getSeconds()+e);break;default:n.setDate(this.getDate()+e)}return n};var u={lastMonthDay:new Date((new Date).getFullYear(),(new Date).getMonth()-1,1),thisMonthDay:new Date((new Date).getFullYear(),(new Date).getMonth(),1),nextMonthDay:new Date((new Date).getFullYear(),(new Date).getMonth()+1,1),parseDate:function(t){if("string"==typeof t){var e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(e&&e.length>3)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/))&&e.length>6)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/))&&e.length>7)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]),parseInt(e[7]))}return null},formatDateInterval:function(t,e){var n=new Date(t),r=new Date(e).getTime()-n.getTime(),i=Math.floor(r/864e5),o=r%864e5,a=Math.floor(o/36e5),s=o%36e5,c=Math.floor(s/6e4),u=s%6e4,l=Math.round(u/1e3),f="";return i>0&&(f+=i+"天"),a>0&&(f+=a+"时"),c>0&&(f+=c+"分"),l>0&&(f+=l+"秒"),0===i&&0===a&&0===c&&0===l&&(f="少于1秒"),f},sleep:function(t){for(var e=Date.now();Date.now()-e<=t;);}};function l(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function f(t){return l(t).split(/\s+/)}var h={getStyle:function(t,e){var n=t.style[e]||t.currentStyle&&t.currentStyle[e];if((!n||"auto"===n)&&document.defaultView){var r=document.defaultView.getComputedStyle(t,null);n=r?r[e]:null}return"auto"===n?null:n},create:function(t,e,n){var r=document.createElement(t);return r.className=e||"",n&&n.appendChild(r),r},remove:function(t){var e=t.parentNode;e&&e.removeChild(t)},empty:function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront:function(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)},toBack:function(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)},getClass:function(t){return t.correspondingElement&&(t=t.correspondingElement),void 0===t.className.baseVal?t.className:t.className.baseVal},hasClass:function(t,e){if(void 0!==t.classList)return t.classList.contains(e);var n=this.getClass(t);return n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(void 0!==t.classList)for(var n=f(e),r=0,i=n.length;r<i;r++)t.classList.add(n[r]);else if(!this.hasClass(t,e)){var o=this.getClass(t);this.setClass(t,(o?o+" ":"")+e)}},removeClass:function(t,e){void 0!==t.classList?f(e).forEach((function(e){return t.classList.remove(e)})):this.setClass(t,l((" "+this.getClass(t)+" ").replace(" "+e+" "," ")))},setClass:function(t,e){void 0===t.className.baseVal?t.className=e:t.className.baseVal=e}},d={isLnglat:function(t,e){return t*=1,!!((e*=1)>0&&e<90&&t>0&&t<180)},formatLnglat:function(t,e){var n="";function r(t){var e=parseFloat(t),n=parseInt(e),r=parseInt(60*(e-n));r<10&&(r="0"+r);var i=parseInt(3600*(e-n)-60*r);return i<10&&(i="0"+i),n+"°"+r+"′"+i+"″"}return t&&e&&(n=r(t)+","+r(e)),n},rayCasting:function(t,e){for(var n=t.x,r=t.y,i=!1,o=0,a=e.length,s=a-1;o<a;s=o,o++){var c=e[o].x,u=e[o].y,l=e[s].x,f=e[s].y;if(c===n&&u===r||l===n&&f===r)return"on";if(u<r&&f>=r||u>=r&&f<r){var h=c+(r-u)*(l-c)/(f-u);if(h===n)return"on";h>n&&(i=!i)}}return i?"in":"out"},wgs84PointsDistance:function(t,e){var n=Math.PI;function r(t){return t*n/180}if(2!=arguments.length)return 0;lon1=t.x,lat1=t.y,lon2=e.x,lat2=e.y;var i,o=6378137,a=6356752.3142,s=1/298.257223563,c=r(lon2-lon1),u=Math.atan((1-s)*Math.tan(r(lat1))),l=Math.atan((1-s)*Math.tan(r(lat2))),f=Math.sin(u),h=Math.cos(u),d=Math.sin(l),p=Math.cos(l),v=c,y=100;do{var m=Math.sin(v),g=Math.cos(v),E=Math.sqrt(p*m*(p*m)+(h*d-f*p*g)*(h*d-f*p*g));if(0==E)return 0;var b=f*d+h*p*g,w=Math.atan2(E,b),M=h*p*m/E,S=1-M*M,_=b-2*f*d/S;isNaN(_)&&(_=0);var R=s/16*S*(4+s*(4-3*S));i=v,v=c+(1-R)*s*M*(w+R*E*(_+R*b*(2*_*_-1)))}while(Math.abs(v-i)>1e-12&&--y>0);if(0==y)return NaN;var O=S*(o*o-a*a)/(a*a),T=1+O/16384*(4096+O*(O*(320-175*O)-768)),C=O/1024*(256+O*(O*(74-47*O)-128)),A=C*E*(_+C/4*(b*(2*_*_-1)-C/6*_*(4*E*E-3)*(4*_*_-3))),I=a*T*(w-A);Math.atan2(p*m,h*d-f*p*g),Math.atan2(h*m,-f*p+h*d*g);return I}},p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v={convertBase64ToBlob:function(t){for(var e=t.split(",")[0].split(":")[1].split(";")[0],n=window.atob(t.split(",")[1]),r=new ArrayBuffer(n.length),i=new Uint8Array(r),o=0;o<n.length;o++)i[o]=n.charCodeAt(o);var a=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;return a?((a=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder)).append(r),a.getBlob(e)):a=new Blob([r],{type:e})},convertUrlToBase64:function(t,e,n){return new Promise((function(r,i){var o=new Image;o.crossOrigin="Anonymous",o.src=t,o.onload=function(){var t=document.createElement("canvas");t.width=e||o.width,t.height=n||o.height,t.getContext("2d").drawImage(o,0,0,o.width,o.height);var i=o.src.substring(o.src.lastIndexOf(".")+1).toLowerCase(),a=t.toDataURL("image/"+i);r({dataURL:a,type:"image/"+i,ext:i})}}))},convertBase64ToFile:function(t,e){for(var n=t.split(","),r=n[0].match(/:(.*?);/)[1],i=atob(n[1]),o=i.length,a=new Uint8Array(o);o--;)a[o]=i.charCodeAt(o);return new File([a],e,{type:r})},downloadFromFile:function(t,e){"object"==(void 0===t?"undefined":p(t))&&t instanceof Blob&&(t=URL.createObjectURL(t));var n=document.createElement("a");n.href=t,n.download=e||"",n.click(),window.URL.revokeObjectURL(n.href)}},y={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},degreesToRadians:function(t){return t*this.DEG2RAD},radiansToDegrees:function(t){return t*this.RAD2DEG},formatFloat:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}},m={debounce:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=void 0,i=void 0,o=void 0,a=void 0,s=void 0,c=function c(){var u=+new Date-a;u<e&&u>0?r=setTimeout(c,e-u):(r=null,n||(s=t.apply(o,i),r||(o=i=null)))};return function(){for(var i=arguments.length,u=Array(i),l=0;l<i;l++)u[l]=arguments[l];o=this,a=+new Date;var f=n&&!r;return r||(r=setTimeout(c,e)),f&&(s=t.apply(o,u),o=u=null),s}},throttle:function(t,e,n){if(1===n);else if(2===n);return function(){var r=this,i=arguments;if(1===n){var o=Date.now();o-previous>e&&(t.apply(r,i),previous=o)}else 2===n&&(timeout||(timeout=setTimeout((function(){timeout=null,t.apply(r,i)}),e)))}},recurve:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,r=0;setTimeout((function i(){++r<Math.floor(n/e)&&(t.call(this),setTimeout(i,e))}))}},g={checkStr:function(t,e){switch(e){case"phone":return/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);case"tel":return/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);case"card":return/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);case"pwd":return/^[a-zA-Z]\w{5,17}$/.test(t);case"postal":return/[1-9]\d{5}(?!\d)/.test(t);case"QQ":return/^[1-9][0-9]{4,9}$/.test(t);case"email":return/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);case"money":return/^\d*(?:\.\d{0,2})?$/.test(t);case"URL":return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);case"IP":return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);case"date":return/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t)||/^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);case"number":return/^[0-9]$/.test(t);case"english":return/^[a-zA-Z]+$/.test(t);case"chinese":return/^[\u4E00-\u9FA5]+$/.test(t);case"lower":return/^[a-z]+$/.test(t);case"upper":return/^[A-Z]+$/.test(t);case"HTML":return/<("[^"]*"|'[^']*'|[^'">])*>/.test(t);default:return!0}},changeCase:function(t,e){switch(e=e||4){case 1:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toUpperCase()+t.substring(1).toLowerCase()}));case 2:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toLowerCase()+t.substring(1).toUpperCase()}));case 3:return t.split("").map((function(t){return/[a-z]/.test(t)?t.toUpperCase():t.toLowerCase()})).join("");case 4:return t.toUpperCase();case 5:return t.toLowerCase();default:return t}}},E={MAP_RENDER:"mapRender",MAP_READY:"mapReady",MOUSE_CLICK:"click",MOUSE_DOUBLE_CLICK:"dblclick",MOUSE_MOVE:"mousemove",MOUSE_IN:"mousein",MOUSE_OUT:"mouseout",MOUSE_RIGHT_CLICK:"mouseRightClick",KEY_DOWN:"keyDown",KEY_UP:"keyUp",DRAW_ACTIVE:"drawActive",DRAW_MOVE:"drawMove",DRAW_COMPLETE:"drawComplete",MQTT_CONNECT:"mqttConnect",MQTT_ERROR:"mqttError",MQTT_MESSAGE:"mqttMessage",MQTT_CLOSE:"mqttClose",WEB_SOCKET_CONNECT:"webSocketConnect",WEB_SOCKET_ERROR:"webSocketError",WEB_SOCKET_MESSAGE:"webSocketMessage",WEB_SOCKET_CLOSE:"webSocketClose"},b={LOGIN_EXPIRED:"登录信息过期,请重新登录",CROSS_ERROR:"跨域访问",UNEXIST_RESOURCE:"资源不存在",TIMEOUT:"请求超时",INTERNAL_ERROR:"内部错误",NETWORK_ERROR:"请求失败,请检查网络是否已连接",PROCESS_FAIL:"处理失败",AUTH_VERIFY_ERROR:"权限验证失败",NO_DATA_FOUND:"未找到数据",DUPLICATE_INSTANCE:"实例为单例模式,不允许重复构建",COORDINATE_ERROR:"坐标验证失败",JSON_PARSE_ERROR:"JSON解析失败,格式有误",JSON_VALUE_ERROR:"JSON无此键",PARAMETER_ERROR:"参数验证失败",PARAMETER_ERROR_ARRAY:"参数格式验证失败:必须是数组",PARAMETER_ERROR_STRING:"参数格式验证失败:必须是字符",PARAMETER_ERROR_FUNCTION:"参数格式验证失败:必须是函数",PARAMETER_ERROR_LACK:"参数缺失项"},w={SUPER_MAP_IMAGES:"SuperMapImages",SUPER_MAP_DATA:"SuperMapData",ARC_GIS_MAP_IMAGES:"ArcGisMapImages",ARC_GIS_MAP_DATA:"ArcGisMapData",OSGB_LAYER:"OSGBLayer",S3M_GROUP:"S3MGroup",TERRAIN_LAYER:"TerrainFileLayer"},M={getDataType:function(t){return Object.prototype.toString.call(t).slice(8,-1)},isEmpty:function(t){if(null==t)return!0;switch(this.getDataType(t)){case"String":return""===t.trim();case"Array":return!t.length;case"Object":return!Object.keys(t).length;case"Boolean":return!t;default:return!1}},isNotEmpty:function(t){return!this.isEmpty(t)},json2form:function(t){var e=new FormData;return Object.keys(t).forEach((function(n){e.append(n,t[n]instanceof Object?JSON.stringify(t[n]):t[n])})),e},jsontoQuery:function(t){var e=[];for(var n in t){var r=n,i=t[n];e.push(r+"="+i)}return e.join("&")},generateGuid:function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+t()+t()+t()+t()+t()+t()},decodeDict:function(){for(var t="",e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length>1){for(var i=n.slice(1,n.length%2==0?n.length-1:n.length),o=0;o<i.length;o+=2){var a=i[o];n[0]===a&&(t=i[o+1])}t||n.length%2!=0||(t=n[n.length-1])}else t=n[0];return t},extend:function(t){for(var e=void 0,n=void 0,r=void 0,i=void 0,o=arguments.length,a=Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];for(n=0,r=a.length;n<r;n++)for(e in i=a[n])t[e]=i[e];return t},rgb2hex:function(t){return"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1)},convertToTree2:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"parentId",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"children",i=[];function o(i){var a=i[e],s=t.filter((function(t){return t.hasOwnProperty(n)&&t[n]===a}));s.length>0&&(s.forEach(o),i[r]=s)}var a=function(r){-1===t.findIndex((function(t){return t[e]===r[n]}))&&(o(r),i.push(r))},s=!0,c=!1,u=void 0;try{for(var l,f=t[Symbol.iterator]();!(s=(l=f.next()).done);s=!0){var h=l.value;a(h)}}catch(t){c=!0,u=t}finally{try{!s&&f.return&&f.return()}finally{if(c)throw u}}return i},loadScript:function(t,e){var n=document.createElement("script");n.readyState?n.onreadystatechange=function(){"complete"!==n.readyState&&"loaded"!==n.readyState||e()}:n.onload=function(){e()},n.src=t,document.body.appendChild(n)},template:function(t,e){return t.replace(/\{ *([\w_-]+) *\}/g,(function(t,n){var r=e[n];if(void 0===r)throw new Error(b.JSON_VALUE_ERROR+t);return"function"==typeof r&&(r=r(e)),r}))}},S=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var _=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.audio=new Audio,this.audio.src=e}return S(t,[{key:"play",value:function(){!this.muted&&this.audio.play()}},{key:"pause",value:function(){this.audio.pause()}},{key:"muted",get:function(){return this.audio.muted},set:function(t){this.audio.muted=t}}]),t}(),R=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var O=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"String"===M.getDataType(e)&&(e=document.querySelector("#"+e)),this.ctx=e.getContext("2d")}return R(t,[{key:"drawLine",value:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};this.cxt.beginPath();var o=i.width||1,a=i.color||"#000";this.cxt.lineWidth=o,this.cxt.fillStyle=a,this.cxt.moveTo(t,e),this.cxt.lineTo(n,r),this.cxt.closePath(),this.cxt.fill()}},{key:"drawArc",value:function(t,e,n,r,i,o,a,s){a?(this.cxt.fillStyle=s,this.cxt.beginPath(),this.cxt.arc(t,e,n,y.degreesToRadians(r),y.degreesToRadians(i),o),this.cxt.closePath(),this.cxt.fill()):(this.cxt.strokeStyle=s,this.cxt.beginPath(),this.cxt.arc(t,e,n,y.degreesToRadians(r),y.degreesToRadians(i),o),this.cxt.stroke())}}]),t}(),T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();function A(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var I=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(A(this,t),"string"==typeof e)if("<"==e.charAt(0)&&">"==e.slice(-1)){var r=e.slice(1,-1);this[0]=document.createElement(r),this.length=1}else{for(var i=n.querySelectorAll(e),o=0;o<i.length;o++)this[o]=i[o];this.length=i.length}else{if(void 0===e)return this;"function"==typeof e?this.ready(e):1==e.nodeType&&(this[0]=e,this.length=1)}}return C(t,[{key:"each",value:function(t){for(var e=0;e<this.length;e++)t(this[e],e)}},{key:"html",value:function(t){return this.each((function(e){e.innerHTML=t})),this}},{key:"css",value:function(t,e){return this.each((function(n){if("object"==(void 0===t?"undefined":T(t)))for(var r in t)"width"!=r&&"height"!=r&&"margin"!=r&&"fontSize"!=r||(n.style[r]=parseInt(t[r])+"px"),n.style[r]=t[r];else n.style[t]=e})),this}},{key:"ready",value:function(t){var e=this;document.addEventListener("DOMContentLoaded",(function(n){t.call(e,n)}))}},{key:"click",value:function(t){return this.each((function(e){var n=this;e.onclick=function(r){t.call(n,r,e)}})),this}},{key:"on",value:function(t,e){var n=this;this.each((function(r){r.addEventListener(t,(function(t){e.call(n,t)}))}))}},{key:"appendTo",value:function(t){if("string"==typeof t)for(var e=document.querySelectorAll(t),n=this[0],r=0;r<e.length;r++)this[r]=n.cloneNode(!0),e[r].appendChild(this[r]),this.length=e.length;else t.appendChild(this[0]);return this}}]),t}(),x=I;function k(){}window.$=function(t,e){return new I(t,e)},Object.assign(k.prototype,{addEventListener:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];void 0===this._listeners&&(this._listeners={}),this._mutex=this._mutex||{},this._context=n;var i=this._mutex,o=this._listeners;return void 0===o[t]&&(o[t]=[]),-1===o[t].indexOf(e)&&(r&&(i[t]=e),o[t].push(e)),this},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var n=this._listeners[t];if(this._mutex[t]===e&&(this._mutex[t]=null),void 0!==n){var r=n.indexOf(e);-1!==r&&n.splice(r,1)}}},dispatchEvent:function(t){var e=this;if(void 0!==this._listeners){var n=this._listeners[t.type];if(void 0!==n){t.target=this;var r=n.slice(0);if(this._mutex[t.type])return void r.find((function(n){return n===e._mutex[t.type]})).call(this._context||this,t);for(var i=0,o=r.length;i<o;i++)r[i].call(this._context||this,t)}}},removeAllListener:function(){for(var t in this._mutex={},this._listeners)this._listeners[t]=[]}});var P=k,D=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var L=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.elements=[],new Map}return D(t,[{key:"set",value:function(t,e){Map.prototype.set.call(this,t,e),this.elements.push({key:t,value:e})}},{key:"delete",value:function(t){Map.prototype.delete.call(this,t),this.elements=this.elements.filter((function(e){return e.key!==t}))}},{key:"isEmpty",value:function(){return 0===this.size}},{key:"clear",value:function(){Map.prototype.clear.call(this),this.elements=[]}}],[{key:"fromEntries",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=new t;return e.forEach((function(t){Array.isArray(t)&&2===t.length&&n.set(t[0],t[1])})),n}}]),t}(),N=n(0),U=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();function j(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function F(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var B=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};j(this,e);var n=F(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.context=M.extend(e.defaultContext,t),n.options={connectTimeout:n.context.MQTT_TIMEOUTM,clientId:M.generateGuid(),username:n.context.MQTT_USERNAME,password:n.context.MQTT_PASSWORD,clean:!0},n.client=Object(N.connect)(n.context.MQTT_SERVICE,n.options),n._onConnect(),n._onMessage(),e.instance=n,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),U(e,[{key:"_onConnect",value:function(){var t=this;this.client.on("connect",(function(){console.log("链接mqtt成功==>"+t.context.MQTT_SERVICE),t.dispatchEvent({type:E.MQTT_CONNECT,message:t})})),this.client.on("error",(function(e){console.log("链接mqtt报错",e),t.dispatchEvent({type:E.MQTT_ERROR,message:t}),t.client.end(),t.client.reconnect()}))}},{key:"_onMessage",value:function(){var t=this;this.client.on("message",(function(e,n){var r=n,i="";n instanceof Uint8Array&&(r=n.toString());try{i=JSON.parse(r)}catch(t){throw new Error(b.JSON_PARSE_ERROR)}t.dispatchEvent({type:E.MQTT_MESSAGE,message:{topic:e,data:i}})}))}},{key:"sendMsg",value:function(t,e){this.client.connected?this.client.publish(t,e,{qos:1,retain:!0}):console.error("客户端未连接")}},{key:"subscribe",value:function(t){return this.client.subscribe(t,{qos:1},(function(e,n){e instanceof Error||0===n.length?console.error("订阅失败==>"+t,e):console.log("订阅成功==>"+t)})),this}},{key:"unsubscribe",value:function(t){return this.client.unsubscribe(t,{qos:1},(function(e,n){e instanceof Error||0===n.length?console.error("取消订阅失败==>"+t,e):console.log("取消订阅成功==>"+t)})),this}},{key:"unconnect",value:function(){this.client.end(),this.client=null,this.dispatchEvent({type:E.MQTT_CLOSE,message:null}),console.log("断开mqtt成功==>"+this.context.MQTT_SERVICE)}}],[{key:"getInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.instance?Object.freeze(e.instance):Object.freeze(new e(t))}}]),e}(P),q=B;B.defaultContext={MQTT_TIMEOUTM:2e4,MQTT_USERNAME:"iRVMS-WEB",MQTT_PASSWORD:"novasky888",MQTT_SERVICE:"ws://"+window.document.domain+":20007/mqtt"};var G=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function W(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var Q=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ws://127.0.0.1:10088";$(this,e);var n=W(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.maxCheckTimes=10,n.url=t,n.checkTimes=0,n.connectStatus=!1,n.connect(),n.connCheckStatus(n.maxCheckTimes),e.instance=n,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),G(e,[{key:"connect",value:function(){var t=this;if(this.checkTimes++,this.disconnect(),this.url)try{console.info("创建ws连接"+this.url),this.client=new WebSocket(this.url),this.client&&(!this.connectStatus&&this.checkTimes===Math.floor(this.maxCheckTimes/2)||this.connectStatus)&&(this.client.onopen=function(e){t.dispatchEvent({type:E.WEB_SOCKET_CONNECT,message:e})},this.client.onmessage=function(e){t.connectStatus=!0,t.dispatchEvent({type:E.WEB_SOCKET_MESSAGE,message:e})},this.client.onclose=function(e){t.dispatchEvent({type:E.WEB_SOCKET_CLOSE,message:e})},this.client.onerror=function(e){t.dispatchEvent({type:E.WEB_SOCKET_ERROR,message:e})})}catch(t){console.error("创建ws连接失败"+this.url+":"+t)}}},{key:"disconnect",value:function(){if(this.client)try{console.log("ws断开连接"+this.url),this.client.close(),this.client=null}catch(t){this.client=null}}},{key:"connCheckStatus",value:function(t){var e=this;this.checkTimes>t||setTimeout((function(){e.client&&0!==e.client.readyState&&1!==e.client.readyState&&e.connect(),e.connCheckStatus(t)}),2e3)}},{key:"send",value:function(t){return this.client&&1===this.client.readyState?(this.client.send(t),!0):(console.error(this.url+"消息发送失败:"+t),!1)}},{key:"heartbeat",value:function(){var t=this;setTimeout((function(){t.client&&1===t.client.readyState&&t.send("HeartBeat"),console.log("HeartBeat,"+t.url),setTimeout(t.heartbeat,3e4)}),1e3)}}],[{key:"getInstance",value:function(){return e.instance?e.instance:Object.freeze(new e)}},{key:"_instance",get:function(){return this.getInstance()}}]),e}(P),z=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();function K(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var V=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(K(this,t),this.cacheType=e,1===e)this.storage=window.localStorage;else{if(2!==e)throw new Error(b.PARAMETER_ERROR);this.storage=window.sessionStorage}}return z(t,[{key:"setItem",value:function(t,e,n){var r={key:t,value:e};if(1===this.cacheType){var i=Date.now();n&&(r.expired=i+1e3*n)}return this.storage[t]=JSON.stringify(r),r}},{key:"getItem",value:function(t){var e=this.storage.getItem(t)||null,n=JSON.parse(e)||{};if(1===this.cacheType){var r=n.expired||Date.now();if(Date.now()>r)return this.remove(t),null}return n.value}},{key:"remove",value:function(t){var e=this;t&&(t.indexOf(",")>-1?t.split(",").forEach((function(t){e.storage.removeItem(t)})):this.storage.removeItem(t))}},{key:"clear",value:function(){this.storage.clear()}}]),t}()}])}));
2
- //# sourceMappingURL=resource.min.js.map
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("mqtt"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define("Gis", ["mqtt"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["Gis"] = factory(require("mqtt"));
8
+ else
9
+ root["Gis"] = factory(root["mqtt"]);
10
+ })(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // define getter function for harmony exports
47
+ /******/ __webpack_require__.d = function(exports, name, getter) {
48
+ /******/ if(!__webpack_require__.o(exports, name)) {
49
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
+ /******/ }
51
+ /******/ };
52
+ /******/
53
+ /******/ // define __esModule on exports
54
+ /******/ __webpack_require__.r = function(exports) {
55
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
+ /******/ }
58
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
+ /******/ };
60
+ /******/
61
+ /******/ // create a fake namespace object
62
+ /******/ // mode & 1: value is a module id, require it
63
+ /******/ // mode & 2: merge all properties of value into the ns
64
+ /******/ // mode & 4: return value when already ns object
65
+ /******/ // mode & 8|1: behave like require
66
+ /******/ __webpack_require__.t = function(value, mode) {
67
+ /******/ if(mode & 1) value = __webpack_require__(value);
68
+ /******/ if(mode & 8) return value;
69
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
+ /******/ var ns = Object.create(null);
71
+ /******/ __webpack_require__.r(ns);
72
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
+ /******/ return ns;
75
+ /******/ };
76
+ /******/
77
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
78
+ /******/ __webpack_require__.n = function(module) {
79
+ /******/ var getter = module && module.__esModule ?
80
+ /******/ function getDefault() { return module['default']; } :
81
+ /******/ function getModuleExports() { return module; };
82
+ /******/ __webpack_require__.d(getter, 'a', getter);
83
+ /******/ return getter;
84
+ /******/ };
85
+ /******/
86
+ /******/ // Object.prototype.hasOwnProperty.call
87
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
+ /******/
89
+ /******/ // __webpack_public_path__
90
+ /******/ __webpack_require__.p = "/dist/";
91
+ /******/
92
+ /******/
93
+ /******/ // Load entry module and return exports
94
+ /******/ return __webpack_require__(__webpack_require__.s = 1);
95
+ /******/ })
96
+ /************************************************************************/
97
+ /******/ ([
98
+ /* 0 */
99
+ /***/ (function(module, exports) {
100
+
101
+ module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
102
+
103
+ /***/ }),
104
+ /* 1 */
105
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
+
107
+ "use strict";
108
+ // ESM COMPAT FLAG
109
+ __webpack_require__.r(__webpack_exports__);
110
+
111
+ // EXPORTS
112
+ __webpack_require__.d(__webpack_exports__, "AnimateUtils", function() { return /* reexport */ AnimateUtils; });
113
+ __webpack_require__.d(__webpack_exports__, "ArrayUtils", function() { return /* reexport */ ArrayUtils; });
114
+ __webpack_require__.d(__webpack_exports__, "BrowserUtils", function() { return /* reexport */ BrowserUtils; });
115
+ __webpack_require__.d(__webpack_exports__, "Cookie", function() { return /* reexport */ Cookie; });
116
+ __webpack_require__.d(__webpack_exports__, "CoordsUtils", function() { return /* reexport */ CoordsUtils; });
117
+ __webpack_require__.d(__webpack_exports__, "DateUtils", function() { return /* reexport */ DateUtils; });
118
+ __webpack_require__.d(__webpack_exports__, "DomUtils", function() { return /* reexport */ DomUtils; });
119
+ __webpack_require__.d(__webpack_exports__, "GeoUtils", function() { return /* reexport */ GeoUtils; });
120
+ __webpack_require__.d(__webpack_exports__, "FileUtils", function() { return /* reexport */ FileUtils; });
121
+ __webpack_require__.d(__webpack_exports__, "MathUtils", function() { return /* reexport */ MathUtils; });
122
+ __webpack_require__.d(__webpack_exports__, "OptimizeUtils", function() { return /* reexport */ OptimizeUtils; });
123
+ __webpack_require__.d(__webpack_exports__, "StringUtils", function() { return /* reexport */ StringUtils; });
124
+ __webpack_require__.d(__webpack_exports__, "Utils", function() { return /* reexport */ CommUtils; });
125
+ __webpack_require__.d(__webpack_exports__, "EventType", function() { return /* reexport */ EventTypeConstant; });
126
+ __webpack_require__.d(__webpack_exports__, "ErrorType", function() { return /* reexport */ ErrorTypeConstant; });
127
+ __webpack_require__.d(__webpack_exports__, "LayerType", function() { return /* reexport */ LayerType; });
128
+ __webpack_require__.d(__webpack_exports__, "AudioPlayer", function() { return /* reexport */ core_AudioPlayer; });
129
+ __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /* reexport */ core_CanvasDrawer; });
130
+ __webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
131
+ __webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
132
+ __webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
133
+ __webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
134
+ __webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
135
+ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
136
+
137
+ // CONCATENATED MODULE: ./src/utils/AnimateUtils.js
138
+ /* harmony default export */ var AnimateUtils = ({
139
+ /**
140
+ * 多属性的动画函数
141
+ * @param {*} ele 需要运动的节点
142
+ * @param {*} attr_options 传入的是一个需要运动的属性包括运动的目标值,操作的节点属性
143
+ * @param {*} timefn 运动的形式,默认是缓冲运动
144
+ * @param {*} speed 运动的速度
145
+ */
146
+ animate: function animate(ele, attr_options, callback) {
147
+ var timefn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "swing";
148
+ var speed = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 5;
149
+
150
+ for (var attr in attr_options) {
151
+ attr_options[attr] = {
152
+ target: attr === "opacity" ? parseInt(attr_options[attr] * 100) : attr_options[attr],
153
+ // 需要计算得到
154
+ iNow: attr === "opacity" ? parseInt(getComputedStyle(ele)[attr] * 100) : parseInt(getComputedStyle(ele)[attr])
155
+ };
156
+ }
157
+
158
+ // 判断是不是匀速运动
159
+ if (timefn === "liner") {
160
+ speed = attr_options[attr].iNow < attr_options[attr].target ? Math.abs(speed) : -Math.abs(speed);
161
+ }
162
+ // 为了防止每个节点的定时器冲突,每次进入的时候我们需要先清理下节点的定时器
163
+ clearInterval(ele.timer);
164
+ // 然后再去设置定时器
165
+ ele.timer = setInterval(function () {
166
+ // 因为是多属性运动,我们首先循环遍历每一个属性
167
+ for (var attr in attr_options) {
168
+ var target = attr_options[attr].target;
169
+
170
+ var iNow = attr_options[attr].iNow;
171
+
172
+ // 计算speed 判断是不是缓冲运动
173
+ if (timefn === "swing") {
174
+ speed = (target - iNow) / 20;
175
+ // 为了防止速度无法达到一个整数
176
+ speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
177
+ }
178
+
179
+ // 运动之中条件的判断
180
+ if (Math.abs(target - iNow) <= Math.abs(speed)) {
181
+ if (attr === "opacity") {
182
+ ele.style[attr] = target / 100;
183
+ } else {
184
+ ele.style[attr] = target + "px";
185
+ }
186
+
187
+ // 每次一个属性运动完成之后我们就直接将它删除
188
+ delete attr_options[attr];
189
+
190
+ // 每次都去循环看一下还有没有属性需要操作
191
+ for (var num in attr_options) {
192
+ return false;
193
+ }
194
+ // 清理定时器 因为我们是一个定时器绑定多个属性操作所以我们需要保证所有的属性都完成之后我们才可以将定时器清除
195
+ clearInterval(ele.timer);
196
+ // 等结束之后我们需要判断这个回到函数是函数我们就回调
197
+ typeof callback === "function" ? callback() : "";
198
+ } else {
199
+ attr_options[attr].iNow += speed;
200
+ if (attr === "opacity") {
201
+ ele.style[attr] = attr_options[attr].iNow / 100;
202
+ } else {
203
+ ele.style[attr] = attr_options[attr].iNow + "px";
204
+ }
205
+ }
206
+ }
207
+ }, 30);
208
+ }
209
+ });
210
+ // CONCATENATED MODULE: ./src/constant/EventTypeConstant.js
211
+ /* harmony default export */ var EventTypeConstant = ({
212
+ MAP_RENDER: "mapRender",
213
+ MAP_READY: "mapReady",
214
+ MOUSE_CLICK: "click",
215
+ MOUSE_DOUBLE_CLICK: "dblclick",
216
+ MOUSE_MOVE: "mousemove",
217
+ MOUSE_IN: "mousein",
218
+ MOUSE_OUT: "mouseout",
219
+ MOUSE_RIGHT_CLICK: "mouseRightClick",
220
+ KEY_DOWN: "keyDown",
221
+ KEY_UP: "keyUp",
222
+ DRAW_ACTIVE: "drawActive",
223
+ DRAW_MOVE: "drawMove",
224
+ DRAW_COMPLETE: "drawComplete",
225
+ MQTT_CONNECT: "mqttConnect",
226
+ MQTT_ERROR: "mqttError",
227
+ MQTT_MESSAGE: "mqttMessage",
228
+ MQTT_CLOSE: "mqttClose",
229
+ WEB_SOCKET_CONNECT: "webSocketConnect",
230
+ WEB_SOCKET_ERROR: "webSocketError",
231
+ WEB_SOCKET_MESSAGE: "webSocketMessage",
232
+ WEB_SOCKET_CLOSE: "webSocketClose"
233
+ });
234
+ // CONCATENATED MODULE: ./src/constant/ErrorTypeConstant.js
235
+ /* harmony default export */ var ErrorTypeConstant = ({
236
+ LOGIN_EXPIRED: "登录信息过期,请重新登录",
237
+ CROSS_ERROR: "跨域访问",
238
+ UNEXIST_RESOURCE: "资源不存在",
239
+ TIMEOUT: "请求超时",
240
+ INTERNAL_ERROR: "内部错误",
241
+ NETWORK_ERROR: "请求失败,请检查网络是否已连接",
242
+ PROCESS_FAIL: "处理失败",
243
+ AUTH_VERIFY_ERROR: "权限验证失败",
244
+ NO_DATA_FOUND: "未找到数据",
245
+ DUPLICATE_INSTANCE: "实例为单例模式,不允许重复构建",
246
+ COORDINATE_ERROR: "坐标验证失败",
247
+ JSON_PARSE_ERROR: "JSON解析失败,格式有误",
248
+ JSON_VALUE_ERROR: "JSON无此键",
249
+ PARAMETER_ERROR: "参数验证失败",
250
+ PARAMETER_ERROR_ARRAY: "参数格式验证失败:必须是数组",
251
+ PARAMETER_ERROR_STRING: "参数格式验证失败:必须是字符",
252
+ PARAMETER_ERROR_FUNCTION: "参数格式验证失败:必须是函数",
253
+ PARAMETER_ERROR_LACK: "参数缺失项"
254
+ });
255
+ // CONCATENATED MODULE: ./src/constant/LayerType.js
256
+ /* harmony default export */ var LayerType = ({
257
+ SUPER_MAP_IMAGES: "SuperMapImages", // 超图影像服务 栅格数据
258
+ SUPER_MAP_DATA: "SuperMapData", // 超图服务 矢量数据
259
+ ARC_GIS_MAP_IMAGES: "ArcGisMapImages", // arcGis影像图层 栅格数据
260
+ ARC_GIS_MAP_DATA: "ArcGisMapData", // arcGis图层 矢量数据
261
+ OSGB_LAYER: "OSGBLayer",
262
+ S3M_GROUP: "S3MGroup", // addS3MGroupLayer(url, options, index) 添加S3M分组图层。
263
+ TERRAIN_LAYER: "TerrainFileLayer" // 地形图层, 需要单独处理
264
+ });
265
+ // CONCATENATED MODULE: ./src/constant/index.js
266
+
267
+
268
+
269
+ // CONCATENATED MODULE: ./src/utils/CommUtils.js
270
+
271
+
272
+ /* eslint-disable no-extend-native, space-in-parens */
273
+ /* harmony default export */ var CommUtils = ({
274
+ /**
275
+ * 判断数据类型
276
+ *
277
+ * @param {*} data
278
+ * @returns {*}
279
+ */
280
+ getDataType: function getDataType(data) {
281
+ return Object.prototype.toString.call(data).slice(8, -1);
282
+ },
283
+ isEmpty: function isEmpty(value) {
284
+ if (value == null) {
285
+ // 等同于 value === undefined || value === null
286
+ return true;
287
+ }
288
+ var type = this.getDataType(value);
289
+ switch (type) {
290
+ case 'String':
291
+ return value.trim() === '';
292
+ case 'Array':
293
+ return !value.length;
294
+ case 'Object':
295
+ return !Object.keys(value).length;
296
+ case 'Boolean':
297
+ return !value;
298
+ default:
299
+ return false; // 其他对象均视作非空
300
+ }
301
+ },
302
+ isNotEmpty: function isNotEmpty(val) {
303
+ return !this.isEmpty(val);
304
+ },
305
+ json2form: function json2form(json) {
306
+ var formData = new FormData();
307
+ Object.keys(json).forEach(function (key) {
308
+ formData.append(key, json[key] instanceof Object ? JSON.stringify(json[key]) : json[key]);
309
+ });
310
+ return formData;
311
+ },
312
+
313
+ /**
314
+ * json转换成get参数形式
315
+ *
316
+ * @param {*} json
317
+ * @returns {*}
318
+ */
319
+ jsontoQuery: function jsontoQuery(json) {
320
+ var tempArr = [];
321
+ for (var i in json) {
322
+ var key = i;
323
+ var value = json[i];
324
+ tempArr.push(key + '=' + value);
325
+ }
326
+ var urlParamsStr = tempArr.join('&');
327
+ return urlParamsStr;
328
+ },
329
+ generateGuid: function generateGuid() {
330
+ var S4 = function S4() {
331
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
332
+ };
333
+ return S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4();
334
+ },
335
+ decodeDict: function decodeDict() {
336
+ var res = '';
337
+
338
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
339
+ args[_key] = arguments[_key];
340
+ }
341
+
342
+ if (args.length > 1) {
343
+ var items = args.slice(1, args.length % 2 === 0 ? args.length - 1 : args.length);
344
+ for (var i = 0; i < items.length; i = i + 2) {
345
+ var item = items[i];
346
+ if (args[0] === item) {
347
+ res = items[i + 1];
348
+ }
349
+ }
350
+ if (!res && args.length % 2 === 0) {
351
+ res = args[args.length - 1];
352
+ }
353
+ } else {
354
+ res = args[0];
355
+ }
356
+ return res;
357
+ },
358
+ extend: function extend(dest) {
359
+ var i = void 0,
360
+ j = void 0,
361
+ len = void 0,
362
+ src = void 0;
363
+
364
+ for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
365
+ args[_key2 - 1] = arguments[_key2];
366
+ }
367
+
368
+ for (j = 0, len = args.length; j < len; j++) {
369
+ src = args[j];
370
+ for (i in src) {
371
+ dest[i] = src[i];
372
+ }
373
+ }
374
+ return dest;
375
+ },
376
+ rgb2hex: function rgb2hex(rgb) {
377
+ var hex = '#' + ((1 << 24) + (rgb[0] << 16) + (rgb[1] << 8) + rgb[2]).toString(16).slice(1);
378
+ return hex;
379
+ },
380
+
381
+ /**
382
+ * 将平级对象列表转换为树形结构对象列表
383
+ *
384
+ * @param {Array} data
385
+ * @param {string} [idPropertyName="id"]
386
+ * @param {string} [parentIdPropertyName="parentId"]
387
+ * @param {string} [childrenPropertyName="children"]
388
+ * @returns {*}
389
+ */
390
+ convertToTree2: function convertToTree2(data) {
391
+ var idPropertyName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
392
+ var parentIdPropertyName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'parentId';
393
+ var childrenPropertyName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'children';
394
+
395
+ var result = [];
396
+ function buildChildren(item) {
397
+ var id = item[idPropertyName];
398
+ var children = data.filter(function (item2) {
399
+ return item2.hasOwnProperty(parentIdPropertyName) && item2[parentIdPropertyName] === id;
400
+ });
401
+ if (children.length > 0) {
402
+ children.forEach(buildChildren);
403
+ item[childrenPropertyName] = children;
404
+ }
405
+ }
406
+
407
+ var _loop = function _loop(item) {
408
+ if (data.findIndex(function (t) {
409
+ return t[idPropertyName] === item[parentIdPropertyName];
410
+ }) === -1) {
411
+ buildChildren(item);
412
+ result.push(item);
413
+ }
414
+ };
415
+
416
+ var _iteratorNormalCompletion = true;
417
+ var _didIteratorError = false;
418
+ var _iteratorError = undefined;
419
+
420
+ try {
421
+ for (var _iterator = data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
422
+ var item = _step.value;
423
+
424
+ _loop(item);
425
+ }
426
+ } catch (err) {
427
+ _didIteratorError = true;
428
+ _iteratorError = err;
429
+ } finally {
430
+ try {
431
+ if (!_iteratorNormalCompletion && _iterator.return) {
432
+ _iterator.return();
433
+ }
434
+ } finally {
435
+ if (_didIteratorError) {
436
+ throw _iteratorError;
437
+ }
438
+ }
439
+ }
440
+
441
+ return result;
442
+ },
443
+
444
+ /**
445
+ * 异步加载script
446
+ *
447
+ * @param {*} url
448
+ * @param {function} callback
449
+ */
450
+ loadScript: function loadScript(url, callback) {
451
+ var oscript = document.createElement('script');
452
+ if (oscript.readyState) {
453
+ // ie8及以下版本
454
+ oscript.onreadystatechange = function () {
455
+ if (oscript.readyState === 'complete' || oscript.readyState === 'loaded') {
456
+ callback();
457
+ }
458
+ };
459
+ } else {
460
+ oscript.onload = function () {
461
+ callback();
462
+ };
463
+ }
464
+ oscript.src = url;
465
+ document.body.appendChild(oscript);
466
+ },
467
+
468
+ /**
469
+ * 提取json中的value组成一个新的字符串
470
+ * eg: template('aaa{key}', json)
471
+ *
472
+ * @param {*} str
473
+ * @param {*} data
474
+ * @returns {*}
475
+ */
476
+ template: function template(str, data) {
477
+ var templateRe = /\{ *([\w_-]+) *\}/g;
478
+ return str.replace(templateRe, function (str, key) {
479
+ var value = data[key];
480
+ if (value === undefined) {
481
+ throw new Error(ErrorTypeConstant.JSON_VALUE_ERROR + str);
482
+ } else if (typeof value === 'function') {
483
+ value = value(data);
484
+ }
485
+ return value;
486
+ });
487
+ }
488
+ });
489
+ // CONCATENATED MODULE: ./src/utils/ArrayUtils.js
490
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
491
+
492
+
493
+ /**
494
+ * 分组函数,暂时无法进行多层分组。如有需要可以使用groupBy+map+flat方法打平
495
+ * @param {*} f
496
+ */
497
+ Array.prototype.groupBy = function (f) {
498
+ var groups = {};
499
+ this.forEach(function (o) {
500
+ var group = JSON.stringify(f(o));
501
+ groups[group] = groups[group] || [];
502
+ groups[group].push(o);
503
+ });
504
+ return Object.keys(groups).map(function (group) {
505
+ return groups[group];
506
+ });
507
+ };
508
+ /**
509
+ * 用于数组对象去重
510
+ * 单纯数组可用[...new Set(arr)]
511
+ * @param {*} f
512
+ */
513
+ Array.prototype.distinct = function (f) {
514
+ var arr = [],
515
+ obj = {};
516
+ this.forEach(function (item) {
517
+ var val = f(item);
518
+ !obj[val] && (obj[val] = arr.push(item));
519
+ });
520
+ return arr;
521
+ };
522
+ Array.prototype.max = function () {
523
+ return Math.max.apply({}, this);
524
+ };
525
+ Array.prototype.min = function () {
526
+ return Math.min.apply({}, this);
527
+ };
528
+ Array.prototype.sum = function () {
529
+ return this.length > 0 ? this.reduce(function () {
530
+ var prev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
531
+ var curr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
532
+ return prev + curr;
533
+ }) : 0;
534
+ };
535
+ Array.prototype.desc = function (f) {
536
+ return this.sort(function (n1, n2) {
537
+ return (f ? f(n2) : n2) - (f ? f(n1) : n1);
538
+ });
539
+ };
540
+ Array.prototype.asc = function (f) {
541
+ return this.sort(function (n1, n2) {
542
+ return (f ? f(n1) : n1) - (f ? f(n2) : n2);
543
+ });
544
+ };
545
+ Array.prototype.clear = function () {
546
+ this.length = 0;
547
+ return this;
548
+ };
549
+ /* harmony default export */ var ArrayUtils = ({
550
+ asArray: function asArray(obj) {
551
+ return CommUtils.isEmpty(obj) ? [] : Array.isArray(obj) ? obj : [obj];
552
+ },
553
+ generateArray: function generateArray(length) {
554
+ return [].concat(_toConsumableArray(new Array(length).keys()));
555
+ },
556
+ union: function union() {
557
+ var res = [];
558
+
559
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
560
+ args[_key] = arguments[_key];
561
+ }
562
+
563
+ args.forEach(function (arg) {
564
+ if (Array.isArray(arg)) {
565
+ res = res.concat(arg.filter(function (v) {
566
+ return !res.includes(v);
567
+ }));
568
+ }
569
+ });
570
+ return res;
571
+ },
572
+ intersection: function intersection() {
573
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
574
+ args[_key2] = arguments[_key2];
575
+ }
576
+
577
+ var res = args[0] || [];
578
+ args.forEach(function (arg) {
579
+ if (Array.isArray(arg)) {
580
+ res = res.filter(function (v) {
581
+ return arg.includes(v);
582
+ });
583
+ }
584
+ });
585
+ return res;
586
+ },
587
+ unionAll: function unionAll() {
588
+ for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
589
+ args[_key3] = arguments[_key3];
590
+ }
591
+
592
+ return [].concat(_toConsumableArray(args)).flat().filter(function (d) {
593
+ return !!d;
594
+ });
595
+ },
596
+ difference: function difference() {
597
+ var _this = this;
598
+
599
+ for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
600
+ args[_key4] = arguments[_key4];
601
+ }
602
+
603
+ return this.union.apply(this, _toConsumableArray(args)).filter(function (d) {
604
+ return !_this.intersection.apply(_this, _toConsumableArray(args)).includes(d);
605
+ });
606
+ }
607
+ });
608
+ // CONCATENATED MODULE: ./src/utils/BrowserUtils.js
609
+ /* harmony default export */ var BrowserUtils = ({
610
+ getUrlParams: function getUrlParams() {
611
+ var href = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.href;
612
+ var needDecode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
613
+
614
+ var reg = /([^&=]+)=([\w\W]*?)(&|$|#)/g;
615
+
616
+ var _ref = new URL(href),
617
+ search = _ref.search,
618
+ hash = _ref.hash;
619
+
620
+ var args = [search, hash];
621
+ var obj = {};
622
+ for (var i = 0; i < args.length; i++) {
623
+ var str = args[i];
624
+ if (str) {
625
+ var s = str.replace(/#|\//g, "");
626
+ var arr = s.split("?");
627
+ if (arr.length > 1) {
628
+ for (var _i = 1; _i < arr.length; _i++) {
629
+ var res = void 0;
630
+ while (res = reg.exec(arr[_i])) {
631
+ obj[res[1]] = needDecode ? decodeURIComponent(res[2]) : res[2];
632
+ }
633
+ }
634
+ }
635
+ }
636
+ }
637
+ return obj;
638
+ },
639
+ getExplorer: function getExplorer() {
640
+ var explorer = window.navigator.userAgent;
641
+ if (explorer.indexOf("MSIE") >= 0) {
642
+ return "IE";
643
+ }
644
+ if (!!window.ActiveXObject || "ActiveXObject" in window) {
645
+ // IE
646
+ return "IE";
647
+ } else if (explorer.indexOf("Firefox") >= 0) {
648
+ // Firefox
649
+ return "Firefox";
650
+ } else if (explorer.indexOf("Chrome") >= 0) {
651
+ // Chrome
652
+ return "Chrome";
653
+ } else if (explorer.indexOf("Opera") >= 0) {
654
+ // Opera
655
+ return "Opera";
656
+ } else if (explorer.indexOf("Safari") >= 0) {
657
+ // Safari
658
+ return "Safari";
659
+ }
660
+ },
661
+ switchFullScreen: function switchFullScreen(status) {
662
+ if (status) {
663
+ var element = document.documentElement;
664
+ if (element.requestFullscreen) {
665
+ element.requestFullscreen();
666
+ } else if (element.msRequestFullscreen) {
667
+ element.msRequestFullscreen();
668
+ } else if (element.mozRequestFullScreen) {
669
+ element.mozRequestFullScreen();
670
+ } else if (element.webkitRequestFullscreen) {
671
+ element.webkitRequestFullscreen();
672
+ }
673
+ } else {
674
+ if (document.exitFullscreen) {
675
+ document.exitFullscreen();
676
+ } else if (document.msExitFullscreen) {
677
+ document.msExitFullscreen();
678
+ } else if (document.mozCancelFullScreen) {
679
+ document.mozCancelFullScreen();
680
+ } else if (document.webkitExitFullscreen) {
681
+ document.webkitExitFullscreen();
682
+ }
683
+ }
684
+ },
685
+
686
+ /**
687
+ * scale屏幕适配方案
688
+ */
689
+ refreshScale: function refreshScale() {
690
+ var baseWidth = document.documentElement.clientWidth;
691
+ var baseHeight = document.documentElement.clientHeight;
692
+ var appStyle = document.getElementById("app").style;
693
+ var realRatio = baseWidth / baseHeight;
694
+ var designRatio = 16 / 9;
695
+ var scaleRate = baseWidth / 1920;
696
+ if (realRatio > designRatio) {
697
+ scaleRate = baseHeight / 1080;
698
+ }
699
+ appStyle.transformOrigin = "left top";
700
+ appStyle.transform = "scale(" + scaleRate + ") translateX(-49.99%)";
701
+ appStyle.width = baseWidth / scaleRate + "px";
702
+ },
703
+
704
+ /**
705
+ * rem屏幕适配方案
706
+ */
707
+ getHtmlFontSize: function getHtmlFontSize() {
708
+ var htmlwidth = document.documentElement.clientWidth || document.body.clientWidth;
709
+ var htmlDom = document.querySelector("html");
710
+ htmlDom.style.fontSize = htmlwidth / 192 + "px";
711
+ }
712
+ });
713
+ // CONCATENATED MODULE: ./src/utils/Cookie.js
714
+ /* harmony default export */ var Cookie = ({
715
+ set: function set(name, value) {
716
+ var Days = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 30;
717
+
718
+ var exp = new Date();
719
+ exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
720
+ document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
721
+ },
722
+ remove: function remove(name) {
723
+ var exp = new Date();
724
+ exp.setTime(exp.getTime() - 1);
725
+ var cval = getCookie(name);
726
+ if (cval != null) {
727
+ document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
728
+ }
729
+ },
730
+ get: function get(name) {
731
+ var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
732
+ if (arr != null) {
733
+ return arr[2];
734
+ } else {
735
+ return "";
736
+ }
737
+ }
738
+ });
739
+ // CONCATENATED MODULE: ./src/utils/CoordsUtils.js
740
+ /* harmony default export */ var CoordsUtils = ({
741
+ PI: 3.14159265358979324,
742
+ XPI: 3.14159265358979324 * 3000.0 / 180.0,
743
+ delta: function delta(lat, lon) {
744
+ var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
745
+ var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
746
+ var dLat = this.transformLat(lon - 105.0, lat - 35.0);
747
+ var dLon = this.transformLon(lon - 105.0, lat - 35.0);
748
+ var radLat = lat / 180.0 * this.PI;
749
+ var magic = Math.sin(radLat);
750
+ magic = 1 - ee * magic * magic;
751
+ var sqrtMagic = Math.sqrt(magic);
752
+ dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
753
+ dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
754
+ return { lat: dLat, lon: dLon };
755
+ },
756
+
757
+ // WGS-84 to GCJ-02
758
+ gcjEncrypt: function gcjEncrypt(wgsLat, wgsLon) {
759
+ if (this.outOfChina(wgsLat, wgsLon)) {
760
+ return { lat: wgsLat, lon: wgsLon };
761
+ }
762
+
763
+ var d = this.delta(wgsLat, wgsLon);
764
+ return { lat: wgsLat + d.lat, lon: wgsLon + d.lon };
765
+ },
766
+
767
+ // GCJ-02 to WGS-84
768
+ gcjDecrypt: function gcjDecrypt(gcjLat, gcjLon) {
769
+ if (this.outOfChina(gcjLat, gcjLon)) {
770
+ return { lat: gcjLat, lon: gcjLon };
771
+ }
772
+
773
+ var d = this.delta(gcjLat, gcjLon);
774
+ return { lat: gcjLat - d.lat, lon: gcjLon - d.lon };
775
+ },
776
+
777
+ // GCJ-02 to WGS-84 exactly
778
+ gcjDecryptExact: function gcjDecryptExact(gcjLat, gcjLon) {
779
+ var initDelta = 0.01;
780
+ var threshold = 0.000000001;
781
+ var dLat = initDelta;
782
+ var dLon = initDelta;
783
+ var mLat = gcjLat - dLat;
784
+ var mLon = gcjLon - dLon;
785
+ var pLat = gcjLat + dLat;
786
+ var pLon = gcjLon + dLon;
787
+ var wgsLat = void 0;
788
+ var wgsLon = void 0;
789
+ var i = 0;
790
+ while (1) {
791
+ wgsLat = (mLat + pLat) / 2;
792
+ wgsLon = (mLon + pLon) / 2;
793
+ var tmp = this.gcj_encrypt(wgsLat, wgsLon);
794
+ dLat = tmp.lat - gcjLat;
795
+ dLon = tmp.lon - gcjLon;
796
+ if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
797
+ break;
798
+ }
799
+
800
+ if (dLat > 0) pLat = wgsLat;else mLat = wgsLat;
801
+ if (dLon > 0) pLon = wgsLon;else mLon = wgsLon;
802
+
803
+ if (++i > 10000) break;
804
+ }
805
+ // console.log(i);
806
+ return { lat: wgsLat, lon: wgsLon };
807
+ },
808
+
809
+ // GCJ-02 to BD-09
810
+ bdEncrypt: function bdEncrypt(gcjLat, gcjLon) {
811
+ var x = gcjLon;
812
+ var y = gcjLat;
813
+ var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.XPI);
814
+ var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.XPI);
815
+ bdLon = z * Math.cos(theta) + 0.0065;
816
+ bdLat = z * Math.sin(theta) + 0.006;
817
+ return { lat: bdLat, lon: bdLon };
818
+ },
819
+
820
+ // BD-09 to GCJ-02
821
+ bdDecrypt: function bdDecrypt(bdLat, bdLon) {
822
+ var x = bdLon - 0.0065;
823
+ var y = bdLat - 0.006;
824
+ var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.XPI);
825
+ var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.XPI);
826
+ var gcjLon = z * Math.cos(theta);
827
+ var gcjLat = z * Math.sin(theta);
828
+ return { lat: gcjLat, lon: gcjLon };
829
+ },
830
+
831
+ // WGS-84 to Web mercator
832
+ // mercatorLat -> y mercatorLon -> x
833
+ mercatorEncrypt: function mercatorEncrypt(wgsLat, wgsLon) {
834
+ var x = wgsLon * 20037508.34 / 180.0;
835
+ var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0);
836
+ y = y * 20037508.34 / 180.0;
837
+ return { lat: y, lon: x
838
+ /*
839
+ if ((Math.abs(wgsLon) > 180 || Math.abs(wgsLat) > 90))
840
+ return null;
841
+ var x = 6378137.0 * wgsLon * 0.017453292519943295;
842
+ var a = wgsLat * 0.017453292519943295;
843
+ var y = 3189068.5 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
844
+ return {'lat' : y, 'lon' : x};
845
+ // */
846
+ };
847
+ },
848
+
849
+ // Web mercator to WGS-84
850
+ // mercatorLat -> y mercatorLon -> x
851
+ mercatorDecrypt: function mercatorDecrypt(mercatorLat, mercatorLon) {
852
+ var x = mercatorLon / 20037508.34 * 180.0;
853
+ var y = mercatorLat / 20037508.34 * 180.0;
854
+ y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2);
855
+ return { lat: y, lon: x
856
+ /*
857
+ if (Math.abs(mercatorLon) < 180 && Math.abs(mercatorLat) < 90)
858
+ return null;
859
+ if ((Math.abs(mercatorLon) > 20037508.3427892) || (Math.abs(mercatorLat) > 20037508.3427892))
860
+ return null;
861
+ var a = mercatorLon / 6378137.0 * 57.295779513082323;
862
+ var x = a - (Math.floor(((a + 180.0) / 360.0)) * 360.0);
863
+ var y = (1.5707963267948966 - (2.0 * Math.atan(Math.exp((-1.0 * mercatorLat) / 6378137.0)))) * 57.295779513082323;
864
+ return {'lat' : y, 'lon' : x};
865
+ // */
866
+ };
867
+ },
868
+
869
+ // two point's distance
870
+ distance: function distance(latA, lonA, latB, lonB) {
871
+ var earthR = 6371000.0;
872
+ var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180);
873
+ var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0);
874
+ var s = x + y;
875
+ if (s > 1) s = 1;
876
+ if (s < -1) s = -1;
877
+ var alpha = Math.acos(s);
878
+ var distance = alpha * earthR;
879
+ return distance;
880
+ },
881
+ outOfChina: function outOfChina(lat, lon) {
882
+ if (lon < 72.004 || lon > 137.8347) {
883
+ return true;
884
+ }
885
+ if (lat < 0.8293 || lat > 55.8271) {
886
+ return true;
887
+ }
888
+ return false;
889
+ },
890
+ transformLat: function transformLat(x, y) {
891
+ var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
892
+ ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0;
893
+ ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0;
894
+ ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0;
895
+ return ret;
896
+ },
897
+ transformLon: function transformLon(x, y) {
898
+ var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
899
+ ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0;
900
+ ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0;
901
+ ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0;
902
+ return ret;
903
+ }
904
+ });
905
+ // CONCATENATED MODULE: ./src/utils/DateUtils.js
906
+ Date.prototype.format = function (fmt) {
907
+ var o = {
908
+ "M+": this.getMonth() + 1, // 月份
909
+ "d+": this.getDate(), // 日
910
+ "h+": this.getHours(), // 小时
911
+ "m+": this.getMinutes(), // 分
912
+ "s+": this.getSeconds(), // 秒
913
+ "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
914
+ S: this.getMilliseconds() // 毫秒
915
+ };
916
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
917
+ for (var k in o) {
918
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
919
+ }
920
+ return fmt;
921
+ };
922
+ /**
923
+ * 实现的时间增减功能
924
+ *
925
+ * @param {*} interval 字符串表达式,表示要添加的时间间隔类型
926
+ * @param {*} number 数值表达式,表示要添加的时间间隔的个数
927
+ */
928
+ Date.prototype.addDate = function (interval, number) {
929
+ var date = new Date(this);
930
+ switch (interval) {
931
+ case "y":
932
+ date.setFullYear(this.getFullYear() + number);
933
+ break;
934
+ case "q":
935
+ date.setMonth(this.getMonth() + number * 3);
936
+ break;
937
+ case "M":
938
+ date.setMonth(this.getMonth() + number);
939
+ break;
940
+ case "w":
941
+ date.setDate(this.getDate() + number * 7);
942
+ break;
943
+ case "d":
944
+ date.setDate(this.getDate() + number);
945
+ break;
946
+ case "h":
947
+ date.setHours(this.getHours() + number);
948
+ break;
949
+ case "m":
950
+ date.setMinutes(this.getMinutes() + number);
951
+ break;
952
+ case "s":
953
+ date.setSeconds(this.getSeconds() + number);
954
+ break;
955
+ default:
956
+ date.setDate(this.getDate() + number);
957
+ break;
958
+ }
959
+ return date;
960
+ };
961
+ /* harmony default export */ var DateUtils = ({
962
+ lastMonthDay: new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1),
963
+ thisMonthDay: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
964
+ nextMonthDay: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1),
965
+ parseDate: function parseDate(str) {
966
+ if (typeof str == "string") {
967
+ var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
968
+ if (results && results.length > 3) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
969
+ results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
970
+ if (results && results.length > 6) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]));
971
+ results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
972
+ if (results && results.length > 7) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]), parseInt(results[7]));
973
+ }
974
+ return null;
975
+ },
976
+
977
+ /**
978
+ * 将时间间隔转换成中国话
979
+ *
980
+ * @param {*} startTime
981
+ * @param {*} endTime
982
+ * @returns {*}
983
+ */
984
+ formatDateInterval: function formatDateInterval(startTime, endTime) {
985
+ var dateCreateTime = new Date(startTime);
986
+ var dateFinishTime = new Date(endTime);
987
+ var dateInterval = dateFinishTime.getTime() - dateCreateTime.getTime();
988
+ var days = Math.floor(dateInterval / (24 * 3600 * 1000));
989
+ var leave1 = dateInterval % (24 * 3600 * 1000);
990
+ var hours = Math.floor(leave1 / (3600 * 1000));
991
+ var leave2 = leave1 % (3600 * 1000);
992
+ var minutes = Math.floor(leave2 / (60 * 1000));
993
+ var leave3 = leave2 % (60 * 1000);
994
+ var seconds = Math.round(leave3 / 1000);
995
+ var intervalDes = "";
996
+ if (days > 0) {
997
+ intervalDes += days + "天";
998
+ }
999
+ if (hours > 0) {
1000
+ intervalDes += hours + "时";
1001
+ }
1002
+ if (minutes > 0) {
1003
+ intervalDes += minutes + "分";
1004
+ }
1005
+ if (seconds > 0) {
1006
+ intervalDes += seconds + "秒";
1007
+ }
1008
+ if (days === 0 && hours === 0 && minutes === 0 && seconds === 0) {
1009
+ intervalDes = "少于1秒";
1010
+ }
1011
+ return intervalDes;
1012
+ },
1013
+ sleep: function sleep(d) {
1014
+ for (var t = Date.now(); Date.now() - t <= d;) {}
1015
+ }
1016
+ });
1017
+ // CONCATENATED MODULE: ./src/utils/DomUtils.js
1018
+ function trim(str) {
1019
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
1020
+ }
1021
+ function splitWords(str) {
1022
+ return trim(str).split(/\s+/);
1023
+ }
1024
+ /* harmony default export */ var DomUtils = ({
1025
+ getStyle: function getStyle(el, style) {
1026
+ var value = el.style[style] || el.currentStyle && el.currentStyle[style];
1027
+
1028
+ if ((!value || value === "auto") && document.defaultView) {
1029
+ var css = document.defaultView.getComputedStyle(el, null);
1030
+ value = css ? css[style] : null;
1031
+ }
1032
+ return value === "auto" ? null : value;
1033
+ },
1034
+ create: function create(tagName, className, container) {
1035
+ var el = document.createElement(tagName);
1036
+ el.className = className || "";
1037
+
1038
+ if (container) {
1039
+ container.appendChild(el);
1040
+ }
1041
+ return el;
1042
+ },
1043
+ remove: function remove(el) {
1044
+ var parent = el.parentNode;
1045
+ if (parent) {
1046
+ parent.removeChild(el);
1047
+ }
1048
+ },
1049
+ empty: function empty(el) {
1050
+ while (el.firstChild) {
1051
+ el.removeChild(el.firstChild);
1052
+ }
1053
+ },
1054
+ toFront: function toFront(el) {
1055
+ var parent = el.parentNode;
1056
+ if (parent && parent.lastChild !== el) {
1057
+ parent.appendChild(el);
1058
+ }
1059
+ },
1060
+ toBack: function toBack(el) {
1061
+ var parent = el.parentNode;
1062
+ if (parent && parent.firstChild !== el) {
1063
+ parent.insertBefore(el, parent.firstChild);
1064
+ }
1065
+ },
1066
+ getClass: function getClass(el) {
1067
+ if (el.correspondingElement) {
1068
+ el = el.correspondingElement;
1069
+ }
1070
+ return el.className.baseVal === undefined ? el.className : el.className.baseVal;
1071
+ },
1072
+ hasClass: function hasClass(el, name) {
1073
+ if (el.classList !== undefined) {
1074
+ return el.classList.contains(name);
1075
+ }
1076
+ var className = this.getClass(el);
1077
+ return className.length > 0 && new RegExp("(^|\\s)" + name + "(\\s|$)").test(className);
1078
+ },
1079
+ addClass: function addClass(el, name) {
1080
+ if (el.classList !== undefined) {
1081
+ var classes = splitWords(name);
1082
+ for (var i = 0, len = classes.length; i < len; i++) {
1083
+ el.classList.add(classes[i]);
1084
+ }
1085
+ } else if (!this.hasClass(el, name)) {
1086
+ var className = this.getClass(el);
1087
+ this.setClass(el, (className ? className + " " : "") + name);
1088
+ }
1089
+ },
1090
+ removeClass: function removeClass(el, name) {
1091
+ if (el.classList !== undefined) {
1092
+ var classes = splitWords(name);
1093
+ classes.forEach(function (name) {
1094
+ return el.classList.remove(name);
1095
+ });
1096
+ } else {
1097
+ this.setClass(el, trim((" " + this.getClass(el) + " ").replace(" " + name + " ", " ")));
1098
+ }
1099
+ },
1100
+ setClass: function setClass(el, name) {
1101
+ if (el.className.baseVal === undefined) {
1102
+ el.className = name;
1103
+ } else {
1104
+ // in case of SVG element
1105
+ el.className.baseVal = name;
1106
+ }
1107
+ }
1108
+ });
1109
+ // CONCATENATED MODULE: ./src/utils/GeoUtils.js
1110
+ /* harmony default export */ var GeoUtils = ({
1111
+ /**
1112
+ * 验证经纬度坐标
1113
+ *
1114
+ * @param {*} lng
1115
+ * @param {*} lat
1116
+ * @returns {*} {boolean}
1117
+ */
1118
+ isLnglat: function isLnglat(lng, lat) {
1119
+ return !!(+lat > 0 && +lat < 90 && +lng > 0 && +lng < 180);
1120
+ },
1121
+
1122
+ /**
1123
+ * 格式化经纬度(转度分秒)
1124
+ *
1125
+ * @param {*} lng
1126
+ * @param {*} lat
1127
+ * @returns {*}
1128
+ */
1129
+ formatLnglat: function formatLnglat(lng, lat) {
1130
+ var res = '';
1131
+ function format(value) {
1132
+ var a = parseFloat(value);
1133
+ var degree = parseInt(a);
1134
+ var min = parseInt((a - degree) * 60);
1135
+ if (min < 10) {
1136
+ min = '0' + min;
1137
+ }
1138
+ var sec = parseInt((a - degree) * 3600 - min * 60);
1139
+ if (sec < 10) {
1140
+ sec = '0' + sec;
1141
+ }
1142
+ return degree + '°' + min + '′' + sec + '″';
1143
+ }
1144
+ if (lng && lat) {
1145
+ res = format(lng) + ',' + format(lat);
1146
+ }
1147
+ return res;
1148
+ },
1149
+
1150
+ /**
1151
+ * 判断点是否在多边形内
1152
+ *
1153
+ * @param {*} p
1154
+ * @param {*} poly
1155
+ * @returns {*}
1156
+ */
1157
+ rayCasting: function rayCasting(p, poly) {
1158
+ var px = p.x,
1159
+ py = p.y,
1160
+ flag = false;
1161
+ for (var i = 0, l = poly.length, j = l - 1; i < l; j = i, i++) {
1162
+ var sx = poly[i].x,
1163
+ sy = poly[i].y,
1164
+ tx = poly[j].x,
1165
+ ty = poly[j].y;
1166
+ // 点与多边形顶点重合
1167
+ if (sx === px && sy === py || tx === px && ty === py) {
1168
+ return 'on';
1169
+ }
1170
+ // 判断线段两端点是否在射线两侧
1171
+ if (sy < py && ty >= py || sy >= py && ty < py) {
1172
+ // 线段上与射线 Y 坐标相同的点的 X 坐标
1173
+ var x = sx + (py - sy) * (tx - sx) / (ty - sy);
1174
+ // 点在多边形的边上
1175
+ if (x === px) {
1176
+ return 'on';
1177
+ }
1178
+ // 射线穿过多边形的边界
1179
+ if (x > px) {
1180
+ flag = !flag;
1181
+ }
1182
+ }
1183
+ }
1184
+ // 射线穿过多边形边界的次数为奇数时点在多边形内
1185
+ return flag ? 'in' : 'out';
1186
+ },
1187
+
1188
+ /**
1189
+ * 计算两点距离
1190
+ *
1191
+ * @param {*} fromPoint
1192
+ * @param {*} toPoint
1193
+ * @returns {*}
1194
+ */
1195
+ wgs84PointsDistance: function wgs84PointsDistance(fromPoint, toPoint) {
1196
+ var PI = Math.PI;
1197
+ function getRad(d) {
1198
+ return d * PI / 180.0;
1199
+ }
1200
+ if (arguments.length != 2) {
1201
+ return 0;
1202
+ }
1203
+ lon1 = fromPoint.x;
1204
+ lat1 = fromPoint.y;
1205
+ lon2 = toPoint.x;
1206
+ lat2 = toPoint.y;
1207
+ var a = 6378137,
1208
+ b = 6356752.3142,
1209
+ f = 1 / 298.257223563;
1210
+ var L = getRad(lon2 - lon1);
1211
+ var U1 = Math.atan((1 - f) * Math.tan(getRad(lat1)));
1212
+ var U2 = Math.atan((1 - f) * Math.tan(getRad(lat2)));
1213
+ var sinU1 = Math.sin(U1),
1214
+ cosU1 = Math.cos(U1);
1215
+ var sinU2 = Math.sin(U2),
1216
+ cosU2 = Math.cos(U2);
1217
+ var lambda = L,
1218
+ lambdaP,
1219
+ iterLimit = 100;
1220
+ do {
1221
+ var sinLambda = Math.sin(lambda),
1222
+ cosLambda = Math.cos(lambda);
1223
+ var sinSigma = Math.sqrt(cosU2 * sinLambda * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
1224
+ if (sinSigma == 0) return 0;
1225
+ var cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
1226
+ var sigma = Math.atan2(sinSigma, cosSigma);
1227
+ var sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
1228
+ var cosSqAlpha = 1 - sinAlpha * sinAlpha;
1229
+ var cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
1230
+ if (isNaN(cos2SigmaM)) cos2SigmaM = 0;
1231
+ var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
1232
+ lambdaP = lambda;
1233
+ lambda = L + (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
1234
+ } while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
1235
+ if (iterLimit == 0) {
1236
+ return NaN;
1237
+ }
1238
+ var uSq = cosSqAlpha * (a * a - b * b) / (b * b);
1239
+ var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
1240
+ var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
1241
+ var deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
1242
+ var s = b * A * (sigma - deltaSigma);
1243
+ var fwdAz = Math.atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
1244
+ var revAz = Math.atan2(cosU1 * sinLambda, -sinU1 * cosU2 + cosU1 * sinU2 * cosLambda);
1245
+ return s;
1246
+ }
1247
+ });
1248
+ // CONCATENATED MODULE: ./src/utils/FileUtils.js
1249
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1250
+
1251
+ /* harmony default export */ var FileUtils = ({
1252
+ /**
1253
+ * 将base64类型编码的图片转换成blob类型
1254
+ *
1255
+ * @param {*} data
1256
+ * @returns {*}
1257
+ */
1258
+ convertBase64ToBlob: function convertBase64ToBlob(data) {
1259
+ var mimeString = data.split(",")[0].split(":")[1].split(";")[0];
1260
+ var byteString = window.atob(data.split(",")[1]);
1261
+ var ab = new ArrayBuffer(byteString.length);
1262
+ var ia = new Uint8Array(ab);
1263
+
1264
+ for (var i = 0; i < byteString.length; i++) {
1265
+ ia[i] = byteString.charCodeAt(i);
1266
+ }
1267
+ var bb = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
1268
+
1269
+ if (bb) {
1270
+ bb = new (window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder)();
1271
+ bb.append(ab);
1272
+ return bb.getBlob(mimeString);
1273
+ } else {
1274
+ bb = new Blob([ab], {
1275
+ type: mimeString
1276
+ });
1277
+ return bb;
1278
+ }
1279
+ },
1280
+
1281
+ /**
1282
+ * 将url图片转换成base64编码的图片,也可用于图片压缩
1283
+ *
1284
+ * @param {*} url 需要转换的图片url
1285
+ * @param {*} width 指定宽高,如未指定则使用默认宽度
1286
+ * @param {*} height
1287
+ * @returns {*}
1288
+ */
1289
+ convertUrlToBase64: function convertUrlToBase64(url, width, height) {
1290
+ return new Promise(function (resolve, reject) {
1291
+ var img = new Image();
1292
+ img.crossOrigin = "Anonymous";
1293
+ img.src = url;
1294
+ img.onload = function () {
1295
+ var canvas = document.createElement("canvas");
1296
+ canvas.width = width || img.width;
1297
+ canvas.height = height || img.height;
1298
+ var ctx = canvas.getContext("2d");
1299
+ ctx.drawImage(img, 0, 0, img.width, img.height);
1300
+ var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
1301
+ var dataURL = canvas.toDataURL("image/" + ext);
1302
+ var base64 = {
1303
+ dataURL: dataURL,
1304
+ type: "image/" + ext,
1305
+ ext: ext
1306
+ };
1307
+ resolve(base64);
1308
+ };
1309
+ });
1310
+ },
1311
+
1312
+ /**
1313
+ * 将base64类型编码的图片转换成file类型
1314
+ *
1315
+ * @param {*} dataurl
1316
+ * @param {*} filename
1317
+ * @returns {*}
1318
+ */
1319
+ convertBase64ToFile: function convertBase64ToFile(dataurl, filename) {
1320
+ var arr = dataurl.split(","),
1321
+ mime = arr[0].match(/:(.*?);/)[1],
1322
+ bstr = atob(arr[1]),
1323
+ n = bstr.length,
1324
+ u8arr = new Uint8Array(n);
1325
+ while (n--) {
1326
+ u8arr[n] = bstr.charCodeAt(n);
1327
+ }
1328
+ var file = new File([u8arr], filename, { type: mime });
1329
+ return file;
1330
+ },
1331
+
1332
+ /**
1333
+ * 直接下载文件,支持blob类型和url类型
1334
+ *
1335
+ * @param {*} url
1336
+ * @param {*} saveName
1337
+ */
1338
+ downloadFromFile: function downloadFromFile(url, saveName) {
1339
+ if ((typeof url === "undefined" ? "undefined" : _typeof(url)) == "object" && url instanceof Blob) {
1340
+ url = URL.createObjectURL(url); // 创建blob地址
1341
+ }
1342
+ var link = document.createElement("a");
1343
+ link.href = url;
1344
+ link.download = saveName || ""; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
1345
+ link.click();
1346
+ window.URL.revokeObjectURL(link.href);
1347
+ }
1348
+ });
1349
+ // CONCATENATED MODULE: ./src/utils/MathUtils.js
1350
+ /* harmony default export */ var MathUtils = ({
1351
+ DEG2RAD: Math.PI / 180,
1352
+ RAD2DEG: 180 / Math.PI,
1353
+ randInt: function randInt(low, high) {
1354
+ return low + Math.floor(Math.random() * (high - low + 1));
1355
+ },
1356
+ randFloat: function randFloat(low, high) {
1357
+ return low + Math.random() * (high - low);
1358
+ },
1359
+
1360
+ /**
1361
+ * 角度转弧度
1362
+ *
1363
+ * @param {*} degrees
1364
+ * @returns {*}
1365
+ */
1366
+ degreesToRadians: function degreesToRadians(degrees) {
1367
+ return degrees * this.DEG2RAD;
1368
+ },
1369
+
1370
+ /**
1371
+ * 弧度转角度
1372
+ *
1373
+ * @param {*} radians
1374
+ * @returns {*}
1375
+ */
1376
+ radiansToDegrees: function radiansToDegrees(radians) {
1377
+ return radians * this.RAD2DEG;
1378
+ },
1379
+ formatFloat: function formatFloat(value) {
1380
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1381
+
1382
+ return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
1383
+ }
1384
+ });
1385
+ // CONCATENATED MODULE: ./src/utils/OptimizeUtils.js
1386
+ /* harmony default export */ var OptimizeUtils = ({
1387
+ /**
1388
+ * @desc 在事件被触发n秒后再执行回调函数,如果在这n秒内又被触发,则重新计时
1389
+ * @desc 防止onresize,scroll,mousemove ,mousehover等,会被频繁触发影响性能
1390
+ * @param func 需要执行的函数
1391
+ * @param wait 延迟执行时间(毫秒)
1392
+ * @param immediate---true 表立即执行,false 表非立即执行
1393
+ * eg: window.addEventListener("resize",debounce(handle,1000));
1394
+ * @returns {*}
1395
+ */
1396
+ debounce: function debounce(func, wait) {
1397
+ var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1398
+
1399
+ var timeout = void 0,
1400
+ args = void 0,
1401
+ context = void 0,
1402
+ timestamp = void 0,
1403
+ result = void 0;
1404
+
1405
+ var later = function later() {
1406
+ // 据上一次触发时间间隔
1407
+ var last = +new Date() - timestamp;
1408
+
1409
+ // 上次被包装函数被调用时间间隔last小于设定时间间隔wait
1410
+ if (last < wait && last > 0) {
1411
+ timeout = setTimeout(later, wait - last);
1412
+ } else {
1413
+ timeout = null;
1414
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
1415
+ if (!immediate) {
1416
+ result = func.apply(context, args);
1417
+ if (!timeout) context = args = null;
1418
+ }
1419
+ }
1420
+ };
1421
+
1422
+ return function () {
1423
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1424
+ args[_key] = arguments[_key];
1425
+ }
1426
+
1427
+ context = this;
1428
+ timestamp = +new Date();
1429
+ var callNow = immediate && !timeout;
1430
+ // 如果延时不存在,重新设定延时
1431
+ if (!timeout) timeout = setTimeout(later, wait);
1432
+ if (callNow) {
1433
+ result = func.apply(context, args);
1434
+ context = args = null;
1435
+ }
1436
+
1437
+ return result;
1438
+ };
1439
+ },
1440
+
1441
+ /**
1442
+ * 规定一个单位时间,在这个单位时间内,只能有一次触发事件的回调函数执行,如果在同一个单位时间内某事件被触发多次,只有一次能生效
1443
+ *
1444
+ * @param {*} func
1445
+ * @param {*} wait
1446
+ * @param {*} type 1 表时间戳版,2 表定时器版
1447
+ * @returns {*}
1448
+ */
1449
+ throttle: function throttle(func, wait, type) {
1450
+ if (type === 1) {
1451
+ var _previous = 0;
1452
+ } else if (type === 2) {
1453
+ var _timeout = void 0;
1454
+ }
1455
+ return function () {
1456
+ var context = this;
1457
+ var args = arguments;
1458
+ if (type === 1) {
1459
+ var now = Date.now();
1460
+ if (now - previous > wait) {
1461
+ func.apply(context, args);
1462
+ previous = now;
1463
+ }
1464
+ } else if (type === 2) {
1465
+ if (!timeout) {
1466
+ timeout = setTimeout(function () {
1467
+ timeout = null;
1468
+ func.apply(context, args);
1469
+ }, wait);
1470
+ }
1471
+ }
1472
+ };
1473
+ },
1474
+
1475
+ /**
1476
+ * 延时递归
1477
+ *
1478
+ * @param {Number} frequency 间隔时间ms
1479
+ * @param {Number} duration 持续时间ms
1480
+ */
1481
+ recurve: function recurve(fun) {
1482
+ var frequency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
1483
+ var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5000;
1484
+
1485
+ var timer = 0;
1486
+ setTimeout(function fn() {
1487
+ timer++;
1488
+ if (timer < Math.floor(duration / frequency)) {
1489
+ fun.call(this);
1490
+ setTimeout(fn, frequency);
1491
+ }
1492
+ });
1493
+ }
1494
+ });
1495
+ // CONCATENATED MODULE: ./src/utils/StringUtils.js
1496
+
1497
+ /* harmony default export */ var StringUtils = ({
1498
+ /**
1499
+ * 常用正则验证
1500
+ *
1501
+ * @param {*} str
1502
+ * @param {*} type
1503
+ * @returns {*}
1504
+ */
1505
+ checkStr: function checkStr(str, type) {
1506
+ switch (type) {
1507
+ case 'phone':
1508
+ // 手机号码
1509
+ return (/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str)
1510
+ );
1511
+ case 'tel':
1512
+ // 座机
1513
+ return (/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str)
1514
+ );
1515
+ case 'card':
1516
+ // 身份证
1517
+ return (/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str)
1518
+ );
1519
+ case 'pwd':
1520
+ // 密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线
1521
+ return (/^[a-zA-Z]\w{5,17}$/.test(str)
1522
+ );
1523
+ case 'postal':
1524
+ // 邮政编码
1525
+ return (/[1-9]\d{5}(?!\d)/.test(str)
1526
+ );
1527
+ case 'QQ':
1528
+ // QQ号
1529
+ return (/^[1-9][0-9]{4,9}$/.test(str)
1530
+ );
1531
+ case 'email':
1532
+ // 邮箱
1533
+ return (/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(str)
1534
+ );
1535
+ case 'money':
1536
+ // 金额(小数点2位)
1537
+ return (/^\d*(?:\.\d{0,2})?$/.test(str)
1538
+ );
1539
+ case 'URL':
1540
+ // 网址
1541
+ return (/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str)
1542
+ );
1543
+ case 'IP':
1544
+ // IP
1545
+ return (/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str)
1546
+ );
1547
+ case 'date':
1548
+ // 日期时间
1549
+ return (/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(str)
1550
+ );
1551
+ case 'number':
1552
+ // 数字
1553
+ return (/^[0-9]$/.test(str)
1554
+ );
1555
+ case 'english':
1556
+ // 英文
1557
+ return (/^[a-zA-Z]+$/.test(str)
1558
+ );
1559
+ case 'chinese':
1560
+ // 中文
1561
+ return (/^[\u4E00-\u9FA5]+$/.test(str)
1562
+ );
1563
+ case 'lower':
1564
+ // 小写
1565
+ return (/^[a-z]+$/.test(str)
1566
+ );
1567
+ case 'upper':
1568
+ // 大写
1569
+ return (/^[A-Z]+$/.test(str)
1570
+ );
1571
+ case 'HTML':
1572
+ // HTML标记
1573
+ return (/<("[^"]*"|'[^']*'|[^'">])*>/.test(str)
1574
+ );
1575
+ default:
1576
+ return true;
1577
+ }
1578
+ },
1579
+
1580
+ /**
1581
+ * 字符串大小写转换 type: 1:首字母大写 2:首页母小写 3:大小写转换 4:全部大写 5:全部小写
1582
+ *
1583
+ * @param {*} str
1584
+ * @param {*} type
1585
+ * @returns {*}
1586
+ */
1587
+ changeCase: function changeCase(str, type) {
1588
+ type = type || 4;
1589
+ switch (type) {
1590
+ case 1:
1591
+ return str.replace(/\b\w+\b/g, function (word) {
1592
+ return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();
1593
+ });
1594
+ case 2:
1595
+ return str.replace(/\b\w+\b/g, function (word) {
1596
+ return word.substring(0, 1).toLowerCase() + word.substring(1).toUpperCase();
1597
+ });
1598
+ case 3:
1599
+ return str.split('').map(function (word) {
1600
+ if (/[a-z]/.test(word)) {
1601
+ return word.toUpperCase();
1602
+ } else {
1603
+ return word.toLowerCase();
1604
+ }
1605
+ }).join('');
1606
+ case 4:
1607
+ return str.toUpperCase();
1608
+ case 5:
1609
+ return str.toLowerCase();
1610
+ default:
1611
+ return str;
1612
+ }
1613
+ },
1614
+ tag: function tag(strArray) {
1615
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1616
+ args[_key - 1] = arguments[_key];
1617
+ }
1618
+
1619
+ args = args.map(function (val) {
1620
+ switch (CommUtils.getDataType(val)) {
1621
+ case 'Object':
1622
+ return val || '{}';
1623
+ case 'Array':
1624
+ return val || '[]';
1625
+ default:
1626
+ return val || '';
1627
+ }
1628
+ });
1629
+ return strArray.reduce(function (prev, next, index) {
1630
+ return '' + prev + args[index - 1] + next;
1631
+ });
1632
+ }
1633
+ });
1634
+ // CONCATENATED MODULE: ./src/utils/index.js
1635
+
1636
+
1637
+
1638
+
1639
+
1640
+
1641
+
1642
+
1643
+
1644
+
1645
+
1646
+
1647
+
1648
+ // CONCATENATED MODULE: ./src/core/AudioPlayer.js
1649
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1650
+
1651
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1652
+
1653
+ /**
1654
+ * @description 声音播放类
1655
+ * @export
1656
+ * @class AudioPlayer
1657
+ */
1658
+ var AudioPlayer = function () {
1659
+ /**
1660
+ * Creates an instance of AudioPlayer.
1661
+ * @param {*} url
1662
+ */
1663
+ function AudioPlayer(url) {
1664
+ _classCallCheck(this, AudioPlayer);
1665
+
1666
+ this.audio = new Audio();
1667
+ this.audio.src = url;
1668
+ }
1669
+
1670
+ _createClass(AudioPlayer, [{
1671
+ key: "play",
1672
+ value: function play() {
1673
+ !this.muted && this.audio.play();
1674
+ }
1675
+ }, {
1676
+ key: "pause",
1677
+ value: function pause() {
1678
+ this.audio.pause();
1679
+ }
1680
+ }, {
1681
+ key: "muted",
1682
+ get: function get() {
1683
+ return this.audio.muted;
1684
+ }
1685
+ /**
1686
+ * @description 设置静音状态,如果静音,autoplay属性将失效
1687
+ */
1688
+ ,
1689
+ set: function set(val) {
1690
+ this.audio.muted = val;
1691
+ }
1692
+ }]);
1693
+
1694
+ return AudioPlayer;
1695
+ }();
1696
+
1697
+ /* harmony default export */ var core_AudioPlayer = (AudioPlayer);
1698
+ // CONCATENATED MODULE: ./src/core/CanvasDrawer.js
1699
+ var CanvasDrawer_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1700
+
1701
+ function CanvasDrawer_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1702
+
1703
+
1704
+
1705
+
1706
+ var CanvasDrawer_CanvasDrawer = function () {
1707
+ function CanvasDrawer(el) {
1708
+ CanvasDrawer_classCallCheck(this, CanvasDrawer);
1709
+
1710
+ if (CommUtils.getDataType(el) === 'String') {
1711
+ el = document.querySelector('#' + el);
1712
+ }
1713
+ this.ctx = el.getContext('2d');
1714
+ }
1715
+
1716
+ CanvasDrawer_createClass(CanvasDrawer, [{
1717
+ key: 'drawLine',
1718
+ value: function drawLine(startX, startY, endX, endY) {
1719
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1720
+
1721
+ this.cxt.beginPath();
1722
+ var width = options.width || 1;
1723
+ var color = options.color || '#000';
1724
+ this.cxt.lineWidth = width;
1725
+ this.cxt.fillStyle = color; // 经过测试不管是fillStyle还是StrokeStyle都是一样的
1726
+ this.cxt.moveTo(startX, startY);
1727
+ this.cxt.lineTo(endX, endY);
1728
+ this.cxt.closePath();
1729
+ this.cxt.fill();
1730
+ }
1731
+ /**
1732
+ * 绘制圆弧
1733
+ * @param {*} x 圆心X坐标
1734
+ * @param {*} y 圆心Y坐标
1735
+ * @param {*} radius 半径
1736
+ * @param {*} startAngle 开始的弧度
1737
+ * @param {*} endAngle 结束的弧度
1738
+ * @param {*} anticlockwise true为逆时针,false为顺时针
1739
+ * @param {boolean} isOnlyArc
1740
+ * @param {boolean} isFill 是否是填充,false为绘制边框,true为绘制填充
1741
+ * @param {*} bgColor 圆弧的颜色
1742
+ * @memberof CanvasDrawer
1743
+ */
1744
+
1745
+ }, {
1746
+ key: 'drawArc',
1747
+ value: function drawArc(x, y, radius, startAngle, endAngle, anticlockwise, isFill, bgColor) {
1748
+ if (isFill) {
1749
+ //为true绘制填充圆弧
1750
+ this.cxt.fillStyle = bgColor;
1751
+ this.cxt.beginPath();
1752
+ this.cxt.arc(x, y, radius, MathUtils.degreesToRadians(startAngle), MathUtils.degreesToRadians(endAngle), anticlockwise);
1753
+ this.cxt.closePath();
1754
+ this.cxt.fill();
1755
+ } else {
1756
+ //为false绘制边框圆弧
1757
+ this.cxt.strokeStyle = bgColor;
1758
+ this.cxt.beginPath();
1759
+ this.cxt.arc(x, y, radius, MathUtils.degreesToRadians(startAngle), MathUtils.degreesToRadians(endAngle), anticlockwise);
1760
+
1761
+ this.cxt.stroke();
1762
+ }
1763
+ }
1764
+ }]);
1765
+
1766
+ return CanvasDrawer;
1767
+ }();
1768
+
1769
+ /* harmony default export */ var core_CanvasDrawer = (CanvasDrawer_CanvasDrawer);
1770
+ // CONCATENATED MODULE: ./src/core/ElQuery.js
1771
+ var ElQuery_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1772
+
1773
+ var ElQuery_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1774
+
1775
+ function ElQuery_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1776
+
1777
+ var ElQuery = function () {
1778
+ function ElQuery(selector) {
1779
+ var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
1780
+
1781
+ ElQuery_classCallCheck(this, ElQuery);
1782
+
1783
+ if (typeof selector == 'string') {
1784
+ if (selector.charAt(0) == '<' && selector.slice(-1) == '>') {
1785
+ var ele = selector.slice(1, -1);
1786
+ this[0] = document.createElement(ele);
1787
+ this.length = 1;
1788
+ } else {
1789
+ var all = el.querySelectorAll(selector);
1790
+ for (var i = 0; i < all.length; i++) {
1791
+ this[i] = all[i];
1792
+ }
1793
+ this.length = all.length;
1794
+ }
1795
+ } else if (typeof selector == 'undefined') {
1796
+ return this;
1797
+ } else if (typeof selector == 'function') {
1798
+ this.ready(selector);
1799
+ } else if (selector.nodeType == 1) {
1800
+ this[0] = selector;
1801
+ this.length = 1;
1802
+ }
1803
+ }
1804
+
1805
+ ElQuery_createClass(ElQuery, [{
1806
+ key: 'each',
1807
+ value: function each(callback) {
1808
+ for (var i = 0; i < this.length; i++) {
1809
+ callback(this[i], i);
1810
+ }
1811
+ }
1812
+ }, {
1813
+ key: 'html',
1814
+ value: function html(val) {
1815
+ this.each(function (obj) {
1816
+ obj.innerHTML = val;
1817
+ });
1818
+ return this;
1819
+ }
1820
+ }, {
1821
+ key: 'css',
1822
+ value: function css(attr, val) {
1823
+ this.each(function (obj) {
1824
+ if ((typeof attr === 'undefined' ? 'undefined' : ElQuery_typeof(attr)) == 'object') {
1825
+ for (var i in attr) {
1826
+ if (i == 'width' || i == 'height' || i == 'margin' || i == 'fontSize') {
1827
+ obj.style[i] = parseInt(attr[i]) + 'px';
1828
+ }
1829
+ obj.style[i] = attr[i];
1830
+ }
1831
+ } else {
1832
+ obj.style[attr] = val;
1833
+ }
1834
+ });
1835
+ return this;
1836
+ }
1837
+ }, {
1838
+ key: 'ready',
1839
+ value: function ready(callback) {
1840
+ var _this = this;
1841
+
1842
+ document.addEventListener('DOMContentLoaded', function (e) {
1843
+ callback.call(_this, e);
1844
+ });
1845
+ }
1846
+ }, {
1847
+ key: 'click',
1848
+ value: function click(callback) {
1849
+ this.each(function (obj) {
1850
+ var _this2 = this;
1851
+
1852
+ obj.onclick = function (e) {
1853
+ callback.call(_this2, e, obj);
1854
+ };
1855
+ });
1856
+ return this;
1857
+ }
1858
+ }, {
1859
+ key: 'on',
1860
+ value: function on(type, callback) {
1861
+ var _this3 = this;
1862
+
1863
+ this.each(function (obj) {
1864
+ obj.addEventListener(type, function (e) {
1865
+ callback.call(_this3, e);
1866
+ });
1867
+ });
1868
+ }
1869
+ }, {
1870
+ key: 'appendTo',
1871
+ value: function appendTo(dom) {
1872
+ if (typeof dom == 'string') {
1873
+ var all = document.querySelectorAll(dom);
1874
+ var ele = this[0];
1875
+ for (var i = 0; i < all.length; i++) {
1876
+ this[i] = ele.cloneNode(true);
1877
+ all[i].appendChild(this[i]);
1878
+ this.length = all.length;
1879
+ }
1880
+ } else {
1881
+ dom.appendChild(this[0]);
1882
+ }
1883
+ return this;
1884
+ }
1885
+ }]);
1886
+
1887
+ return ElQuery;
1888
+ }();
1889
+
1890
+ /* harmony default export */ var core_ElQuery = (ElQuery);
1891
+
1892
+ window.$ = function (selector, el) {
1893
+ return new ElQuery(selector, el);
1894
+ };
1895
+ // CONCATENATED MODULE: ./src/core/EventDispatcher.js
1896
+ function EventDispatcher() {}
1897
+
1898
+ Object.assign(EventDispatcher.prototype, {
1899
+ /**
1900
+ * 添加监听器
1901
+ * @param type{string}
1902
+ * @param listener{function}
1903
+ * @param mutexStatus{boolean}
1904
+ */
1905
+ addEventListener: function addEventListener(type, listener, context) {
1906
+ var mutexStatus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1907
+
1908
+ if (this._listeners === undefined) this._listeners = {};
1909
+ this._mutex = this._mutex || {};
1910
+ this._context = context;
1911
+ var mutex = this._mutex;
1912
+ var listeners = this._listeners;
1913
+
1914
+ if (listeners[type] === undefined) {
1915
+ listeners[type] = [];
1916
+ }
1917
+
1918
+ if (listeners[type].indexOf(listener) === -1) {
1919
+ // 如果启用功能独占
1920
+ if (mutexStatus) {
1921
+ mutex[type] = listener;
1922
+ }
1923
+ listeners[type].push(listener);
1924
+ }
1925
+ return this;
1926
+ },
1927
+ hasEventListener: function hasEventListener(type, listener) {
1928
+ if (this._listeners === undefined) return false;
1929
+
1930
+ var listeners = this._listeners;
1931
+
1932
+ return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
1933
+ },
1934
+ removeEventListener: function removeEventListener(type, listener) {
1935
+ if (this._listeners === undefined) return;
1936
+
1937
+ var listeners = this._listeners;
1938
+ var listenerArray = listeners[type];
1939
+
1940
+ // 移除指定的功能独占
1941
+ if (this._mutex[type] === listener) {
1942
+ this._mutex[type] = null;
1943
+ }
1944
+
1945
+ if (listenerArray !== undefined) {
1946
+ var index = listenerArray.indexOf(listener);
1947
+
1948
+ if (index !== -1) {
1949
+ listenerArray.splice(index, 1);
1950
+ }
1951
+ }
1952
+ },
1953
+
1954
+
1955
+ /**
1956
+ * 派发事件
1957
+ * @param event{{type: string, message: {}}}
1958
+ */
1959
+ dispatchEvent: function dispatchEvent(event) {
1960
+ var _this = this;
1961
+
1962
+ if (this._listeners === undefined) return;
1963
+
1964
+ var listeners = this._listeners;
1965
+ var listenerArray = listeners[event.type];
1966
+
1967
+ if (listenerArray !== undefined) {
1968
+ event.target = this;
1969
+
1970
+ // Make a copy, in case listeners are removed while iterating.
1971
+ var array = listenerArray.slice(0);
1972
+ if (this._mutex[event.type]) {
1973
+ var find = array.find(function (item) {
1974
+ return item === _this._mutex[event.type];
1975
+ });
1976
+ find.call(this._context || this, event);
1977
+ return;
1978
+ }
1979
+ for (var i = 0, l = array.length; i < l; i++) {
1980
+ array[i].call(this._context || this, event);
1981
+ }
1982
+ }
1983
+ },
1984
+ removeAllListener: function removeAllListener() {
1985
+ this._mutex = {};
1986
+ for (var key in this._listeners) {
1987
+ this._listeners[key] = [];
1988
+ }
1989
+ }
1990
+ });
1991
+
1992
+ /* harmony default export */ var core_EventDispatcher = (EventDispatcher);
1993
+ // CONCATENATED MODULE: ./src/core/HashMap.js
1994
+ var HashMap_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1995
+
1996
+ function HashMap_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1997
+
1998
+ var HashMap = function () {
1999
+ function HashMap() {
2000
+ HashMap_classCallCheck(this, HashMap);
2001
+
2002
+ this.elements = [];
2003
+ return new Map();
2004
+ }
2005
+
2006
+ HashMap_createClass(HashMap, [{
2007
+ key: "set",
2008
+ value: function set(key, value) {
2009
+ Map.prototype.set.call(this, key, value);
2010
+ this.elements.push({ key: key, value: value });
2011
+ }
2012
+ }, {
2013
+ key: "delete",
2014
+ value: function _delete(key) {
2015
+ Map.prototype.delete.call(this, key);
2016
+ this.elements = this.elements.filter(function (d) {
2017
+ return d.key !== key;
2018
+ });
2019
+ }
2020
+ }, {
2021
+ key: "isEmpty",
2022
+ value: function isEmpty() {
2023
+ return this.size === 0;
2024
+ }
2025
+ }, {
2026
+ key: "clear",
2027
+ value: function clear() {
2028
+ Map.prototype.clear.call(this);
2029
+ this.elements = [];
2030
+ }
2031
+ /**
2032
+ * 通过数组创建Map对象
2033
+ *
2034
+ * @static
2035
+ * @param {*} array
2036
+ */
2037
+
2038
+ }], [{
2039
+ key: "fromEntries",
2040
+ value: function fromEntries() {
2041
+ var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2042
+
2043
+ var hashMap = new HashMap();
2044
+ array.forEach(function (element) {
2045
+ if (Array.isArray(element) && element.length === 2) {
2046
+ hashMap.set(element[0], element[1]);
2047
+ }
2048
+ });
2049
+ return hashMap;
2050
+ }
2051
+ }]);
2052
+
2053
+ return HashMap;
2054
+ }();
2055
+
2056
+ /* harmony default export */ var core_HashMap = (HashMap);
2057
+ // EXTERNAL MODULE: external "mqtt"
2058
+ var external_mqtt_ = __webpack_require__(0);
2059
+
2060
+ // CONCATENATED MODULE: ./src/core/MqttClient.js
2061
+ var MqttClient_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2062
+
2063
+ function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2064
+
2065
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2066
+
2067
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2068
+
2069
+
2070
+
2071
+
2072
+
2073
+
2074
+
2075
+ var MqttClient_MqttClient = function (_EventDispatcher) {
2076
+ _inherits(MqttClient, _EventDispatcher);
2077
+
2078
+ /**
2079
+ * Creates an instance of MqttClient.
2080
+ * @param {*} config mqtt实例参数
2081
+ */
2082
+ function MqttClient() {
2083
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2084
+
2085
+ MqttClient_classCallCheck(this, MqttClient);
2086
+
2087
+ var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
2088
+
2089
+ _this.context = CommUtils.extend(MqttClient.defaultContext, config);
2090
+ _this.options = {
2091
+ connectTimeout: _this.context.MQTT_TIMEOUTM,
2092
+ clientId: CommUtils.generateGuid(),
2093
+ username: _this.context.MQTT_USERNAME,
2094
+ password: _this.context.MQTT_PASSWORD,
2095
+ clean: true
2096
+ };
2097
+ _this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
2098
+ _this._onConnect();
2099
+ _this._onMessage();
2100
+ MqttClient.instance = _this;
2101
+ return _this;
2102
+ }
2103
+
2104
+ MqttClient_createClass(MqttClient, [{
2105
+ key: "_onConnect",
2106
+ value: function _onConnect() {
2107
+ var _this2 = this;
2108
+
2109
+ this.client.on("connect", function () {
2110
+ console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
2111
+ _this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
2112
+ });
2113
+ this.client.on("error", function (err) {
2114
+ console.log("链接mqtt报错", err);
2115
+ _this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
2116
+ _this2.client.end();
2117
+ _this2.client.reconnect();
2118
+ });
2119
+ }
2120
+ }, {
2121
+ key: "_onMessage",
2122
+ value: function _onMessage() {
2123
+ var _this3 = this;
2124
+
2125
+ this.client.on("message", function (topic, message) {
2126
+ var dataString = message;
2127
+ var data = "";
2128
+ if (message instanceof Uint8Array) {
2129
+ dataString = message.toString();
2130
+ }
2131
+ try {
2132
+ data = JSON.parse(dataString);
2133
+ } catch (error) {
2134
+ throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
2135
+ }
2136
+ _this3.dispatchEvent({
2137
+ type: EventTypeConstant.MQTT_MESSAGE,
2138
+ message: { topic: topic, data: data }
2139
+ });
2140
+ });
2141
+ }
2142
+ }, {
2143
+ key: "sendMsg",
2144
+ value: function sendMsg(topic, msg) {
2145
+ if (!this.client.connected) {
2146
+ console.error("客户端未连接");
2147
+ return;
2148
+ }
2149
+ this.client.publish(topic, msg, { qos: 1, retain: true });
2150
+ }
2151
+ }, {
2152
+ key: "subscribe",
2153
+ value: function subscribe(topic) {
2154
+ this.client.subscribe(topic, { qos: 1 }, function (error, res) {
2155
+ if (error instanceof Error || res.length === 0) {
2156
+ console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2157
+ } else {
2158
+ console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
2159
+ }
2160
+ });
2161
+ return this;
2162
+ }
2163
+ }, {
2164
+ key: "unsubscribe",
2165
+ value: function unsubscribe(topic) {
2166
+ this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
2167
+ if (error instanceof Error || res.length === 0) {
2168
+ console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2169
+ } else {
2170
+ console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
2171
+ }
2172
+ });
2173
+ return this;
2174
+ }
2175
+ }, {
2176
+ key: "unconnect",
2177
+ value: function unconnect() {
2178
+ this.client.end();
2179
+ this.client = null;
2180
+ this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
2181
+ console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
2182
+ }
2183
+ /**
2184
+ * @description 获取并冻结mqtt实例
2185
+ * @static
2186
+ * @param {*} [config={}]
2187
+ * @returns {MqttClient}
2188
+ */
2189
+
2190
+ }], [{
2191
+ key: "getInstance",
2192
+ value: function getInstance() {
2193
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2194
+
2195
+ if (MqttClient.instance) {
2196
+ return Object.freeze(MqttClient.instance);
2197
+ } else {
2198
+ return Object.freeze(new MqttClient(config));
2199
+ }
2200
+ }
2201
+ }]);
2202
+
2203
+ return MqttClient;
2204
+ }(core_EventDispatcher);
2205
+
2206
+ /* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
2207
+
2208
+ MqttClient_MqttClient.defaultContext = {
2209
+ MQTT_TIMEOUTM: 20000,
2210
+ MQTT_USERNAME: "iRVMS-WEB",
2211
+ MQTT_PASSWORD: "novasky888",
2212
+ MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
2213
+ };
2214
+ // CONCATENATED MODULE: ./src/core/WebSocketClient.js
2215
+ var WebSocketClient_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2216
+
2217
+ function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2218
+
2219
+ function WebSocketClient_possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2220
+
2221
+ function WebSocketClient_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2222
+
2223
+
2224
+
2225
+
2226
+ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2227
+ WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
2228
+
2229
+ function WebSocketClient() {
2230
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://127.0.0.1:10088";
2231
+
2232
+ WebSocketClient_classCallCheck(this, WebSocketClient);
2233
+
2234
+ var _this = WebSocketClient_possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2235
+
2236
+ _this.maxCheckTimes = 10;
2237
+ _this.url = url;
2238
+ _this.checkTimes = 0;
2239
+ _this.connectStatus = false;
2240
+ _this.connect();
2241
+ _this.connCheckStatus(_this.maxCheckTimes);
2242
+ // this.heartbeat()
2243
+ WebSocketClient.instance = _this;
2244
+ return _this;
2245
+ }
2246
+
2247
+ WebSocketClient_createClass(WebSocketClient, [{
2248
+ key: "connect",
2249
+ value: function connect() {
2250
+ var _this2 = this;
2251
+
2252
+ this.checkTimes++;
2253
+ this.disconnect();
2254
+ if (this.url) {
2255
+ try {
2256
+ console.info("创建ws连接" + this.url);
2257
+ this.client = new WebSocket(this.url);
2258
+ if (this.client) {
2259
+ // 当连接成功或连接失败达到最大重连次数的一半时
2260
+ if (!this.connectStatus && this.checkTimes === Math.floor(this.maxCheckTimes / 2) || this.connectStatus) {
2261
+ this.client.onopen = function (message) {
2262
+ _this2.dispatchEvent({
2263
+ type: EventTypeConstant.WEB_SOCKET_CONNECT,
2264
+ message: message
2265
+ });
2266
+ };
2267
+ this.client.onmessage = function (message) {
2268
+ _this2.connectStatus = true;
2269
+ _this2.dispatchEvent({
2270
+ type: EventTypeConstant.WEB_SOCKET_MESSAGE,
2271
+ message: message
2272
+ });
2273
+ };
2274
+ this.client.onclose = function (message) {
2275
+ _this2.dispatchEvent({
2276
+ type: EventTypeConstant.WEB_SOCKET_CLOSE,
2277
+ message: message
2278
+ });
2279
+ };
2280
+ this.client.onerror = function (message) {
2281
+ _this2.dispatchEvent({
2282
+ type: EventTypeConstant.WEB_SOCKET_ERROR,
2283
+ message: message
2284
+ });
2285
+ };
2286
+ }
2287
+ }
2288
+ } catch (ex) {
2289
+ console.error("创建ws连接失败" + this.url + ":" + ex);
2290
+ }
2291
+ }
2292
+ }
2293
+ }, {
2294
+ key: "disconnect",
2295
+ value: function disconnect() {
2296
+ if (this.client) {
2297
+ try {
2298
+ console.log("ws断开连接" + this.url);
2299
+ this.client.close();
2300
+ this.client = null;
2301
+ } catch (ex) {
2302
+ this.client = null;
2303
+ }
2304
+ }
2305
+ }
2306
+ }, {
2307
+ key: "connCheckStatus",
2308
+ value: function connCheckStatus(times) {
2309
+ var _this3 = this;
2310
+
2311
+ if (this.checkTimes > times) return;
2312
+ setTimeout(function () {
2313
+ if (_this3.client && _this3.client.readyState !== 0 && _this3.client.readyState !== 1) {
2314
+ _this3.connect();
2315
+ }
2316
+ _this3.connCheckStatus(times);
2317
+ }, 2000);
2318
+ }
2319
+ }, {
2320
+ key: "send",
2321
+ value: function send(message) {
2322
+ if (this.client && this.client.readyState === 1) {
2323
+ this.client.send(message);
2324
+ return true;
2325
+ }
2326
+ console.error(this.url + "消息发送失败:" + message);
2327
+ return false;
2328
+ }
2329
+ }, {
2330
+ key: "heartbeat",
2331
+ value: function heartbeat() {
2332
+ var _this4 = this;
2333
+
2334
+ setTimeout(function () {
2335
+ if (_this4.client && _this4.client.readyState === 1) {
2336
+ _this4.send("HeartBeat");
2337
+ }
2338
+ console.log("HeartBeat," + _this4.url);
2339
+ setTimeout(_this4.heartbeat, 30000);
2340
+ }, 1000);
2341
+ }
2342
+ }], [{
2343
+ key: "getInstance",
2344
+ value: function getInstance() {
2345
+ if (WebSocketClient.instance) {
2346
+ return WebSocketClient.instance;
2347
+ } else {
2348
+ return Object.freeze(new WebSocketClient());
2349
+ }
2350
+ }
2351
+ }, {
2352
+ key: "_instance",
2353
+ get: function get() {
2354
+ return this.getInstance();
2355
+ }
2356
+ }]);
2357
+
2358
+ return WebSocketClient;
2359
+ }(core_EventDispatcher);
2360
+
2361
+ /* harmony default export */ var core_WebSocketClient = (WebSocketClient_WebSocketClient);
2362
+ // CONCATENATED MODULE: ./src/core/WebStorage.js
2363
+ var WebStorage_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2364
+
2365
+ function WebStorage_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2366
+
2367
+
2368
+
2369
+ var WebStorage_WebStorage = function () {
2370
+ function WebStorage() {
2371
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2372
+
2373
+ WebStorage_classCallCheck(this, WebStorage);
2374
+
2375
+ this.cacheType = type;
2376
+ if (type === 1) {
2377
+ this.storage = window.localStorage;
2378
+ } else if (type === 2) {
2379
+ this.storage = window.sessionStorage;
2380
+ } else {
2381
+ throw new Error(ErrorTypeConstant.PARAMETER_ERROR);
2382
+ }
2383
+ }
2384
+
2385
+ /**
2386
+ * 设置带过期时间的LocalStorage
2387
+ * @param key 缓存关键字
2388
+ * @param value 缓存对象,可以是任意类型
2389
+ * @param expired 以秒为单位,默认为1小时
2390
+ * @returns {Object}
2391
+ */
2392
+
2393
+
2394
+ WebStorage_createClass(WebStorage, [{
2395
+ key: "setItem",
2396
+ value: function setItem(key, value, expired) {
2397
+ var tempObj = { key: key, value: value };
2398
+ if (this.cacheType === 1) {
2399
+ var currTime = Date.now();
2400
+ if (expired) {
2401
+ tempObj.expired = currTime + expired * 1000;
2402
+ }
2403
+ }
2404
+ this.storage[key] = JSON.stringify(tempObj);
2405
+ return tempObj;
2406
+ }
2407
+
2408
+ /***
2409
+ * 获取带过期时间的缓存
2410
+ * @param key
2411
+ * @returns {null|*}
2412
+ */
2413
+
2414
+ }, {
2415
+ key: "getItem",
2416
+ value: function getItem(key) {
2417
+ var storageData = this.storage.getItem(key) || null;
2418
+ var tempObj = JSON.parse(storageData) || {};
2419
+ if (this.cacheType === 1) {
2420
+ var expired = tempObj.expired || Date.now();
2421
+ if (Date.now() > expired) {
2422
+ this.remove(key);
2423
+ return null;
2424
+ }
2425
+ }
2426
+ return tempObj.value;
2427
+ }
2428
+
2429
+ /**
2430
+ * 移除指定缓存
2431
+ * @param keys
2432
+ */
2433
+
2434
+ }, {
2435
+ key: "remove",
2436
+ value: function remove(keys) {
2437
+ var _this = this;
2438
+
2439
+ if (keys) {
2440
+ if (keys.indexOf(",") > -1) {
2441
+ keys.split(",").forEach(function (key) {
2442
+ _this.storage.removeItem(key);
2443
+ });
2444
+ } else {
2445
+ this.storage.removeItem(keys);
2446
+ }
2447
+ }
2448
+ }
2449
+
2450
+ /**
2451
+ * 移出全部缓存
2452
+ */
2453
+
2454
+ }, {
2455
+ key: "clear",
2456
+ value: function clear() {
2457
+ this.storage.clear();
2458
+ }
2459
+ }]);
2460
+
2461
+ return WebStorage;
2462
+ }();
2463
+
2464
+ /* harmony default export */ var core_WebStorage = (WebStorage_WebStorage);
2465
+ // CONCATENATED MODULE: ./src/index.js
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+
2473
+
2474
+
2475
+
2476
+
2477
+ /***/ })
2478
+ /******/ ]);
2479
+ });