gis-common 3.1.4 → 3.1.6
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.
- package/dist/core/AudioPlayer.d.ts +20 -0
- package/dist/gis-common.es.js +1183 -1380
- package/dist/gis-common.umd.js +1 -1
- package/package.json +4 -4
package/dist/gis-common.es.js
CHANGED
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var G = Object.defineProperty;
|
|
2
|
+
var z = (t, e, n) => e in t ? G(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var P = (t, e, n) => z(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const Y = {
|
|
5
|
+
/**
|
|
6
|
+
* 多属性的动画函数
|
|
7
|
+
* @param {*} ele 需要运动的节点
|
|
8
|
+
* @param {*} attr_options 传入的是一个需要运动的属性包括运动的目标值,操作的节点属性
|
|
9
|
+
* @param {*} timefn 运动的形式,默认是缓冲运动
|
|
10
|
+
* @param {*} speed 运动的速度
|
|
11
|
+
*/
|
|
12
|
+
animate(t, e, n, r = "swing", a = 5) {
|
|
13
|
+
for (var s in e)
|
|
14
|
+
e[s] = {
|
|
15
|
+
target: s === "opacity" ? parseInt(e[s] * 100) : e[s],
|
|
16
|
+
// 需要计算得到
|
|
17
|
+
iNow: parseInt(s === "opacity" ? getComputedStyle(t)[s] * 100 : getComputedStyle(t)[s])
|
|
7
18
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
speed = (target - iNow) / 20;
|
|
19
|
-
speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
|
|
20
|
-
}
|
|
21
|
-
if (Math.abs(target - iNow) <= Math.abs(speed)) {
|
|
22
|
-
if (attr2 === "opacity") {
|
|
23
|
-
ele.style[attr2] = target / 100;
|
|
24
|
-
} else {
|
|
25
|
-
ele.style[attr2] = target + "px";
|
|
26
|
-
}
|
|
27
|
-
delete attr_options[attr2];
|
|
28
|
-
for (var num in attr_options) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
clearInterval(ele.timer);
|
|
32
|
-
typeof callback === "function" ? callback() : "";
|
|
33
|
-
} else {
|
|
34
|
-
attr_options[attr2].iNow += speed;
|
|
35
|
-
if (attr2 === "opacity") {
|
|
36
|
-
ele.style[attr2] = attr_options[attr2].iNow / 100;
|
|
37
|
-
} else {
|
|
38
|
-
ele.style[attr2] = attr_options[attr2].iNow + "px";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
19
|
+
r === "liner" && (a = e[s].iNow < e[s].target ? Math.abs(a) : -Math.abs(a)), clearInterval(t.timer), t.timer = setInterval(function() {
|
|
20
|
+
for (var i in e) {
|
|
21
|
+
var o = e[i].target, c = e[i].iNow;
|
|
22
|
+
if (r === "swing" && (a = (o - c) / 20, a = a > 0 ? Math.ceil(a) : Math.floor(a)), Math.abs(o - c) <= Math.abs(a)) {
|
|
23
|
+
i === "opacity" ? t.style[i] = o / 100 : t.style[i] = o + "px", delete e[i];
|
|
24
|
+
for (var l in e)
|
|
25
|
+
return !1;
|
|
26
|
+
clearInterval(t.timer), typeof n == "function" && n();
|
|
27
|
+
} else
|
|
28
|
+
e[i].iNow += a, i === "opacity" ? t.style[i] = e[i].iNow / 100 : t.style[i] = e[i].iNow + "px";
|
|
41
29
|
}
|
|
42
30
|
}, 30);
|
|
43
31
|
}
|
|
44
|
-
}
|
|
45
|
-
var EventType = {
|
|
32
|
+
}, v = {
|
|
46
33
|
MAP_RENDER: "mapRender",
|
|
47
34
|
MAP_READY: "mapReady",
|
|
48
35
|
MOUSE_CLICK: "click",
|
|
@@ -64,39 +51,42 @@ var EventType = {
|
|
|
64
51
|
WEB_SOCKET_ERROR: "webSocketError",
|
|
65
52
|
WEB_SOCKET_MESSAGE: "webSocketMessage",
|
|
66
53
|
WEB_SOCKET_CLOSE: "webSocketClose"
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
var LayerType = {
|
|
54
|
+
}, m = {
|
|
55
|
+
LOGIN_EXPIRED: "登录信息过期,请重新登录",
|
|
56
|
+
CROSS_ERROR: "跨域访问",
|
|
57
|
+
UNEXIST_RESOURCE: "资源不存在",
|
|
58
|
+
TIMEOUT: "请求超时",
|
|
59
|
+
INTERNAL_ERROR: "内部错误",
|
|
60
|
+
NETWORK_ERROR: "请求失败,请检查网络是否已连接",
|
|
61
|
+
PROCESS_FAIL: "处理失败",
|
|
62
|
+
AUTH_VERIFY_ERROR: "权限验证失败",
|
|
63
|
+
NO_DATA_FOUND: "未找到数据",
|
|
64
|
+
DUPLICATE_INSTANCE: "实例为单例模式,不允许重复构建",
|
|
65
|
+
COORDINATE_ERROR: "坐标验证失败",
|
|
66
|
+
JSON_PARSE_ERROR: "JSON解析失败,格式有误",
|
|
67
|
+
JSON_VALUE_ERROR: "JSON无此键",
|
|
68
|
+
PARAMETER_ERROR: "验证数据类型失败",
|
|
69
|
+
PARAMETER_ERROR_ARRAY: "格式类型验证失败:必须是数组",
|
|
70
|
+
PARAMETER_ERROR_STRING: "格式类型验证失败:必须是字符",
|
|
71
|
+
PARAMETER_ERROR_FUNCTION: "格式类型验证失败:必须是函数",
|
|
72
|
+
PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
|
|
73
|
+
PARAMETER_ERROR_LACK: "参数缺失",
|
|
74
|
+
STRING_CHECK_LOSS: "字符缺少关键字"
|
|
75
|
+
}, K = {
|
|
91
76
|
SUPER_MAP_IMAGES: "SuperMapImages",
|
|
77
|
+
// 超图影像服务 栅格数据
|
|
92
78
|
SUPER_MAP_DATA: "SuperMapData",
|
|
79
|
+
// 超图服务 矢量数据
|
|
93
80
|
ARC_GIS_MAP_IMAGES: "ArcGisMapImages",
|
|
81
|
+
// arcGis影像图层 栅格数据
|
|
94
82
|
ARC_GIS_MAP_DATA: "ArcGisMapData",
|
|
83
|
+
// arcGis图层 矢量数据
|
|
95
84
|
OSGB_LAYER: "OSGBLayer",
|
|
96
85
|
S3M_GROUP: "S3MGroup",
|
|
86
|
+
// addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
97
87
|
TERRAIN_LAYER: "TerrainFileLayer"
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
// 地形图层, 需要单独处理
|
|
89
|
+
}, J = {
|
|
100
90
|
POINT: "point",
|
|
101
91
|
POLYLINE: "polyline",
|
|
102
92
|
POLYGON: "polygon",
|
|
@@ -106,216 +96,199 @@ const GraphicType = {
|
|
|
106
96
|
LABEL: "label",
|
|
107
97
|
MODEL: "model",
|
|
108
98
|
WALL: "wall"
|
|
109
|
-
}
|
|
110
|
-
const MeasureMode = {
|
|
99
|
+
}, V = {
|
|
111
100
|
DISTANCE: "distance",
|
|
112
101
|
AREA: "area",
|
|
113
102
|
HEIGHT: "height"
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
}, E = {
|
|
104
|
+
/**
|
|
105
|
+
* 判断数据类型
|
|
106
|
+
*
|
|
107
|
+
* @param {*} data
|
|
108
|
+
* @returns {*}
|
|
109
|
+
*/
|
|
110
|
+
getDataType(t) {
|
|
111
|
+
return Object.prototype.toString.call(t).slice(8, -1);
|
|
112
|
+
},
|
|
113
|
+
isEmpty(t) {
|
|
114
|
+
if (t == null)
|
|
115
|
+
return !0;
|
|
116
|
+
switch (this.getDataType(t)) {
|
|
125
117
|
case "String":
|
|
126
|
-
return
|
|
118
|
+
return t.trim() === "";
|
|
127
119
|
case "Array":
|
|
128
|
-
return !
|
|
120
|
+
return !t.length;
|
|
129
121
|
case "Object":
|
|
130
|
-
return !Object.keys(
|
|
122
|
+
return !Object.keys(t).length;
|
|
131
123
|
case "Boolean":
|
|
132
|
-
return !
|
|
124
|
+
return !t;
|
|
133
125
|
default:
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
isNotEmpty(
|
|
138
|
-
return !this.isEmpty(
|
|
139
|
-
},
|
|
140
|
-
json2form(
|
|
141
|
-
const
|
|
142
|
-
Object.keys(
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var
|
|
155
|
-
|
|
126
|
+
return !1;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
isNotEmpty(t) {
|
|
130
|
+
return !this.isEmpty(t);
|
|
131
|
+
},
|
|
132
|
+
json2form(t) {
|
|
133
|
+
const e = new FormData();
|
|
134
|
+
return Object.keys(t).forEach((n) => {
|
|
135
|
+
e.append(n, t[n] instanceof Object ? JSON.stringify(t[n]) : t[n]);
|
|
136
|
+
}), e;
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* json转换成get参数形式
|
|
140
|
+
*
|
|
141
|
+
* @param {*} json
|
|
142
|
+
* @returns {*}
|
|
143
|
+
*/
|
|
144
|
+
json2Query(t) {
|
|
145
|
+
var e = [];
|
|
146
|
+
for (var n in t) {
|
|
147
|
+
var r = n, a = t[n];
|
|
148
|
+
e.push(r + "=" + a);
|
|
149
|
+
}
|
|
150
|
+
var s = e.join("&");
|
|
151
|
+
return s;
|
|
156
152
|
},
|
|
157
153
|
generateGuid() {
|
|
158
|
-
const
|
|
154
|
+
const t = function() {
|
|
159
155
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
160
156
|
};
|
|
161
|
-
return
|
|
162
|
-
},
|
|
163
|
-
decodeDict(...
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
for (let
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
res = items[i + 1];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (!res && args.length % 2 === 0) {
|
|
174
|
-
res = args[args.length - 1];
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
res = args[0];
|
|
178
|
-
}
|
|
179
|
-
return res;
|
|
180
|
-
},
|
|
181
|
-
extend(dest, ...args) {
|
|
182
|
-
let i, j, len, src;
|
|
183
|
-
for (j = 0, len = args.length; j < len; j++) {
|
|
184
|
-
src = args[j];
|
|
185
|
-
for (i in src) {
|
|
186
|
-
dest[i] = src[i];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return dest;
|
|
190
|
-
},
|
|
191
|
-
rgb2hex(rgb) {
|
|
192
|
-
var hex = "#" + ((1 << 24) + (rgb[0] << 16) + (rgb[1] << 8) + rgb[2]).toString(16).slice(1);
|
|
193
|
-
return hex;
|
|
194
|
-
},
|
|
195
|
-
convertToTree2(data, idPropertyName = "id", parentIdPropertyName = "parentId", childrenPropertyName = "children") {
|
|
196
|
-
const result = [];
|
|
197
|
-
function buildChildren(item) {
|
|
198
|
-
const id = item[idPropertyName];
|
|
199
|
-
const children = data.filter((item2) => item2.hasOwnProperty(parentIdPropertyName) && item2[parentIdPropertyName] === id);
|
|
200
|
-
if (children.length > 0) {
|
|
201
|
-
children.forEach(buildChildren);
|
|
202
|
-
item[childrenPropertyName] = children;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
for (const item of data) {
|
|
206
|
-
if (data.findIndex((t) => t[idPropertyName] === item[parentIdPropertyName]) === -1) {
|
|
207
|
-
buildChildren(item);
|
|
208
|
-
result.push(item);
|
|
157
|
+
return t() + t() + t() + t() + t() + t() + t() + t();
|
|
158
|
+
},
|
|
159
|
+
decodeDict(...t) {
|
|
160
|
+
let e = "";
|
|
161
|
+
if (t.length > 1) {
|
|
162
|
+
const n = t.slice(1, t.length % 2 === 0 ? t.length - 1 : t.length);
|
|
163
|
+
for (let r = 0; r < n.length; r = r + 2) {
|
|
164
|
+
const a = n[r];
|
|
165
|
+
t[0] === a && (e = n[r + 1]);
|
|
209
166
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
167
|
+
!e && t.length % 2 === 0 && (e = t[t.length - 1]);
|
|
168
|
+
} else
|
|
169
|
+
e = t[0];
|
|
170
|
+
return e;
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @param {*} dest
|
|
175
|
+
* @param {...any} args
|
|
176
|
+
* @returns 等同于L.extend
|
|
177
|
+
*/
|
|
178
|
+
extend(t, ...e) {
|
|
179
|
+
let n, r, a, s;
|
|
180
|
+
for (r = 0, a = e.length; r < a; r++) {
|
|
181
|
+
s = e[r];
|
|
182
|
+
for (n in s)
|
|
183
|
+
t[n] = s[n];
|
|
184
|
+
}
|
|
185
|
+
return t;
|
|
186
|
+
},
|
|
187
|
+
rgb2hex(t) {
|
|
188
|
+
var e = "#" + (16777216 + (t[0] << 16) + (t[1] << 8) + t[2]).toString(16).slice(1);
|
|
189
|
+
return e;
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* 将平级对象列表转换为树形结构对象列表
|
|
193
|
+
*
|
|
194
|
+
* @param {Array} data
|
|
195
|
+
* @param {string} [idPropertyName="id"]
|
|
196
|
+
* @param {string} [parentIdPropertyName="parentId"]
|
|
197
|
+
* @param {string} [childrenPropertyName="children"]
|
|
198
|
+
* @returns {*}
|
|
199
|
+
*/
|
|
200
|
+
convertToTree2(t, e = "id", n = "parentId", r = "children") {
|
|
201
|
+
const a = [];
|
|
202
|
+
function s(i) {
|
|
203
|
+
const o = i[e], c = t.filter((l) => l.hasOwnProperty(n) && l[n] === o);
|
|
204
|
+
c.length > 0 && (c.forEach(s), i[r] = c);
|
|
205
|
+
}
|
|
206
|
+
for (const i of t)
|
|
207
|
+
t.findIndex((o) => o[e] === i[n]) === -1 && (s(i), a.push(i));
|
|
208
|
+
return a;
|
|
209
|
+
},
|
|
210
|
+
/**
|
|
211
|
+
* 异步加载script
|
|
212
|
+
*
|
|
213
|
+
* @param {*} url
|
|
214
|
+
*/
|
|
215
|
+
asyncLoadScript(t) {
|
|
216
|
+
return new Promise((e, n) => {
|
|
215
217
|
try {
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
oscript.onload = function() {
|
|
225
|
-
resolve(oscript);
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
oscript.type = "text/javascript";
|
|
229
|
-
oscript.src = url;
|
|
230
|
-
document.body.appendChild(oscript);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
reject(error);
|
|
218
|
+
var r = document.createElement("script");
|
|
219
|
+
r.readyState ? r.onreadystatechange = function() {
|
|
220
|
+
(r.readyState === "complete" || r.readyState === "loaded") && e(r);
|
|
221
|
+
} : r.onload = function() {
|
|
222
|
+
e(r);
|
|
223
|
+
}, r.type = "text/javascript", r.src = t, document.body.appendChild(r);
|
|
224
|
+
} catch (a) {
|
|
225
|
+
n(a);
|
|
233
226
|
}
|
|
234
227
|
});
|
|
235
228
|
},
|
|
236
|
-
loadStyle(
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
css.rel = "stylesheet";
|
|
241
|
-
css.type = "text/css";
|
|
242
|
-
document.head.appendChild(css);
|
|
229
|
+
loadStyle(t) {
|
|
230
|
+
t.forEach((e) => {
|
|
231
|
+
const n = document.createElement("link");
|
|
232
|
+
n.href = e, n.rel = "stylesheet", n.type = "text/css", document.head.appendChild(n);
|
|
243
233
|
});
|
|
244
234
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
235
|
+
/**
|
|
236
|
+
* 提取json中的value组成一个新的字符串
|
|
237
|
+
* eg: template('aaa{key}', json)
|
|
238
|
+
*
|
|
239
|
+
* @param {*} str
|
|
240
|
+
* @param {*} data
|
|
241
|
+
* @returns {*}
|
|
242
|
+
*/
|
|
243
|
+
template(t, e) {
|
|
244
|
+
const n = /\{ *([\w_-]+) *\}/g;
|
|
245
|
+
return t.replace(n, function(r, a) {
|
|
246
|
+
var s = e[a];
|
|
247
|
+
if (s === void 0)
|
|
248
|
+
throw new Error(m.JSON_VALUE_ERROR + r);
|
|
249
|
+
return typeof s == "function" && (s = s(e)), s;
|
|
255
250
|
});
|
|
256
251
|
},
|
|
257
|
-
deleteEmptyProperty(
|
|
252
|
+
deleteEmptyProperty(t) {
|
|
258
253
|
return Object.fromEntries(
|
|
259
|
-
Object.keys(
|
|
254
|
+
Object.keys(t).filter((e) => !this.isEmpty(t[e])).map((e) => [e, t[e]])
|
|
260
255
|
);
|
|
261
256
|
},
|
|
262
257
|
deepAssign() {
|
|
263
|
-
let
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return target;
|
|
283
|
-
},
|
|
284
|
-
handleCopyValue(text) {
|
|
285
|
-
if (!navigator.clipboard && window.isSecureContext) {
|
|
286
|
-
return navigator.clipboard.writeText(text);
|
|
287
|
-
} else {
|
|
288
|
-
const textArea = document.createElement("textarea");
|
|
289
|
-
textArea.style.position = "fixed";
|
|
290
|
-
textArea.style.top = textArea.style.left = "-100vh";
|
|
291
|
-
textArea.style.opacity = "0";
|
|
292
|
-
textArea.value = text;
|
|
293
|
-
document.body.appendChild(textArea);
|
|
294
|
-
textArea.focus();
|
|
295
|
-
textArea.select();
|
|
296
|
-
return new Promise((resolve, reject) => {
|
|
297
|
-
document.execCommand("copy") ? resolve() : reject(new Error("copy failed"));
|
|
298
|
-
textArea.remove();
|
|
258
|
+
let t = arguments.length, e = arguments[0];
|
|
259
|
+
this.getDataType(e) !== "Object" && (e = {});
|
|
260
|
+
for (let n = 1; n < t; n++) {
|
|
261
|
+
let r = arguments[n];
|
|
262
|
+
if (this.getDataType(r) === "Object")
|
|
263
|
+
for (let a in r)
|
|
264
|
+
a === "__proto__" || e === r[a] || (this.getDataType(r[a]) === "Object" ? e[a] = this.deepAssign(e[a], r[a]) : e[a] = r[a]);
|
|
265
|
+
}
|
|
266
|
+
return e;
|
|
267
|
+
},
|
|
268
|
+
handleCopyValue(t) {
|
|
269
|
+
if (!navigator.clipboard && window.isSecureContext)
|
|
270
|
+
return navigator.clipboard.writeText(t);
|
|
271
|
+
{
|
|
272
|
+
const e = document.createElement("textarea");
|
|
273
|
+
return e.style.position = "fixed", e.style.top = e.style.left = "-100vh", e.style.opacity = "0", e.value = t, document.body.appendChild(e), e.focus(), e.select(), new Promise((n, r) => {
|
|
274
|
+
document.execCommand("copy") ? n() : r(new Error("copy failed")), e.remove();
|
|
299
275
|
});
|
|
300
276
|
}
|
|
301
277
|
}
|
|
302
278
|
};
|
|
303
|
-
Array.prototype.groupBy = function(
|
|
304
|
-
var
|
|
305
|
-
this.forEach(function(
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
return Object.keys(groups).map((group) => groups[group]);
|
|
279
|
+
Array.prototype.groupBy = function(t) {
|
|
280
|
+
var e = {};
|
|
281
|
+
return this.forEach(function(n) {
|
|
282
|
+
var r = JSON.stringify(t(n));
|
|
283
|
+
e[r] = e[r] || [], e[r].push(n);
|
|
284
|
+
}), Object.keys(e).map((n) => e[n]);
|
|
311
285
|
};
|
|
312
|
-
Array.prototype.distinct = function(
|
|
313
|
-
const
|
|
314
|
-
this.forEach((
|
|
315
|
-
const
|
|
316
|
-
!
|
|
317
|
-
});
|
|
318
|
-
return arr;
|
|
286
|
+
Array.prototype.distinct = function(t = (e) => e) {
|
|
287
|
+
const e = [], n = {};
|
|
288
|
+
return this.forEach((r) => {
|
|
289
|
+
const a = t(r);
|
|
290
|
+
!n[a] && (n[a] = e.push(r));
|
|
291
|
+
}), e;
|
|
319
292
|
};
|
|
320
293
|
Array.prototype.max = function() {
|
|
321
294
|
return Math.max.apply({}, this);
|
|
@@ -324,1083 +297,954 @@ Array.prototype.min = function() {
|
|
|
324
297
|
return Math.min.apply({}, this);
|
|
325
298
|
};
|
|
326
299
|
Array.prototype.sum = function() {
|
|
327
|
-
return this.length > 0 ? this.reduce((
|
|
300
|
+
return this.length > 0 ? this.reduce((t = 0, e = 0) => t + e) : 0;
|
|
328
301
|
};
|
|
329
302
|
Array.prototype.avg = function() {
|
|
330
303
|
return this.length ? this.sum() / this.length : 0;
|
|
331
304
|
};
|
|
332
|
-
Array.prototype.desc = function(
|
|
333
|
-
return this.sort((
|
|
305
|
+
Array.prototype.desc = function(t = (e) => e) {
|
|
306
|
+
return this.sort((e, n) => t(n) - t(e));
|
|
334
307
|
};
|
|
335
|
-
Array.prototype.asc = function(
|
|
336
|
-
return this.sort((
|
|
308
|
+
Array.prototype.asc = function(t = (e) => e) {
|
|
309
|
+
return this.sort((e, n) => t(e) - t(n));
|
|
337
310
|
};
|
|
338
311
|
Array.prototype.clear = function() {
|
|
339
|
-
this.length = 0;
|
|
340
|
-
return this;
|
|
312
|
+
return this.length = 0, this;
|
|
341
313
|
};
|
|
342
|
-
|
|
343
|
-
asArray(
|
|
344
|
-
return
|
|
345
|
-
},
|
|
346
|
-
generateArray(
|
|
347
|
-
return [...new Array(
|
|
348
|
-
},
|
|
349
|
-
union(...
|
|
350
|
-
let
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return
|
|
366
|
-
},
|
|
367
|
-
unionAll(...args) {
|
|
368
|
-
return [...args].flat().filter((d) => !!d);
|
|
369
|
-
},
|
|
370
|
-
difference(...args) {
|
|
371
|
-
return this.union(...args).filter((d) => !this.intersection(...args).includes(d));
|
|
314
|
+
const Q = {
|
|
315
|
+
asArray(t) {
|
|
316
|
+
return E.isEmpty(t) ? [] : Array.isArray(t) ? t : [t];
|
|
317
|
+
},
|
|
318
|
+
generateArray(t) {
|
|
319
|
+
return [...new Array(t).keys()];
|
|
320
|
+
},
|
|
321
|
+
union(...t) {
|
|
322
|
+
let e = [];
|
|
323
|
+
return t.forEach((n) => {
|
|
324
|
+
Array.isArray(n) && (e = e.concat(n.filter((r) => !e.includes(r))));
|
|
325
|
+
}), e;
|
|
326
|
+
},
|
|
327
|
+
intersection(...t) {
|
|
328
|
+
let e = t[0] || [];
|
|
329
|
+
return t.forEach((n) => {
|
|
330
|
+
Array.isArray(n) && (e = e.filter((r) => n.includes(r)));
|
|
331
|
+
}), e;
|
|
332
|
+
},
|
|
333
|
+
unionAll(...t) {
|
|
334
|
+
return [...t].flat().filter((e) => !!e);
|
|
335
|
+
},
|
|
336
|
+
difference(...t) {
|
|
337
|
+
return this.union(...t).filter((e) => !this.intersection(...t).includes(e));
|
|
372
338
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
for (let i2 = 1; i2 < arr.length; i2++) {
|
|
387
|
-
let res;
|
|
388
|
-
while (res = reg.exec(arr[i2])) {
|
|
389
|
-
obj[res[1]] = needDecode ? decodeURIComponent(res[2]) : res[2];
|
|
390
|
-
}
|
|
339
|
+
}, X = {
|
|
340
|
+
getUrlParams(t = window.location.href, e = !0) {
|
|
341
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: r, hash: a } = new URL(t), s = [r, a];
|
|
342
|
+
let i = {};
|
|
343
|
+
for (let o = 0; o < s.length; o++) {
|
|
344
|
+
const c = s[o];
|
|
345
|
+
if (c) {
|
|
346
|
+
const h = c.replace(/#|\//g, "").split("?");
|
|
347
|
+
if (h.length > 1)
|
|
348
|
+
for (let u = 1; u < h.length; u++) {
|
|
349
|
+
let d;
|
|
350
|
+
for (; d = n.exec(h[u]); )
|
|
351
|
+
i[d[1]] = e ? decodeURIComponent(d[2]) : d[2];
|
|
391
352
|
}
|
|
392
|
-
}
|
|
393
353
|
}
|
|
394
354
|
}
|
|
395
|
-
return
|
|
355
|
+
return i;
|
|
396
356
|
},
|
|
397
357
|
getExplorer() {
|
|
398
|
-
var
|
|
399
|
-
if (
|
|
358
|
+
var t = window.navigator.userAgent;
|
|
359
|
+
if (t.indexOf("MSIE") >= 0 || window.ActiveXObject || "ActiveXObject" in window)
|
|
400
360
|
return "IE";
|
|
401
|
-
|
|
402
|
-
if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
|
403
|
-
return "IE";
|
|
404
|
-
} else if (explorer.indexOf("Firefox") >= 0) {
|
|
361
|
+
if (t.indexOf("Firefox") >= 0)
|
|
405
362
|
return "Firefox";
|
|
406
|
-
|
|
363
|
+
if (t.indexOf("Chrome") >= 0)
|
|
407
364
|
return "Chrome";
|
|
408
|
-
|
|
365
|
+
if (t.indexOf("Opera") >= 0)
|
|
409
366
|
return "Opera";
|
|
410
|
-
|
|
367
|
+
if (t.indexOf("Safari") >= 0)
|
|
411
368
|
return "Safari";
|
|
412
|
-
}
|
|
413
369
|
},
|
|
414
370
|
detectOS() {
|
|
415
|
-
let
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
},
|
|
430
|
-
switchFullScreen(status) {
|
|
431
|
-
if (status) {
|
|
432
|
-
const element = document.documentElement;
|
|
433
|
-
if (element.requestFullscreen) {
|
|
434
|
-
element.requestFullscreen();
|
|
435
|
-
} else if (element.msRequestFullscreen) {
|
|
436
|
-
element.msRequestFullscreen();
|
|
437
|
-
} else if (element.mozRequestFullScreen) {
|
|
438
|
-
element.mozRequestFullScreen();
|
|
439
|
-
} else if (element.webkitRequestFullscreen) {
|
|
440
|
-
element.webkitRequestFullscreen();
|
|
441
|
-
}
|
|
442
|
-
} else {
|
|
443
|
-
if (document.exitFullscreen) {
|
|
444
|
-
document.exitFullscreen();
|
|
445
|
-
} else if (document.msExitFullscreen) {
|
|
446
|
-
document.msExitFullscreen();
|
|
447
|
-
} else if (document.mozCancelFullScreen) {
|
|
448
|
-
document.mozCancelFullScreen();
|
|
449
|
-
} else if (document.webkitExitFullscreen) {
|
|
450
|
-
document.webkitExitFullscreen();
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
},
|
|
371
|
+
let t = "";
|
|
372
|
+
const e = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0, r = navigator.userAgent.indexOf("Linux", 0) != -1 ? 1 : 0, a = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
|
|
373
|
+
return e ? t = "MS Windows" : n ? t = "Apple mac" : r ? t = "Linux" : a && (t = "Unix"), t;
|
|
374
|
+
},
|
|
375
|
+
switchFullScreen(t) {
|
|
376
|
+
if (t) {
|
|
377
|
+
const e = document.documentElement;
|
|
378
|
+
e.requestFullscreen ? e.requestFullscreen() : e.msRequestFullscreen ? e.msRequestFullscreen() : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen();
|
|
379
|
+
} else
|
|
380
|
+
document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen();
|
|
381
|
+
},
|
|
382
|
+
/**
|
|
383
|
+
* scale屏幕适配方案
|
|
384
|
+
*/
|
|
454
385
|
refreshScale() {
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const realRatio = baseWidth / baseHeight;
|
|
459
|
-
const designRatio = 16 / 9;
|
|
460
|
-
let scaleRate = baseWidth / 1920;
|
|
461
|
-
if (realRatio > designRatio) {
|
|
462
|
-
scaleRate = baseHeight / 1080;
|
|
463
|
-
}
|
|
464
|
-
appStyle.transformOrigin = "left top";
|
|
465
|
-
appStyle.transform = `scale(${scaleRate}) translateX(-49.99%)`;
|
|
466
|
-
appStyle.width = `${baseWidth / scaleRate}px`;
|
|
386
|
+
const t = document.documentElement.clientWidth, e = document.documentElement.clientHeight, n = document.getElementById("app").style, r = t / e, a = 16 / 9;
|
|
387
|
+
let s = t / 1920;
|
|
388
|
+
r > a && (s = e / 1080), n.transformOrigin = "left top", n.transform = `scale(${s}) translateX(-49.99%)`, n.width = `${t / s}px`;
|
|
467
389
|
},
|
|
390
|
+
/**
|
|
391
|
+
* rem屏幕适配方案
|
|
392
|
+
*/
|
|
468
393
|
getHtmlFontSize() {
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
htmlDom.style.fontSize = htmlwidth / 192 + "px";
|
|
394
|
+
const t = document.documentElement.clientWidth || document.body.clientWidth, e = document.querySelector("html");
|
|
395
|
+
e.style.fontSize = t / 192 + "px";
|
|
472
396
|
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
var
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
},
|
|
488
|
-
get: function(name) {
|
|
489
|
-
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
|
|
490
|
-
if (arr != null) {
|
|
491
|
-
return arr[2];
|
|
492
|
-
} else {
|
|
493
|
-
return "";
|
|
494
|
-
}
|
|
397
|
+
}, Z = {
|
|
398
|
+
set: function(t, e, n = 30) {
|
|
399
|
+
var r = /* @__PURE__ */ new Date();
|
|
400
|
+
r.setTime(r.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = t + "=" + escape(e) + ";expires=" + r.toUTCString();
|
|
401
|
+
},
|
|
402
|
+
remove: function(t) {
|
|
403
|
+
var e = /* @__PURE__ */ new Date();
|
|
404
|
+
e.setTime(e.getTime() - 1);
|
|
405
|
+
var n = this.get(t);
|
|
406
|
+
n != null && (document.cookie = t + "=" + n + ";expires=" + e.toUTCString());
|
|
407
|
+
},
|
|
408
|
+
get: function(t) {
|
|
409
|
+
var e = document.cookie.match(new RegExp("(^| )" + t + "=([^;]*)(;|$)"));
|
|
410
|
+
return e != null ? e[2] : "";
|
|
495
411
|
}
|
|
496
|
-
}
|
|
497
|
-
var CoordsUtils = {
|
|
412
|
+
}, tt = {
|
|
498
413
|
PI: 3.141592653589793,
|
|
499
414
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
500
|
-
delta(
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
let
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return
|
|
569
|
-
},
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
const gcjLon = z * Math.cos(theta);
|
|
576
|
-
const gcjLat = z * Math.sin(theta);
|
|
577
|
-
return { lat: gcjLat, lng: gcjLon };
|
|
578
|
-
},
|
|
579
|
-
mercatorEncrypt(wgsLat, wgsLon) {
|
|
580
|
-
const x = wgsLon * 2003750834e-2 / 180;
|
|
581
|
-
let y = Math.log(Math.tan((90 + wgsLat) * this.PI / 360)) / (this.PI / 180);
|
|
582
|
-
y = y * 2003750834e-2 / 180;
|
|
583
|
-
return { lat: y, lng: x };
|
|
584
|
-
},
|
|
585
|
-
mercatorDecrypt(mercatorLat, mercatorLon) {
|
|
586
|
-
const x = mercatorLon / 2003750834e-2 * 180;
|
|
587
|
-
let y = mercatorLat / 2003750834e-2 * 180;
|
|
588
|
-
y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180)) - this.PI / 2);
|
|
589
|
-
return { lat: y, lng: x };
|
|
590
|
-
},
|
|
591
|
-
distance(latA, lngA, latB, lngB) {
|
|
592
|
-
const earthR = 6371e3;
|
|
593
|
-
const x = Math.cos(latA * this.PI / 180) * Math.cos(latB * this.PI / 180) * Math.cos((lngA - lngB) * this.PI / 180);
|
|
594
|
-
const y = Math.sin(latA * this.PI / 180) * Math.sin(latB * this.PI / 180);
|
|
595
|
-
let s = x + y;
|
|
596
|
-
if (s > 1)
|
|
597
|
-
s = 1;
|
|
598
|
-
if (s < -1)
|
|
599
|
-
s = -1;
|
|
600
|
-
const alpha = Math.acos(s);
|
|
601
|
-
const distance = alpha * earthR;
|
|
602
|
-
return distance;
|
|
603
|
-
},
|
|
604
|
-
outOfChina(lat, lng) {
|
|
605
|
-
if (lng < 72.004 || lng > 137.8347) {
|
|
606
|
-
return true;
|
|
607
|
-
}
|
|
608
|
-
if (lat < 0.8293 || lat > 55.8271) {
|
|
609
|
-
return true;
|
|
610
|
-
}
|
|
611
|
-
return false;
|
|
612
|
-
},
|
|
613
|
-
transformLat(x, y) {
|
|
614
|
-
let ret = -100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
|
|
615
|
-
ret += (20 * Math.sin(6 * x * this.PI) + 20 * Math.sin(2 * x * this.PI)) * 2 / 3;
|
|
616
|
-
ret += (20 * Math.sin(y * this.PI) + 40 * Math.sin(y / 3 * this.PI)) * 2 / 3;
|
|
617
|
-
ret += (160 * Math.sin(y / 12 * this.PI) + 320 * Math.sin(y * this.PI / 30)) * 2 / 3;
|
|
618
|
-
return ret;
|
|
619
|
-
},
|
|
620
|
-
transformLon(x, y) {
|
|
621
|
-
let ret = 300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
|
|
622
|
-
ret += (20 * Math.sin(6 * x * this.PI) + 20 * Math.sin(2 * x * this.PI)) * 2 / 3;
|
|
623
|
-
ret += (20 * Math.sin(x * this.PI) + 40 * Math.sin(x / 3 * this.PI)) * 2 / 3;
|
|
624
|
-
ret += (150 * Math.sin(x / 12 * this.PI) + 300 * Math.sin(x / 30 * this.PI)) * 2 / 3;
|
|
625
|
-
return ret;
|
|
626
|
-
},
|
|
627
|
-
randomCoordinate(minX, minY, maxX, maxY) {
|
|
415
|
+
delta(t, e) {
|
|
416
|
+
const r = 0.006693421622965943;
|
|
417
|
+
let a = this.transformLat(e - 105, t - 35), s = this.transformLon(e - 105, t - 35);
|
|
418
|
+
const i = t / 180 * this.PI;
|
|
419
|
+
let o = Math.sin(i);
|
|
420
|
+
o = 1 - r * o * o;
|
|
421
|
+
const c = Math.sqrt(o);
|
|
422
|
+
return a = a * 180 / (6378245 * (1 - r) / (o * c) * this.PI), s = s * 180 / (6378245 / c * Math.cos(i) * this.PI), { lat: a, lng: s };
|
|
423
|
+
},
|
|
424
|
+
// WGS-84 to GCJ-02
|
|
425
|
+
gcjEncrypt(t, e) {
|
|
426
|
+
if (this.outOfChina(t, e))
|
|
427
|
+
return { lat: t, lng: e };
|
|
428
|
+
const n = this.delta(t, e);
|
|
429
|
+
return { lat: t + n.lat, lng: e + n.lng };
|
|
430
|
+
},
|
|
431
|
+
// GCJ-02 to WGS-84
|
|
432
|
+
gcjDecrypt(t, e) {
|
|
433
|
+
if (this.outOfChina(t, e))
|
|
434
|
+
return { lat: t, lng: e };
|
|
435
|
+
const n = this.delta(t, e);
|
|
436
|
+
return { lat: t - n.lat, lng: e - n.lng };
|
|
437
|
+
},
|
|
438
|
+
// GCJ-02 to WGS-84 exactly
|
|
439
|
+
gcjDecryptExact(t, e) {
|
|
440
|
+
let a = 0.01, s = 0.01, i = t - a, o = e - s, c = t + a, l = e + s, h, u, d = 0;
|
|
441
|
+
for (; ; ) {
|
|
442
|
+
h = (i + c) / 2, u = (o + l) / 2;
|
|
443
|
+
const f = this.gcj_encrypt(h, u);
|
|
444
|
+
if (a = f.lat - t, s = f.lng - e, Math.abs(a) < 1e-9 && Math.abs(s) < 1e-9 || (a > 0 ? c = h : i = h, s > 0 ? l = u : o = u, ++d > 1e4)) break;
|
|
445
|
+
}
|
|
446
|
+
return { lat: h, lng: u };
|
|
447
|
+
},
|
|
448
|
+
// GCJ-02 to BD-09
|
|
449
|
+
bdEncrypt(t, e) {
|
|
450
|
+
const n = e, r = t, a = Math.sqrt(n * n + r * r) + 2e-5 * Math.sin(r * this.XPI), s = Math.atan2(r, n) + 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(s) + 65e-4;
|
|
451
|
+
return { lat: a * Math.sin(s) + 6e-3, lng: i };
|
|
452
|
+
},
|
|
453
|
+
// BD-09 to GCJ-02
|
|
454
|
+
bdDecrypt(t, e) {
|
|
455
|
+
const n = e - 65e-4, r = t - 6e-3, a = Math.sqrt(n * n + r * r) - 2e-5 * Math.sin(r * this.XPI), s = Math.atan2(r, n) - 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(s);
|
|
456
|
+
return { lat: a * Math.sin(s), lng: i };
|
|
457
|
+
},
|
|
458
|
+
// WGS-84 to Web mercator
|
|
459
|
+
// mercatorLat -> y mercatorLon -> x
|
|
460
|
+
mercatorEncrypt(t, e) {
|
|
461
|
+
const n = e * 2003750834e-2 / 180;
|
|
462
|
+
let r = Math.log(Math.tan((90 + t) * this.PI / 360)) / (this.PI / 180);
|
|
463
|
+
return r = r * 2003750834e-2 / 180, { lat: r, lng: n };
|
|
464
|
+
},
|
|
465
|
+
// Web mercator to WGS-84
|
|
466
|
+
// mercatorLat -> y mercatorLon -> x
|
|
467
|
+
mercatorDecrypt(t, e) {
|
|
468
|
+
const n = e / 2003750834e-2 * 180;
|
|
469
|
+
let r = t / 2003750834e-2 * 180;
|
|
470
|
+
return r = 180 / this.PI * (2 * Math.atan(Math.exp(r * this.PI / 180)) - this.PI / 2), { lat: r, lng: n };
|
|
471
|
+
},
|
|
472
|
+
// two point's distance
|
|
473
|
+
distance(t, e, n, r) {
|
|
474
|
+
const s = Math.cos(t * this.PI / 180) * Math.cos(n * this.PI / 180) * Math.cos((e - r) * this.PI / 180), i = Math.sin(t * this.PI / 180) * Math.sin(n * this.PI / 180);
|
|
475
|
+
let o = s + i;
|
|
476
|
+
return o > 1 && (o = 1), o < -1 && (o = -1), Math.acos(o) * 6371e3;
|
|
477
|
+
},
|
|
478
|
+
outOfChina(t, e) {
|
|
479
|
+
return e < 72.004 || e > 137.8347 || t < 0.8293 || t > 55.8271;
|
|
480
|
+
},
|
|
481
|
+
transformLat(t, e) {
|
|
482
|
+
let n = -100 + 2 * t + 3 * e + 0.2 * e * e + 0.1 * t * e + 0.2 * Math.sqrt(Math.abs(t));
|
|
483
|
+
return n += (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI)) * 2 / 3, n += (20 * Math.sin(e * this.PI) + 40 * Math.sin(e / 3 * this.PI)) * 2 / 3, n += (160 * Math.sin(e / 12 * this.PI) + 320 * Math.sin(e * this.PI / 30)) * 2 / 3, n;
|
|
484
|
+
},
|
|
485
|
+
transformLon(t, e) {
|
|
486
|
+
let n = 300 + t + 2 * e + 0.1 * t * t + 0.1 * t * e + 0.1 * Math.sqrt(Math.abs(t));
|
|
487
|
+
return n += (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI)) * 2 / 3, n += (20 * Math.sin(t * this.PI) + 40 * Math.sin(t / 3 * this.PI)) * 2 / 3, n += (150 * Math.sin(t / 12 * this.PI) + 300 * Math.sin(t / 30 * this.PI)) * 2 / 3, n;
|
|
488
|
+
},
|
|
489
|
+
randomCoordinate(t, e, n, r) {
|
|
628
490
|
return {
|
|
629
|
-
lat: Math.random() * (
|
|
630
|
-
lng: Math.random() * (
|
|
491
|
+
lat: Math.random() * (r - e) + e,
|
|
492
|
+
lng: Math.random() * (n - t) + t
|
|
631
493
|
};
|
|
632
494
|
}
|
|
633
495
|
};
|
|
634
|
-
Date.prototype.format = function(
|
|
635
|
-
const
|
|
496
|
+
Date.prototype.format = function(t) {
|
|
497
|
+
const e = {
|
|
636
498
|
"M+": this.getMonth() + 1,
|
|
499
|
+
// 月份
|
|
637
500
|
"d+": this.getDate(),
|
|
501
|
+
// 日
|
|
638
502
|
"h+": this.getHours(),
|
|
503
|
+
// 小时
|
|
639
504
|
"m+": this.getMinutes(),
|
|
505
|
+
// 分
|
|
640
506
|
"s+": this.getSeconds(),
|
|
507
|
+
// 秒
|
|
641
508
|
"q+": Math.floor((this.getMonth() + 3) / 3),
|
|
509
|
+
// 季度
|
|
642
510
|
S: this.getMilliseconds()
|
|
511
|
+
// 毫秒
|
|
643
512
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
|
649
|
-
}
|
|
650
|
-
return fmt;
|
|
513
|
+
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
|
514
|
+
for (const n in e)
|
|
515
|
+
new RegExp("(" + n + ")").test(t) && (t = t.replace(RegExp.$1, RegExp.$1.length === 1 ? e[n] : ("00" + e[n]).substr(("" + e[n]).length)));
|
|
516
|
+
return t;
|
|
651
517
|
};
|
|
652
|
-
Date.prototype.addDate = function(
|
|
653
|
-
const
|
|
654
|
-
switch (
|
|
518
|
+
Date.prototype.addDate = function(t, e) {
|
|
519
|
+
const n = new Date(this);
|
|
520
|
+
switch (t) {
|
|
655
521
|
case "y":
|
|
656
|
-
|
|
522
|
+
n.setFullYear(this.getFullYear() + e);
|
|
657
523
|
break;
|
|
658
524
|
case "q":
|
|
659
|
-
|
|
525
|
+
n.setMonth(this.getMonth() + e * 3);
|
|
660
526
|
break;
|
|
661
527
|
case "M":
|
|
662
|
-
|
|
528
|
+
n.setMonth(this.getMonth() + e);
|
|
663
529
|
break;
|
|
664
530
|
case "w":
|
|
665
|
-
|
|
531
|
+
n.setDate(this.getDate() + e * 7);
|
|
666
532
|
break;
|
|
667
533
|
case "d":
|
|
668
|
-
|
|
534
|
+
n.setDate(this.getDate() + e);
|
|
669
535
|
break;
|
|
670
536
|
case "h":
|
|
671
|
-
|
|
537
|
+
n.setHours(this.getHours() + e);
|
|
672
538
|
break;
|
|
673
539
|
case "m":
|
|
674
|
-
|
|
540
|
+
n.setMinutes(this.getMinutes() + e);
|
|
675
541
|
break;
|
|
676
542
|
case "s":
|
|
677
|
-
|
|
543
|
+
n.setSeconds(this.getSeconds() + e);
|
|
678
544
|
break;
|
|
679
545
|
default:
|
|
680
|
-
|
|
546
|
+
n.setDate(this.getDate() + e);
|
|
681
547
|
break;
|
|
682
548
|
}
|
|
683
|
-
return
|
|
549
|
+
return n;
|
|
684
550
|
};
|
|
685
|
-
|
|
686
|
-
lastMonthDate: new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1),
|
|
687
|
-
thisMonthDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
|
|
688
|
-
nextMonthDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1),
|
|
689
|
-
lastWeekDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1 - 7 - new Date().getDay()),
|
|
690
|
-
thisWeekDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1 - new Date().getDay()),
|
|
691
|
-
nextWeekDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1 + 7 - new Date().getDay()),
|
|
692
|
-
lastDayDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1),
|
|
693
|
-
thisDayDate: new Date(new Date().setHours(0, 0, 0, 0)),
|
|
694
|
-
nextDayDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1),
|
|
695
|
-
parseDate(
|
|
696
|
-
if (typeof
|
|
697
|
-
var
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
|
|
701
|
-
if (results && results.length > 6)
|
|
551
|
+
const et = {
|
|
552
|
+
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
553
|
+
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
554
|
+
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
555
|
+
lastWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - 7 - (/* @__PURE__ */ new Date()).getDay()),
|
|
556
|
+
thisWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 - (/* @__PURE__ */ new Date()).getDay()),
|
|
557
|
+
nextWeekDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1 + 7 - (/* @__PURE__ */ new Date()).getDay()),
|
|
558
|
+
lastDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() - 1),
|
|
559
|
+
thisDayDate: new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
|
|
560
|
+
nextDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1),
|
|
561
|
+
parseDate(t) {
|
|
562
|
+
if (typeof t == "string") {
|
|
563
|
+
var e = t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
|
|
564
|
+
if (e && e.length > 3) return new Date(parseInt(e[1]), parseInt(e[2]) - 1, parseInt(e[3]));
|
|
565
|
+
if (e = t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/), e && e.length > 6)
|
|
702
566
|
return new Date(
|
|
703
|
-
parseInt(
|
|
704
|
-
parseInt(
|
|
705
|
-
parseInt(
|
|
706
|
-
parseInt(
|
|
707
|
-
parseInt(
|
|
708
|
-
parseInt(
|
|
567
|
+
parseInt(e[1]),
|
|
568
|
+
parseInt(e[2]) - 1,
|
|
569
|
+
parseInt(e[3]),
|
|
570
|
+
parseInt(e[4]),
|
|
571
|
+
parseInt(e[5]),
|
|
572
|
+
parseInt(e[6])
|
|
709
573
|
);
|
|
710
|
-
|
|
711
|
-
if (results && results.length > 7)
|
|
574
|
+
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 && e.length > 7)
|
|
712
575
|
return new Date(
|
|
713
|
-
parseInt(
|
|
714
|
-
parseInt(
|
|
715
|
-
parseInt(
|
|
716
|
-
parseInt(
|
|
717
|
-
parseInt(
|
|
718
|
-
parseInt(
|
|
719
|
-
parseInt(
|
|
576
|
+
parseInt(e[1]),
|
|
577
|
+
parseInt(e[2]) - 1,
|
|
578
|
+
parseInt(e[3]),
|
|
579
|
+
parseInt(e[4]),
|
|
580
|
+
parseInt(e[5]),
|
|
581
|
+
parseInt(e[6]),
|
|
582
|
+
parseInt(e[7])
|
|
720
583
|
);
|
|
721
584
|
}
|
|
722
585
|
return null;
|
|
723
586
|
},
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
intervalDes += minutes + "\u5206";
|
|
744
|
-
}
|
|
745
|
-
if (seconds > 0) {
|
|
746
|
-
intervalDes += seconds + "\u79D2";
|
|
747
|
-
}
|
|
748
|
-
if (days === 0 && hours === 0 && minutes === 0 && seconds === 0) {
|
|
749
|
-
intervalDes = "\u5C11\u4E8E1\u79D2";
|
|
750
|
-
}
|
|
751
|
-
return intervalDes;
|
|
752
|
-
},
|
|
753
|
-
formatterCounter(times) {
|
|
754
|
-
const checked = function(j) {
|
|
755
|
-
return (j > 10 ? "" : "0") + (j || 0);
|
|
756
|
-
};
|
|
757
|
-
const houres = checked(Math.floor(times / 3600));
|
|
758
|
-
const level1 = times % 3600;
|
|
759
|
-
const minutes = checked(Math.floor(level1 / 60));
|
|
760
|
-
const leave2 = level1 % 60;
|
|
761
|
-
const seconds = checked(Math.round(leave2));
|
|
762
|
-
return `${houres}:${minutes}:${seconds}`;
|
|
763
|
-
},
|
|
764
|
-
sleep(d) {
|
|
587
|
+
/**
|
|
588
|
+
* 将时间间隔转换成中国话
|
|
589
|
+
*
|
|
590
|
+
* @param {*} startTime
|
|
591
|
+
* @param {*} endTime
|
|
592
|
+
* @returns {*}
|
|
593
|
+
*/
|
|
594
|
+
formatDateInterval(t, e) {
|
|
595
|
+
const n = new Date(t), a = new Date(e).getTime() - n.getTime(), s = Math.floor(a / (24 * 3600 * 1e3)), i = a % (24 * 3600 * 1e3), o = Math.floor(i / (3600 * 1e3)), c = i % (3600 * 1e3), l = Math.floor(c / (60 * 1e3)), h = c % (60 * 1e3), u = Math.round(h / 1e3);
|
|
596
|
+
let d = "";
|
|
597
|
+
return s > 0 && (d += s + "天"), o > 0 && (d += o + "时"), l > 0 && (d += l + "分"), u > 0 && (d += u + "秒"), s === 0 && o === 0 && l === 0 && u === 0 && (d = "少于1秒"), d;
|
|
598
|
+
},
|
|
599
|
+
formatterCounter(t) {
|
|
600
|
+
const e = function(o) {
|
|
601
|
+
return (o > 10 ? "" : "0") + (o || 0);
|
|
602
|
+
}, n = e(Math.floor(t / 3600)), r = t % 3600, a = e(Math.floor(r / 60)), s = r % 60, i = e(Math.round(s));
|
|
603
|
+
return `${n}:${a}:${i}`;
|
|
604
|
+
},
|
|
605
|
+
sleep(t) {
|
|
765
606
|
}
|
|
766
607
|
};
|
|
767
|
-
function
|
|
768
|
-
return
|
|
608
|
+
function N(t) {
|
|
609
|
+
return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, "");
|
|
769
610
|
}
|
|
770
|
-
function
|
|
771
|
-
return
|
|
611
|
+
function L(t) {
|
|
612
|
+
return N(t).split(/\s+/);
|
|
772
613
|
}
|
|
773
|
-
|
|
774
|
-
getStyle(
|
|
775
|
-
let
|
|
776
|
-
if ((!
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
return
|
|
781
|
-
},
|
|
782
|
-
create(
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
},
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
for (let i = 0, len = classes.length; i < len; i++) {
|
|
830
|
-
el.classList.add(classes[i]);
|
|
831
|
-
}
|
|
832
|
-
} else if (!this.hasClass(el, name)) {
|
|
833
|
-
const className = this.getClass(el);
|
|
834
|
-
this.setClass(el, (className ? className + " " : "") + name);
|
|
835
|
-
}
|
|
836
|
-
},
|
|
837
|
-
removeClass(el, name) {
|
|
838
|
-
if (el.classList !== void 0) {
|
|
839
|
-
const classes = splitWords(name);
|
|
840
|
-
classes.forEach((name2) => el.classList.remove(name2));
|
|
841
|
-
} else {
|
|
842
|
-
this.setClass(el, trim((" " + this.getClass(el) + " ").replace(" " + name + " ", " ")));
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
setClass(el, name) {
|
|
846
|
-
if (el.className.baseVal === void 0) {
|
|
847
|
-
el.className = name;
|
|
848
|
-
} else {
|
|
849
|
-
el.className.baseVal = name;
|
|
850
|
-
}
|
|
851
|
-
},
|
|
852
|
-
parseFromString(str) {
|
|
853
|
-
const parser = new DOMParser();
|
|
854
|
-
const doc = parser.parseFromString(str, "text/xml");
|
|
855
|
-
return doc.children[0];
|
|
614
|
+
const nt = {
|
|
615
|
+
getStyle(t, e) {
|
|
616
|
+
let n = t.style[e] || t.currentStyle && t.currentStyle[e];
|
|
617
|
+
if ((!n || n === "auto") && document.defaultView) {
|
|
618
|
+
const r = document.defaultView.getComputedStyle(t, null);
|
|
619
|
+
n = r ? r[e] : null;
|
|
620
|
+
}
|
|
621
|
+
return n === "auto" ? null : n;
|
|
622
|
+
},
|
|
623
|
+
create(t, e, n) {
|
|
624
|
+
const r = document.createElement(t);
|
|
625
|
+
return r.className = e || "", n && n.appendChild(r), r;
|
|
626
|
+
},
|
|
627
|
+
remove(t) {
|
|
628
|
+
const e = t.parentNode;
|
|
629
|
+
e && e.removeChild(t);
|
|
630
|
+
},
|
|
631
|
+
empty(t) {
|
|
632
|
+
for (; t.firstChild; )
|
|
633
|
+
t.removeChild(t.firstChild);
|
|
634
|
+
},
|
|
635
|
+
toFront(t) {
|
|
636
|
+
const e = t.parentNode;
|
|
637
|
+
e && e.lastChild !== t && e.appendChild(t);
|
|
638
|
+
},
|
|
639
|
+
toBack(t) {
|
|
640
|
+
const e = t.parentNode;
|
|
641
|
+
e && e.firstChild !== t && e.insertBefore(t, e.firstChild);
|
|
642
|
+
},
|
|
643
|
+
getClass(t) {
|
|
644
|
+
return t.correspondingElement && (t = t.correspondingElement), t.className.baseVal === void 0 ? t.className : t.className.baseVal;
|
|
645
|
+
},
|
|
646
|
+
hasClass(t, e) {
|
|
647
|
+
if (t.classList !== void 0)
|
|
648
|
+
return t.classList.contains(e);
|
|
649
|
+
const n = this.getClass(t);
|
|
650
|
+
return n.length > 0 && new RegExp("(^|\\s)" + e + "(\\s|$)").test(n);
|
|
651
|
+
},
|
|
652
|
+
addClass(t, e) {
|
|
653
|
+
if (t.classList !== void 0) {
|
|
654
|
+
const n = L(e);
|
|
655
|
+
for (let r = 0, a = n.length; r < a; r++)
|
|
656
|
+
t.classList.add(n[r]);
|
|
657
|
+
} else if (!this.hasClass(t, e)) {
|
|
658
|
+
const n = this.getClass(t);
|
|
659
|
+
this.setClass(t, (n ? n + " " : "") + e);
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
removeClass(t, e) {
|
|
663
|
+
t.classList !== void 0 ? L(e).forEach((r) => t.classList.remove(r)) : this.setClass(t, N((" " + this.getClass(t) + " ").replace(" " + e + " ", " ")));
|
|
664
|
+
},
|
|
665
|
+
setClass(t, e) {
|
|
666
|
+
t.className.baseVal === void 0 ? t.className = e : t.className.baseVal = e;
|
|
667
|
+
},
|
|
668
|
+
parseFromString(t) {
|
|
669
|
+
return new DOMParser().parseFromString(t, "text/xml").children[0];
|
|
856
670
|
}
|
|
857
|
-
}
|
|
858
|
-
var MathUtils = {
|
|
671
|
+
}, g = {
|
|
859
672
|
DEG2RAD: Math.PI / 180,
|
|
860
673
|
RAD2DEG: 180 / Math.PI,
|
|
861
|
-
randInt(
|
|
862
|
-
return
|
|
863
|
-
},
|
|
864
|
-
randFloat(
|
|
865
|
-
return
|
|
866
|
-
},
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
674
|
+
randInt(t, e) {
|
|
675
|
+
return t + Math.floor(Math.random() * (e - t + 1));
|
|
676
|
+
},
|
|
677
|
+
randFloat(t, e) {
|
|
678
|
+
return t + Math.random() * (e - t);
|
|
679
|
+
},
|
|
680
|
+
/**
|
|
681
|
+
* 角度转弧度
|
|
682
|
+
*
|
|
683
|
+
* @param {*} degrees
|
|
684
|
+
* @returns {*}
|
|
685
|
+
*/
|
|
686
|
+
degreesToRadians(t) {
|
|
687
|
+
return t * this.DEG2RAD;
|
|
688
|
+
},
|
|
689
|
+
/**
|
|
690
|
+
* 角度转弧度
|
|
691
|
+
*
|
|
692
|
+
* @param {*} degrees
|
|
693
|
+
* @returns {*}
|
|
694
|
+
*/
|
|
695
|
+
toRadians(t) {
|
|
696
|
+
return t * this.DEG2RAD;
|
|
697
|
+
},
|
|
698
|
+
/**
|
|
699
|
+
* 弧度转角度
|
|
700
|
+
*
|
|
701
|
+
* @param {*} radians
|
|
702
|
+
* @returns {*}
|
|
703
|
+
*/
|
|
704
|
+
radiansToDegrees(t) {
|
|
705
|
+
return t * this.RAD2DEG;
|
|
706
|
+
},
|
|
707
|
+
/**
|
|
708
|
+
* 弧度转角度
|
|
709
|
+
*
|
|
710
|
+
* @param {*} radians
|
|
711
|
+
* @returns {*}
|
|
712
|
+
*/
|
|
713
|
+
toDegrees(t) {
|
|
714
|
+
return t * this.RAD2DEG;
|
|
715
|
+
},
|
|
716
|
+
formatFloat(t, e = 2) {
|
|
717
|
+
return Math.round(t * Math.pow(10, e)) / Math.pow(10, e);
|
|
881
718
|
}
|
|
882
|
-
}
|
|
883
|
-
var GeoUtils = {
|
|
719
|
+
}, j = {
|
|
884
720
|
toRadian: Math.PI / 180,
|
|
885
721
|
R: 6371393,
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
722
|
+
/**
|
|
723
|
+
* 验证经纬度坐标
|
|
724
|
+
*
|
|
725
|
+
* @param {*} lng
|
|
726
|
+
* @param {*} lat
|
|
727
|
+
* @returns {*} {boolean}
|
|
728
|
+
*/
|
|
729
|
+
isLnglat(t, e) {
|
|
730
|
+
return t && e && +e > -90 && +e < 90 && +t > -180 && +t < 180;
|
|
731
|
+
},
|
|
732
|
+
/**
|
|
733
|
+
* 格式化经纬度(转度分秒)
|
|
734
|
+
*
|
|
735
|
+
* @param {*} lng
|
|
736
|
+
* @param {*} lat
|
|
737
|
+
* @returns {*}
|
|
738
|
+
*/
|
|
739
|
+
formatLnglat(t, e) {
|
|
740
|
+
let n = "";
|
|
741
|
+
function r(a) {
|
|
742
|
+
const s = parseFloat(a), i = parseInt(s);
|
|
743
|
+
let o = parseInt((s - i) * 60), c = (s - i) * 3600 - o * 60;
|
|
744
|
+
return i + "°" + o + "′" + c.toFixed(2) + "″";
|
|
745
|
+
}
|
|
746
|
+
return t && e && (n = r(t) + "," + r(e)), n;
|
|
747
|
+
},
|
|
748
|
+
/**
|
|
749
|
+
* 度分秒转十进制
|
|
750
|
+
*
|
|
751
|
+
* @param {*} lng
|
|
752
|
+
* @param {*} lat
|
|
753
|
+
* @returns {*}
|
|
754
|
+
*/
|
|
755
|
+
transformLnglat(t, e) {
|
|
756
|
+
function n(r) {
|
|
757
|
+
for (var a = /[sw]/i.test(r), s = a ? -1 : 1, i = r.match(/[\d.]+/g), o = 0, c = 0, l = i.length; c < l; c++)
|
|
758
|
+
o += i[c] / s, s *= 60;
|
|
759
|
+
return o;
|
|
760
|
+
}
|
|
761
|
+
if (t && e)
|
|
916
762
|
return {
|
|
917
|
-
lng:
|
|
918
|
-
lat:
|
|
763
|
+
lng: n(t),
|
|
764
|
+
lat: n(e)
|
|
919
765
|
};
|
|
920
|
-
}
|
|
921
766
|
},
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
767
|
+
/**
|
|
768
|
+
* 判断点是否在多边形内
|
|
769
|
+
*
|
|
770
|
+
* @param {*} p
|
|
771
|
+
* @param {*} poly
|
|
772
|
+
* @returns {*}
|
|
773
|
+
*/
|
|
774
|
+
rayCasting(t, e) {
|
|
775
|
+
for (var n = t.x, r = t.y, a = !1, s = 0, i = e.length, o = i - 1; s < i; o = s, s++) {
|
|
776
|
+
var c = e[s].x, l = e[s].y, h = e[o].x, u = e[o].y;
|
|
777
|
+
if (c === n && l === r || h === n && u === r)
|
|
927
778
|
return "on";
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if (x === px) {
|
|
779
|
+
if (l < r && u >= r || l >= r && u < r) {
|
|
780
|
+
var d = c + (r - l) * (h - c) / (u - l);
|
|
781
|
+
if (d === n)
|
|
932
782
|
return "on";
|
|
933
|
-
|
|
934
|
-
if (x > px) {
|
|
935
|
-
flag = !flag;
|
|
936
|
-
}
|
|
783
|
+
d > n && (a = !a);
|
|
937
784
|
}
|
|
938
785
|
}
|
|
939
|
-
return
|
|
940
|
-
},
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
786
|
+
return a ? "in" : "out";
|
|
787
|
+
},
|
|
788
|
+
/**
|
|
789
|
+
* 计算两点距离
|
|
790
|
+
*
|
|
791
|
+
* @param {*} fromPoint
|
|
792
|
+
* @param {*} toPoint
|
|
793
|
+
* @returns {*}
|
|
794
|
+
*/
|
|
795
|
+
wgs84PointsDistance(t, e) {
|
|
796
|
+
var n = Math.PI;
|
|
797
|
+
function r(W) {
|
|
798
|
+
return W * n / 180;
|
|
799
|
+
}
|
|
800
|
+
if (arguments.length != 2)
|
|
947
801
|
return 0;
|
|
948
|
-
|
|
949
|
-
lon1 =
|
|
950
|
-
lat1 = fromPoint.y;
|
|
951
|
-
lon2 = toPoint.x;
|
|
952
|
-
lat2 = toPoint.y;
|
|
953
|
-
var a = 6378137, b = 63567523142e-4, f = 1 / 298.257223563;
|
|
954
|
-
var L = getRad(lon2 - lon1);
|
|
955
|
-
var U1 = Math.atan((1 - f) * Math.tan(getRad(lat1)));
|
|
956
|
-
var U2 = Math.atan((1 - f) * Math.tan(getRad(lat2)));
|
|
957
|
-
var sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
|
|
958
|
-
var sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
|
|
959
|
-
var lambda = L, lambdaP, iterLimit = 100;
|
|
802
|
+
lon1 = t.x, lat1 = t.y, lon2 = e.x, lat2 = e.y;
|
|
803
|
+
var a = 6378137, s = 63567523142e-4, i = 1 / 298.257223563, o = r(lon2 - lon1), c = Math.atan((1 - i) * Math.tan(r(lat1))), l = Math.atan((1 - i) * Math.tan(r(lat2))), h = Math.sin(c), u = Math.cos(c), d = Math.sin(l), f = Math.cos(l), w = o, T, _ = 100;
|
|
960
804
|
do {
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
cosU2 * sinLambda * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
|
|
805
|
+
var b = Math.sin(w), A = Math.cos(w), R = Math.sqrt(
|
|
806
|
+
f * b * (f * b) + (u * d - h * f * A) * (u * d - h * f * A)
|
|
964
807
|
);
|
|
965
|
-
if (
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
var
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
if (isNaN(cos2SigmaM))
|
|
973
|
-
cos2SigmaM = 0;
|
|
974
|
-
var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
|
|
975
|
-
lambdaP = lambda;
|
|
976
|
-
lambda = L + (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
977
|
-
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
|
|
978
|
-
if (iterLimit == 0) {
|
|
808
|
+
if (R == 0) return 0;
|
|
809
|
+
var D = h * d + u * f * A, C = Math.atan2(R, D), x = u * f * b / R, O = 1 - x * x, p = D - 2 * h * d / O;
|
|
810
|
+
isNaN(p) && (p = 0);
|
|
811
|
+
var I = i / 16 * O * (4 + i * (4 - 3 * O));
|
|
812
|
+
T = w, w = o + (1 - I) * i * x * (C + I * R * (p + I * D * (-1 + 2 * p * p)));
|
|
813
|
+
} while (Math.abs(w - T) > 1e-12 && --_ > 0);
|
|
814
|
+
if (_ == 0)
|
|
979
815
|
return NaN;
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
const { x:
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
var
|
|
1007
|
-
var angle = Math.atan2(y, x) * (180 / Math.PI);
|
|
1008
|
-
var deltaF = (f2 - f1) * this.toRadian;
|
|
1009
|
-
var deltaL = (l2 - l1) * this.toRadian;
|
|
1010
|
-
var a = Math.sin(deltaF / 2) * Math.sin(deltaF / 2) + Math.cos(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.sin(deltaL / 2) * Math.sin(deltaL / 2);
|
|
1011
|
-
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
1012
|
-
var distance = this.R * c;
|
|
816
|
+
var M = O * (a * a - s * s) / (s * s), F = 1 + M / 16384 * (4096 + M * (-768 + M * (320 - 175 * M))), S = M / 1024 * (256 + M * (-128 + M * (74 - 47 * M))), B = S * R * (p + S / 4 * (D * (-1 + 2 * p * p) - S / 6 * p * (-3 + 4 * R * R) * (-3 + 4 * p * p))), $ = s * F * (C - B);
|
|
817
|
+
return $;
|
|
818
|
+
},
|
|
819
|
+
/**
|
|
820
|
+
* P1绕一个坐标点P2旋转θ角度后,新的坐标的计算公式
|
|
821
|
+
*
|
|
822
|
+
* @param {*} p1
|
|
823
|
+
* @param {*} p2
|
|
824
|
+
* @param {*} θ 旋转角度,正:表示顺时针,负:表示逆时针
|
|
825
|
+
*/
|
|
826
|
+
rotatePoint(t, e, n) {
|
|
827
|
+
const r = (t.x - e.x) * Math.cos(Math.PI / 180 * -n) - (t.y - e.y) * Math.sin(Math.PI / 180 * -n) + e.x, a = (t.x - e.x) * Math.sin(Math.PI / 180 * -n) + (t.y - e.y) * Math.cos(Math.PI / 180 * -n) + e.y;
|
|
828
|
+
return { x: r, y: a };
|
|
829
|
+
},
|
|
830
|
+
calcBearAndDis(t, e) {
|
|
831
|
+
const { x: n, y: r } = t, { x: a, y: s } = e, i = a - n, o = s - r, c = Math.sqrt(i * i + o * o);
|
|
832
|
+
return { angle: (Math.atan2(o, i) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
|
|
833
|
+
},
|
|
834
|
+
/**
|
|
835
|
+
* 计算latlng2相对于latlng1的方位角和距离
|
|
836
|
+
*
|
|
837
|
+
* @param {*} latlng1
|
|
838
|
+
* @param {*} latlng2
|
|
839
|
+
* @returns {*} {boolean}
|
|
840
|
+
*/
|
|
841
|
+
calcBearAndDisByPoints(t, e) {
|
|
842
|
+
var n = parseFloat(t.lat), r = parseFloat(t.lng), a = parseFloat(e.lat), s = parseFloat(e.lng), i = Math.sin((s - r) * this.toRadian) * Math.cos(a * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(a * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.cos((s - r) * this.toRadian), c = Math.atan2(i, o) * (180 / Math.PI), l = (a - n) * this.toRadian, h = (s - r) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), f = this.R * d;
|
|
1013
843
|
return {
|
|
1014
|
-
angle,
|
|
1015
|
-
distance
|
|
844
|
+
angle: c,
|
|
845
|
+
distance: f
|
|
1016
846
|
};
|
|
1017
847
|
},
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
848
|
+
/**
|
|
849
|
+
* 根据方位角和距离生成新的坐标
|
|
850
|
+
*
|
|
851
|
+
* @param {*} latlng
|
|
852
|
+
* @param {*} angle
|
|
853
|
+
* @param {*} distance
|
|
854
|
+
* @returns {*}
|
|
855
|
+
*/
|
|
856
|
+
calcPointByBearAndDis(t, e, n) {
|
|
857
|
+
const r = g.toRadians(parseFloat(t.lat)), a = g.toRadians(parseFloat(t.lng));
|
|
858
|
+
e = parseFloat(e), n = parseFloat(n);
|
|
859
|
+
const s = n / this.R;
|
|
860
|
+
e = g.toRadians(e);
|
|
861
|
+
const i = Math.asin(Math.sin(r) * Math.cos(s) + Math.cos(r) * Math.sin(s) * Math.cos(e)), o = a + Math.atan2(Math.sin(e) * Math.sin(s) * Math.cos(r), Math.cos(s) - Math.sin(r) * Math.sin(i));
|
|
1027
862
|
return {
|
|
1028
|
-
lat:
|
|
1029
|
-
lng:
|
|
863
|
+
lat: g.toDegrees(i),
|
|
864
|
+
lng: g.toDegrees(o)
|
|
1030
865
|
};
|
|
1031
866
|
},
|
|
1032
|
-
mercatorTolonlat(
|
|
1033
|
-
const
|
|
1034
|
-
var
|
|
1035
|
-
const
|
|
1036
|
-
return { lng, lat };
|
|
1037
|
-
},
|
|
1038
|
-
lonlatToMercator(
|
|
1039
|
-
var
|
|
1040
|
-
const
|
|
1041
|
-
var a =
|
|
1042
|
-
const
|
|
1043
|
-
return { x, y };
|
|
867
|
+
mercatorTolonlat(t, e) {
|
|
868
|
+
const n = t / 2003750834e-2 * 180;
|
|
869
|
+
var r = e / 2003750834e-2 * 180;
|
|
870
|
+
const a = 180 / Math.PI * (2 * Math.atan(Math.exp(r * Math.PI / 180)) - Math.PI / 2);
|
|
871
|
+
return { lng: n, lat: a };
|
|
872
|
+
},
|
|
873
|
+
lonlatToMercator(t, e) {
|
|
874
|
+
var n = 6378137;
|
|
875
|
+
const r = t * Math.PI / 180 * n;
|
|
876
|
+
var a = e * Math.PI / 180;
|
|
877
|
+
const s = n / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a)));
|
|
878
|
+
return { x: r, y: s };
|
|
1044
879
|
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
var
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
var
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
var base64 = {
|
|
1081
|
-
dataURL,
|
|
1082
|
-
type: "image/" + ext,
|
|
1083
|
-
ext
|
|
880
|
+
}, rt = {
|
|
881
|
+
/**
|
|
882
|
+
* 将base64类型编码的图片转换成blob类型
|
|
883
|
+
*
|
|
884
|
+
* @param {*} data
|
|
885
|
+
* @returns {*}
|
|
886
|
+
*/
|
|
887
|
+
convertBase64ToBlob(t) {
|
|
888
|
+
for (var e = t.split(",")[0].split(":")[1].split(";")[0], n = window.atob(t.split(",")[1]), r = new ArrayBuffer(n.length), a = new Uint8Array(r), s = 0; s < n.length; s++)
|
|
889
|
+
a[s] = n.charCodeAt(s);
|
|
890
|
+
var i = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
|
|
891
|
+
return i ? (i = new (window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder)(), i.append(r), i.getBlob(e)) : (i = new Blob([r], {
|
|
892
|
+
type: e
|
|
893
|
+
}), i);
|
|
894
|
+
},
|
|
895
|
+
/**
|
|
896
|
+
* 将url图片转换成base64编码的图片,也可用于图片压缩
|
|
897
|
+
*
|
|
898
|
+
* @param {*} url 需要转换的图片url
|
|
899
|
+
* @param {*} width 指定宽高,如未指定则使用默认宽度
|
|
900
|
+
* @param {*} height
|
|
901
|
+
* @returns {*}
|
|
902
|
+
*/
|
|
903
|
+
convertUrlToBase64(t, e, n) {
|
|
904
|
+
return new Promise(function(r, a) {
|
|
905
|
+
var s = new Image();
|
|
906
|
+
s.crossOrigin = "Anonymous", s.src = t, s.onload = function() {
|
|
907
|
+
var i = document.createElement("canvas");
|
|
908
|
+
i.width = e || s.width, i.height = n || s.height;
|
|
909
|
+
var o = i.getContext("2d");
|
|
910
|
+
o.drawImage(s, 0, 0, s.width, s.height);
|
|
911
|
+
var c = s.src.substring(s.src.lastIndexOf(".") + 1).toLowerCase(), l = i.toDataURL("image/" + c), h = {
|
|
912
|
+
dataURL: l,
|
|
913
|
+
type: "image/" + c,
|
|
914
|
+
ext: c
|
|
1084
915
|
};
|
|
1085
|
-
|
|
916
|
+
r(h);
|
|
1086
917
|
};
|
|
1087
918
|
});
|
|
1088
919
|
},
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
920
|
+
/**
|
|
921
|
+
* 将base64类型编码的图片转换成file类型
|
|
922
|
+
*
|
|
923
|
+
* @param {*} dataurl
|
|
924
|
+
* @param {*} filename
|
|
925
|
+
* @returns {*}
|
|
926
|
+
*/
|
|
927
|
+
convertBase64ToFile(t, e) {
|
|
928
|
+
for (var n = t.split(","), r = n[0].match(/:(.*?);/)[1], a = atob(n[1]), s = a.length, i = new Uint8Array(s); s--; )
|
|
929
|
+
i[s] = a.charCodeAt(s);
|
|
930
|
+
return new File([i], e, { type: r });
|
|
931
|
+
},
|
|
932
|
+
/**
|
|
933
|
+
* 直接下载文件,支持blob类型和url类型
|
|
934
|
+
*
|
|
935
|
+
* @param {*} data
|
|
936
|
+
* @param {*} saveName
|
|
937
|
+
*/
|
|
938
|
+
downloadFromFile(t, e) {
|
|
939
|
+
if (typeof t == "object")
|
|
940
|
+
if (t instanceof Blob)
|
|
941
|
+
t = URL.createObjectURL(t);
|
|
942
|
+
else {
|
|
943
|
+
const r = JSON.stringify(t), a = new Blob([r], { type: "text/json" });
|
|
944
|
+
t = window.URL.createObjectURL(a);
|
|
1105
945
|
}
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
|
|
946
|
+
else if (typeof t == "string" && t.indexOf("http") === -1) {
|
|
947
|
+
const r = new Blob([t], { type: "text/json" });
|
|
948
|
+
t = window.URL.createObjectURL(r);
|
|
1109
949
|
}
|
|
1110
|
-
var
|
|
1111
|
-
|
|
1112
|
-
link.download = saveName || "";
|
|
1113
|
-
link.click();
|
|
1114
|
-
window.URL.revokeObjectURL(link.href);
|
|
950
|
+
var n = document.createElement("a");
|
|
951
|
+
n.href = t, n.download = e || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
1115
952
|
}
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}
|
|
953
|
+
}, st = {
|
|
954
|
+
/**
|
|
955
|
+
* @desc 在事件被触发n秒后再执行回调函数,如果在这n秒内又被触发,则重新计时
|
|
956
|
+
* @desc 防止onresize,scroll,mousemove ,mousehover等,会被频繁触发影响性能
|
|
957
|
+
* @param func 需要执行的函数
|
|
958
|
+
* @param wait 延迟执行时间(毫秒)
|
|
959
|
+
* @param immediate---true 表立即执行,false 表非立即执行
|
|
960
|
+
* eg: window.addEventListener("resize",debounce(handle,1000));
|
|
961
|
+
* @returns {*}
|
|
962
|
+
*/
|
|
963
|
+
debounce(t, e, n = !0) {
|
|
964
|
+
let r, a, s, i, o;
|
|
965
|
+
const c = function() {
|
|
966
|
+
const l = +/* @__PURE__ */ new Date() - i;
|
|
967
|
+
l < e && l > 0 ? r = setTimeout(c, e - l) : (r = null, n || (o = t.apply(s, a), r || (s = a = null)));
|
|
1132
968
|
};
|
|
1133
|
-
return function(...
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
if (!timeout)
|
|
1138
|
-
timeout = setTimeout(later, wait);
|
|
1139
|
-
if (callNow) {
|
|
1140
|
-
result = func.apply(context, args2);
|
|
1141
|
-
context = args2 = null;
|
|
1142
|
-
}
|
|
1143
|
-
return result;
|
|
969
|
+
return function(...l) {
|
|
970
|
+
s = this, i = +/* @__PURE__ */ new Date();
|
|
971
|
+
const h = n && !r;
|
|
972
|
+
return r || (r = setTimeout(c, e)), h && (o = t.apply(s, l), s = l = null), o;
|
|
1144
973
|
};
|
|
1145
974
|
},
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
975
|
+
/**
|
|
976
|
+
* 规定一个单位时间,在这个单位时间内,只能有一次触发事件的回调函数执行,如果在同一个单位时间内某事件被触发多次,只有一次能生效
|
|
977
|
+
*
|
|
978
|
+
* @param {*} func
|
|
979
|
+
* @param {*} wait
|
|
980
|
+
* @param {*} type 1 表时间戳版,2 表定时器版
|
|
981
|
+
* @returns {*}
|
|
982
|
+
*/
|
|
983
|
+
throttle(t, e, n) {
|
|
984
|
+
if (n === 1)
|
|
985
|
+
var r = 0;
|
|
986
|
+
else if (n === 2)
|
|
987
|
+
var a;
|
|
1152
988
|
return function() {
|
|
1153
|
-
let
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
} else if (type === 2) {
|
|
1162
|
-
if (!timeout) {
|
|
1163
|
-
timeout = setTimeout(() => {
|
|
1164
|
-
timeout = null;
|
|
1165
|
-
func.apply(context, args);
|
|
1166
|
-
}, wait);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
989
|
+
let s = this, i = arguments;
|
|
990
|
+
if (n === 1) {
|
|
991
|
+
let o = Date.now();
|
|
992
|
+
o - r > e && (t.apply(s, i), r = o);
|
|
993
|
+
} else n === 2 && (a || (a = setTimeout(() => {
|
|
994
|
+
a = null, t.apply(s, i);
|
|
995
|
+
}, e)));
|
|
1169
996
|
};
|
|
1170
997
|
},
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
998
|
+
/**
|
|
999
|
+
* 延时递归
|
|
1000
|
+
*
|
|
1001
|
+
* @param {Number} frequency 间隔时间ms
|
|
1002
|
+
* @param {Number} duration 持续时间ms
|
|
1003
|
+
*/
|
|
1004
|
+
recurve(t, e = 500, n = 5e3) {
|
|
1005
|
+
let r = 0;
|
|
1006
|
+
setTimeout(function a() {
|
|
1007
|
+
r++, r < Math.floor(n / e) && (t.call(this), setTimeout(a, e));
|
|
1179
1008
|
});
|
|
1180
1009
|
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1010
|
+
}, q = {
|
|
1011
|
+
/**
|
|
1012
|
+
* 常用正则验证
|
|
1013
|
+
*
|
|
1014
|
+
* @param {*} str
|
|
1015
|
+
* @param {*} type
|
|
1016
|
+
* @returns {*}
|
|
1017
|
+
*/
|
|
1018
|
+
checkStr(t, e) {
|
|
1019
|
+
switch (e) {
|
|
1185
1020
|
case "phone":
|
|
1186
|
-
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(
|
|
1021
|
+
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);
|
|
1187
1022
|
case "tel":
|
|
1188
|
-
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(
|
|
1023
|
+
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);
|
|
1189
1024
|
case "card":
|
|
1190
|
-
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(
|
|
1025
|
+
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);
|
|
1191
1026
|
case "pwd":
|
|
1192
|
-
return /^[a-zA-Z]\w{5,17}$/.test(
|
|
1027
|
+
return /^[a-zA-Z]\w{5,17}$/.test(t);
|
|
1193
1028
|
case "postal":
|
|
1194
|
-
return /[1-9]\d{5}(?!\d)/.test(
|
|
1029
|
+
return /[1-9]\d{5}(?!\d)/.test(t);
|
|
1195
1030
|
case "QQ":
|
|
1196
|
-
return /^[1-9][0-9]{4,9}$/.test(
|
|
1031
|
+
return /^[1-9][0-9]{4,9}$/.test(t);
|
|
1197
1032
|
case "email":
|
|
1198
|
-
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(
|
|
1033
|
+
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);
|
|
1199
1034
|
case "money":
|
|
1200
|
-
return /^\d*(?:\.\d{0,2})?$/.test(
|
|
1035
|
+
return /^\d*(?:\.\d{0,2})?$/.test(t);
|
|
1201
1036
|
case "URL":
|
|
1202
|
-
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(
|
|
1037
|
+
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);
|
|
1203
1038
|
case "IP":
|
|
1204
|
-
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(
|
|
1039
|
+
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);
|
|
1205
1040
|
case "date":
|
|
1206
|
-
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(
|
|
1041
|
+
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);
|
|
1207
1042
|
case "number":
|
|
1208
|
-
return /^[0-9]$/.test(
|
|
1043
|
+
return /^[0-9]$/.test(t);
|
|
1209
1044
|
case "english":
|
|
1210
|
-
return /^[a-zA-Z]+$/.test(
|
|
1045
|
+
return /^[a-zA-Z]+$/.test(t);
|
|
1211
1046
|
case "chinese":
|
|
1212
|
-
return /^[\u4E00-\u9FA5]+$/.test(
|
|
1047
|
+
return /^[\u4E00-\u9FA5]+$/.test(t);
|
|
1213
1048
|
case "lower":
|
|
1214
|
-
return /^[a-z]+$/.test(
|
|
1049
|
+
return /^[a-z]+$/.test(t);
|
|
1215
1050
|
case "upper":
|
|
1216
|
-
return /^[A-Z]+$/.test(
|
|
1051
|
+
return /^[A-Z]+$/.test(t);
|
|
1217
1052
|
case "HTML":
|
|
1218
|
-
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(
|
|
1053
|
+
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(t);
|
|
1219
1054
|
default:
|
|
1220
|
-
return
|
|
1221
|
-
}
|
|
1222
|
-
},
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1055
|
+
return !0;
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
/**
|
|
1059
|
+
* 字符串大小写转换 type: 1:首字母大写 2:首页母小写 3:大小写转换 4:全部大写 5:全部小写
|
|
1060
|
+
*
|
|
1061
|
+
* @param {*} str
|
|
1062
|
+
* @param {*} type
|
|
1063
|
+
* @returns {*}
|
|
1064
|
+
*/
|
|
1065
|
+
changeCase(t, e) {
|
|
1066
|
+
switch (e = e || 4, e) {
|
|
1226
1067
|
case 1:
|
|
1227
|
-
return
|
|
1228
|
-
return
|
|
1068
|
+
return t.replace(/\b\w+\b/g, function(n) {
|
|
1069
|
+
return n.substring(0, 1).toUpperCase() + n.substring(1).toLowerCase();
|
|
1229
1070
|
});
|
|
1230
1071
|
case 2:
|
|
1231
|
-
return
|
|
1232
|
-
return
|
|
1072
|
+
return t.replace(/\b\w+\b/g, function(n) {
|
|
1073
|
+
return n.substring(0, 1).toLowerCase() + n.substring(1).toUpperCase();
|
|
1233
1074
|
});
|
|
1234
1075
|
case 3:
|
|
1235
|
-
return
|
|
1236
|
-
|
|
1237
|
-
return word.toUpperCase();
|
|
1238
|
-
} else {
|
|
1239
|
-
return word.toLowerCase();
|
|
1240
|
-
}
|
|
1076
|
+
return t.split("").map(function(n) {
|
|
1077
|
+
return /[a-z]/.test(n) ? n.toUpperCase() : n.toLowerCase();
|
|
1241
1078
|
}).join("");
|
|
1242
1079
|
case 4:
|
|
1243
|
-
return
|
|
1080
|
+
return t.toUpperCase();
|
|
1244
1081
|
case 5:
|
|
1245
|
-
return
|
|
1082
|
+
return t.toLowerCase();
|
|
1246
1083
|
default:
|
|
1247
|
-
return
|
|
1248
|
-
}
|
|
1249
|
-
},
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1084
|
+
return t;
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
/**
|
|
1088
|
+
* 处理字符串模板
|
|
1089
|
+
* eg: tag`${abc}`
|
|
1090
|
+
* @param {*} strArray
|
|
1091
|
+
* @param {*} args
|
|
1092
|
+
* @returns {*}
|
|
1093
|
+
*/
|
|
1094
|
+
tag(t, ...e) {
|
|
1095
|
+
return e = e.map((n) => {
|
|
1096
|
+
switch (E.getDataType(n)) {
|
|
1253
1097
|
case "Object":
|
|
1254
|
-
return
|
|
1098
|
+
return n || "{}";
|
|
1255
1099
|
case "Array":
|
|
1256
|
-
return
|
|
1100
|
+
return n || "[]";
|
|
1257
1101
|
default:
|
|
1258
|
-
return
|
|
1102
|
+
return n || "";
|
|
1259
1103
|
}
|
|
1260
|
-
});
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1104
|
+
}), t.reduce((n, r, a) => `${n}${e[a - 1]}${r}`);
|
|
1105
|
+
},
|
|
1106
|
+
/**
|
|
1107
|
+
* 获取字符串字节长度
|
|
1108
|
+
* @param {*} str
|
|
1109
|
+
* @returns {*}
|
|
1110
|
+
*/
|
|
1111
|
+
getByteLength(t) {
|
|
1112
|
+
return t.replace(/[\u0391-\uFFE5]/g, "aa").length;
|
|
1113
|
+
},
|
|
1114
|
+
/**
|
|
1115
|
+
* 根据字节长度截取字符串
|
|
1116
|
+
* @param {*} str
|
|
1117
|
+
* @param {*} n
|
|
1118
|
+
* @returns {*}
|
|
1119
|
+
*/
|
|
1120
|
+
subStringByte(t, e, n) {
|
|
1267
1121
|
var r = /[^\x00-\xff]/g;
|
|
1268
|
-
if (
|
|
1269
|
-
return
|
|
1122
|
+
if (t.replace(r, "mm").length <= n)
|
|
1123
|
+
return t;
|
|
1124
|
+
for (var a = Math.floor(n / 2), s = a; s < t.length; s++) {
|
|
1125
|
+
let i = t.substring(e, s);
|
|
1126
|
+
if (i.replace(r, "mm").length >= n)
|
|
1127
|
+
return i;
|
|
1270
1128
|
}
|
|
1271
|
-
|
|
1272
|
-
for (var i = m; i < str.length; i++) {
|
|
1273
|
-
let sub = str.substring(start, i);
|
|
1274
|
-
if (sub.replace(r, "mm").length >= n) {
|
|
1275
|
-
return sub;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
return str;
|
|
1129
|
+
return t;
|
|
1279
1130
|
},
|
|
1280
|
-
asString(
|
|
1281
|
-
if (
|
|
1131
|
+
asString(t) {
|
|
1132
|
+
if (E.isEmpty(t))
|
|
1282
1133
|
return "";
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
return value;
|
|
1290
|
-
}
|
|
1134
|
+
switch (E.getDataType()) {
|
|
1135
|
+
case "Object":
|
|
1136
|
+
case "Array":
|
|
1137
|
+
return JSON.stringify(t);
|
|
1138
|
+
default:
|
|
1139
|
+
return t;
|
|
1291
1140
|
}
|
|
1292
1141
|
}
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
res = str.indexOf(args[i]) >= 0;
|
|
1310
|
-
}
|
|
1311
|
-
if (res) {
|
|
1312
|
-
throw Error(ErrorType.STRING_CHECK_LOSS);
|
|
1313
|
-
}
|
|
1142
|
+
}, at = {
|
|
1143
|
+
notNull(t) {
|
|
1144
|
+
if (E.isEmpty(t))
|
|
1145
|
+
throw Error("不能为空:>>>" + t);
|
|
1146
|
+
},
|
|
1147
|
+
legalLnglat(t, e) {
|
|
1148
|
+
if (!j.isLnglat(t, e))
|
|
1149
|
+
throw Error(m.COORDINATE_ERROR);
|
|
1150
|
+
},
|
|
1151
|
+
contain(t, ...e) {
|
|
1152
|
+
let n = !1;
|
|
1153
|
+
const r = e.length || 0;
|
|
1154
|
+
for (let a = 0, s = r; a < s; a++)
|
|
1155
|
+
n = t.indexOf(e[a]) >= 0;
|
|
1156
|
+
if (n)
|
|
1157
|
+
throw Error(m.STRING_CHECK_LOSS);
|
|
1314
1158
|
},
|
|
1315
1159
|
verify: {
|
|
1316
|
-
array(
|
|
1317
|
-
if (
|
|
1318
|
-
throw Error(
|
|
1319
|
-
}
|
|
1160
|
+
array(t) {
|
|
1161
|
+
if (E.getDataType(t) !== "Array")
|
|
1162
|
+
throw Error(m.PARAMETER_ERROR_ARRAY + ":>>>" + t);
|
|
1320
1163
|
},
|
|
1321
|
-
function(
|
|
1322
|
-
if (
|
|
1323
|
-
throw Error(
|
|
1324
|
-
}
|
|
1164
|
+
function(t) {
|
|
1165
|
+
if (E.getDataType(t) !== "Function")
|
|
1166
|
+
throw Error(m.PARAMETER_ERROR_FUNCTION + ":>>>" + t);
|
|
1325
1167
|
},
|
|
1326
|
-
object(
|
|
1327
|
-
if (
|
|
1328
|
-
throw Error(
|
|
1329
|
-
}
|
|
1168
|
+
object(t) {
|
|
1169
|
+
if (E.getDataType(t) !== "Object")
|
|
1170
|
+
throw Error(m.PARAMETER_ERROR_OBJECT + ":>>>" + t);
|
|
1330
1171
|
}
|
|
1331
1172
|
},
|
|
1332
|
-
legalJSON(
|
|
1173
|
+
legalJSON(t) {
|
|
1333
1174
|
try {
|
|
1334
|
-
JSON.parse(
|
|
1335
|
-
} catch
|
|
1336
|
-
throw Error(
|
|
1175
|
+
JSON.parse(t);
|
|
1176
|
+
} catch {
|
|
1177
|
+
throw Error(m.JSON_PARSE_ERROR + ":>>>" + t);
|
|
1337
1178
|
}
|
|
1338
1179
|
},
|
|
1339
|
-
legalData(
|
|
1340
|
-
const
|
|
1341
|
-
let
|
|
1342
|
-
switch (
|
|
1180
|
+
legalData(t, e) {
|
|
1181
|
+
const n = q.checkStr(t, e);
|
|
1182
|
+
let r = "";
|
|
1183
|
+
switch (e) {
|
|
1343
1184
|
case "phone":
|
|
1344
|
-
|
|
1185
|
+
r = "电话";
|
|
1345
1186
|
break;
|
|
1346
1187
|
case "tel":
|
|
1347
|
-
|
|
1188
|
+
r = "座机";
|
|
1348
1189
|
break;
|
|
1349
1190
|
case "card":
|
|
1350
|
-
|
|
1191
|
+
r = "身份证";
|
|
1351
1192
|
break;
|
|
1352
1193
|
case "pwd":
|
|
1353
|
-
|
|
1194
|
+
r = "密码";
|
|
1354
1195
|
break;
|
|
1355
1196
|
case "postal":
|
|
1356
|
-
|
|
1197
|
+
r = "邮政编码";
|
|
1357
1198
|
break;
|
|
1358
1199
|
case "QQ":
|
|
1359
|
-
|
|
1200
|
+
r = "QQ";
|
|
1360
1201
|
break;
|
|
1361
1202
|
case "email":
|
|
1362
|
-
|
|
1203
|
+
r = "邮箱";
|
|
1363
1204
|
break;
|
|
1364
1205
|
case "money":
|
|
1365
|
-
|
|
1206
|
+
r = "金额";
|
|
1366
1207
|
break;
|
|
1367
1208
|
case "URL":
|
|
1368
|
-
|
|
1209
|
+
r = "网址";
|
|
1369
1210
|
break;
|
|
1370
1211
|
case "IP":
|
|
1371
|
-
|
|
1212
|
+
r = "IP";
|
|
1372
1213
|
break;
|
|
1373
1214
|
case "date":
|
|
1374
|
-
|
|
1215
|
+
r = "日期时间";
|
|
1375
1216
|
break;
|
|
1376
1217
|
case "number":
|
|
1377
|
-
|
|
1218
|
+
r = "数字";
|
|
1378
1219
|
break;
|
|
1379
1220
|
case "english":
|
|
1380
|
-
|
|
1221
|
+
r = "英文";
|
|
1381
1222
|
break;
|
|
1382
1223
|
case "chinese":
|
|
1383
|
-
|
|
1224
|
+
r = "中文";
|
|
1384
1225
|
break;
|
|
1385
1226
|
case "lower":
|
|
1386
|
-
|
|
1227
|
+
r = "小写";
|
|
1387
1228
|
break;
|
|
1388
1229
|
case "upper":
|
|
1389
|
-
|
|
1230
|
+
r = "大写";
|
|
1390
1231
|
break;
|
|
1391
1232
|
case "HTML":
|
|
1392
|
-
|
|
1233
|
+
r = "HTML标记";
|
|
1393
1234
|
break;
|
|
1394
1235
|
}
|
|
1395
|
-
if (!
|
|
1396
|
-
throw Error(
|
|
1397
|
-
}
|
|
1236
|
+
if (!n)
|
|
1237
|
+
throw Error(m.PARAMETER_ERROR + ":>>>不是" + r);
|
|
1398
1238
|
}
|
|
1399
1239
|
};
|
|
1400
|
-
class
|
|
1401
|
-
constructor(
|
|
1402
|
-
|
|
1403
|
-
|
|
1240
|
+
class it {
|
|
1241
|
+
constructor(e) {
|
|
1242
|
+
/**
|
|
1243
|
+
* Creates an instance of AudioPlayer.
|
|
1244
|
+
* @param {*} url
|
|
1245
|
+
*/
|
|
1246
|
+
P(this, "audio");
|
|
1247
|
+
this.audio = new Audio(), this.audio.src = e;
|
|
1404
1248
|
}
|
|
1405
1249
|
play() {
|
|
1406
1250
|
!this.muted && this.audio.play();
|
|
@@ -1411,108 +1255,88 @@ class AudioPlayer {
|
|
|
1411
1255
|
get muted() {
|
|
1412
1256
|
return this.audio.muted;
|
|
1413
1257
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* @description 设置静音状态,如果静音,autoplay属性将失效
|
|
1260
|
+
*/
|
|
1261
|
+
set muted(e) {
|
|
1262
|
+
this.audio.muted = e;
|
|
1416
1263
|
}
|
|
1417
1264
|
}
|
|
1418
|
-
class
|
|
1419
|
-
constructor(
|
|
1420
|
-
|
|
1421
|
-
el = document.querySelector("#" + el);
|
|
1422
|
-
}
|
|
1423
|
-
this.ctx = el.getContext("2d");
|
|
1265
|
+
class ot {
|
|
1266
|
+
constructor(e) {
|
|
1267
|
+
E.getDataType(e) === "String" && (e = document.querySelector("#" + e)), this.ctx = e.getContext("2d");
|
|
1424
1268
|
}
|
|
1425
|
-
drawLine(
|
|
1269
|
+
drawLine(e, n, r, a, s = {}) {
|
|
1426
1270
|
this.cxt.beginPath();
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
this.cxt.lineWidth = width;
|
|
1430
|
-
this.cxt.fillStyle = color;
|
|
1431
|
-
this.cxt.moveTo(startX, startY);
|
|
1432
|
-
this.cxt.lineTo(endX, endY);
|
|
1433
|
-
this.cxt.closePath();
|
|
1434
|
-
this.cxt.fill();
|
|
1271
|
+
const i = s.width || 1, o = s.color || "#000";
|
|
1272
|
+
this.cxt.lineWidth = i, this.cxt.fillStyle = o, this.cxt.moveTo(e, n), this.cxt.lineTo(r, a), this.cxt.closePath(), this.cxt.fill();
|
|
1435
1273
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1274
|
+
/**
|
|
1275
|
+
* 绘制圆弧
|
|
1276
|
+
* @param {*} x 圆心X坐标
|
|
1277
|
+
* @param {*} y 圆心Y坐标
|
|
1278
|
+
* @param {*} radius 半径
|
|
1279
|
+
* @param {*} startAngle 开始的弧度
|
|
1280
|
+
* @param {*} endAngle 结束的弧度
|
|
1281
|
+
* @param {*} anticlockwise true为逆时针,false为顺时针
|
|
1282
|
+
* @param {boolean} isOnlyArc
|
|
1283
|
+
* @param {boolean} isFill 是否是填充,false为绘制边框,true为绘制填充
|
|
1284
|
+
* @param {*} bgColor 圆弧的颜色
|
|
1285
|
+
* @memberof CanvasDrawer
|
|
1286
|
+
*/
|
|
1287
|
+
drawArc(e, n, r, a, s, i, o, c) {
|
|
1288
|
+
o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, r, g.degreesToRadians(a), g.degreesToRadians(s), i), this.cxt.closePath(), this.cxt.fill()) : (this.cxt.strokeStyle = c, this.cxt.beginPath(), this.cxt.arc(e, n, r, g.degreesToRadians(a), g.degreesToRadians(s), i), this.cxt.stroke());
|
|
1449
1289
|
}
|
|
1450
1290
|
}
|
|
1451
|
-
function
|
|
1291
|
+
function k() {
|
|
1452
1292
|
}
|
|
1453
|
-
Object.assign(
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
if (this.
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
},
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
if (this.
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
const
|
|
1488
|
-
if (
|
|
1489
|
-
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
},
|
|
1493
|
-
dispatchEvent(event) {
|
|
1494
|
-
if (this._listeners === void 0)
|
|
1495
|
-
return;
|
|
1496
|
-
const listeners = this._listeners;
|
|
1497
|
-
const listenerArray = listeners[event.type];
|
|
1498
|
-
if (listenerArray !== void 0) {
|
|
1499
|
-
event.target = this;
|
|
1500
|
-
const array = listenerArray.slice(0);
|
|
1501
|
-
if (this._mutex[event.type]) {
|
|
1502
|
-
const find = array.find((item) => item === this._mutex[event.type]);
|
|
1503
|
-
find.call(this._context || this, event);
|
|
1293
|
+
Object.assign(k.prototype, {
|
|
1294
|
+
/**
|
|
1295
|
+
* 添加监听器
|
|
1296
|
+
* @param type{string}
|
|
1297
|
+
* @param listener{function}
|
|
1298
|
+
* @param mutexStatus{boolean}
|
|
1299
|
+
*/
|
|
1300
|
+
addEventListener(t, e, n, r = !1) {
|
|
1301
|
+
this._listeners === void 0 && (this._listeners = {}), this._mutex = this._mutex || {}, this._context = n;
|
|
1302
|
+
const a = this._mutex, s = this._listeners;
|
|
1303
|
+
return s[t] === void 0 && (s[t] = []), s[t].indexOf(e) === -1 && (r && (a[t] = e), s[t].push(e)), this;
|
|
1304
|
+
},
|
|
1305
|
+
hasEventListener(t, e) {
|
|
1306
|
+
if (this._listeners === void 0) return !1;
|
|
1307
|
+
const n = this._listeners;
|
|
1308
|
+
return n[t] !== void 0 && n[t].indexOf(e) !== -1;
|
|
1309
|
+
},
|
|
1310
|
+
removeEventListener(t, e) {
|
|
1311
|
+
if (this._listeners === void 0) return;
|
|
1312
|
+
const r = this._listeners[t];
|
|
1313
|
+
if (this._mutex[t] === e && (this._mutex[t] = null), r !== void 0) {
|
|
1314
|
+
const a = r.map((s) => s.toString()).indexOf(e.toString());
|
|
1315
|
+
a !== -1 && r.splice(a, 1);
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
/**
|
|
1319
|
+
* 派发事件
|
|
1320
|
+
* @param event{{type: string, message: {}}}
|
|
1321
|
+
*/
|
|
1322
|
+
dispatchEvent(t) {
|
|
1323
|
+
if (this._listeners === void 0) return;
|
|
1324
|
+
const n = this._listeners[t.type];
|
|
1325
|
+
if (n !== void 0) {
|
|
1326
|
+
t.target = this;
|
|
1327
|
+
const r = n.slice(0);
|
|
1328
|
+
if (this._mutex[t.type]) {
|
|
1329
|
+
r.find((s) => s === this._mutex[t.type]).call(this._context || this, t);
|
|
1504
1330
|
return;
|
|
1505
1331
|
}
|
|
1506
|
-
for (let
|
|
1507
|
-
|
|
1508
|
-
}
|
|
1332
|
+
for (let a = 0, s = r.length; a < s; a++)
|
|
1333
|
+
r[a].call(this._context || this, t);
|
|
1509
1334
|
}
|
|
1510
1335
|
},
|
|
1511
1336
|
removeAllListener() {
|
|
1512
1337
|
this._mutex = {};
|
|
1513
|
-
for (const
|
|
1514
|
-
this._listeners[
|
|
1515
|
-
}
|
|
1338
|
+
for (const t in this._listeners)
|
|
1339
|
+
this._listeners[t] = [];
|
|
1516
1340
|
}
|
|
1517
1341
|
});
|
|
1518
1342
|
Object.assign(Map.prototype, {
|
|
@@ -1529,223 +1353,202 @@ Object.assign(Map.prototype, {
|
|
|
1529
1353
|
return Array.from(Map.prototype.entries.call(this));
|
|
1530
1354
|
}
|
|
1531
1355
|
});
|
|
1532
|
-
function
|
|
1356
|
+
function U() {
|
|
1533
1357
|
return /* @__PURE__ */ new Map();
|
|
1534
1358
|
}
|
|
1535
|
-
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
}
|
|
1541
|
-
});
|
|
1542
|
-
return hashMap;
|
|
1359
|
+
U.fromEntries = function(t = []) {
|
|
1360
|
+
const e = new U();
|
|
1361
|
+
return t.forEach((n) => {
|
|
1362
|
+
Array.isArray(n) && n.length === 2 && e.set(n[0], n[1]);
|
|
1363
|
+
}), e;
|
|
1543
1364
|
};
|
|
1544
|
-
class
|
|
1545
|
-
constructor(
|
|
1546
|
-
super();
|
|
1547
|
-
this.maxCheckTimes = 10;
|
|
1548
|
-
this.url = url;
|
|
1549
|
-
this.checkTimes = 0;
|
|
1550
|
-
this.connectStatus = false;
|
|
1551
|
-
this.connect();
|
|
1552
|
-
this.connCheckStatus(this.maxCheckTimes);
|
|
1553
|
-
WebSocketClient.instance = this;
|
|
1365
|
+
class y extends k {
|
|
1366
|
+
constructor(e = "ws://127.0.0.1:10088") {
|
|
1367
|
+
super(), this.maxCheckTimes = 10, this.url = e, this.checkTimes = 0, this.connectStatus = !1, this.connect(), this.connCheckStatus(this.maxCheckTimes), y.instance = this;
|
|
1554
1368
|
}
|
|
1555
1369
|
connect() {
|
|
1556
|
-
this.disconnect()
|
|
1557
|
-
if (this.url) {
|
|
1370
|
+
if (this.disconnect(), this.url)
|
|
1558
1371
|
try {
|
|
1559
|
-
console.info("
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
type: EventType.WEB_SOCKET_CONNECT,
|
|
1566
|
-
message
|
|
1372
|
+
if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
|
|
1373
|
+
const e = this;
|
|
1374
|
+
this.client.onopen = function(n) {
|
|
1375
|
+
e.dispatchEvent({
|
|
1376
|
+
type: v.WEB_SOCKET_CONNECT,
|
|
1377
|
+
message: n
|
|
1567
1378
|
});
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
type: EventType.WEB_SOCKET_MESSAGE,
|
|
1573
|
-
message
|
|
1379
|
+
}, this.client.onmessage = function(n) {
|
|
1380
|
+
e.connectStatus = !0, e.dispatchEvent({
|
|
1381
|
+
type: v.WEB_SOCKET_MESSAGE,
|
|
1382
|
+
message: n
|
|
1574
1383
|
});
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
message
|
|
1384
|
+
}, this.client.onclose = function(n) {
|
|
1385
|
+
e.dispatchEvent({
|
|
1386
|
+
type: v.WEB_SOCKET_CLOSE,
|
|
1387
|
+
message: n
|
|
1580
1388
|
});
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
});
|
|
1588
|
-
};
|
|
1589
|
-
}
|
|
1389
|
+
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(n) {
|
|
1390
|
+
e.dispatchEvent({
|
|
1391
|
+
type: v.WEB_SOCKET_ERROR,
|
|
1392
|
+
message: n
|
|
1393
|
+
});
|
|
1394
|
+
});
|
|
1590
1395
|
}
|
|
1591
|
-
} catch (
|
|
1592
|
-
console.error("
|
|
1396
|
+
} catch (e) {
|
|
1397
|
+
console.error("创建ws连接失败" + this.url + ":" + e);
|
|
1593
1398
|
}
|
|
1594
|
-
}
|
|
1595
1399
|
}
|
|
1596
1400
|
disconnect() {
|
|
1597
|
-
if (this.client)
|
|
1401
|
+
if (this.client)
|
|
1598
1402
|
try {
|
|
1599
|
-
console.log("ws
|
|
1600
|
-
|
|
1601
|
-
this.client = null;
|
|
1602
|
-
} catch (ex) {
|
|
1403
|
+
console.log("ws断开连接" + this.url), this.client.close(), this.client = null;
|
|
1404
|
+
} catch {
|
|
1603
1405
|
this.client = null;
|
|
1604
1406
|
}
|
|
1605
|
-
}
|
|
1606
1407
|
}
|
|
1607
|
-
connCheckStatus(
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
setTimeout(() => {
|
|
1611
|
-
this.checkTimes++;
|
|
1612
|
-
if (this.client && this.client.readyState !== 0 && this.client.readyState !== 1) {
|
|
1613
|
-
this.connect();
|
|
1614
|
-
}
|
|
1615
|
-
this.connCheckStatus(times);
|
|
1408
|
+
connCheckStatus(e) {
|
|
1409
|
+
this.checkTimes > e || setTimeout(() => {
|
|
1410
|
+
this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(e);
|
|
1616
1411
|
}, 2e3);
|
|
1617
1412
|
}
|
|
1618
|
-
send(
|
|
1619
|
-
|
|
1620
|
-
this.client.send(message);
|
|
1621
|
-
return true;
|
|
1622
|
-
}
|
|
1623
|
-
console.error(this.url + "\u6D88\u606F\u53D1\u9001\u5931\u8D25\uFF1A" + message);
|
|
1624
|
-
return false;
|
|
1413
|
+
send(e) {
|
|
1414
|
+
return this.client && this.client.readyState === 1 ? (this.client.send(e), !0) : (console.error(this.url + "消息发送失败:" + e), !1);
|
|
1625
1415
|
}
|
|
1626
1416
|
heartbeat() {
|
|
1627
1417
|
setTimeout(() => {
|
|
1628
|
-
|
|
1629
|
-
this.send("HeartBeat");
|
|
1630
|
-
}
|
|
1631
|
-
console.log("HeartBeat," + this.url);
|
|
1632
|
-
setTimeout(this.heartbeat, 3e4);
|
|
1418
|
+
this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
|
|
1633
1419
|
}, 1e3);
|
|
1634
1420
|
}
|
|
1635
1421
|
static getInstance() {
|
|
1636
|
-
|
|
1637
|
-
return WebSocketClient.instance;
|
|
1638
|
-
} else {
|
|
1639
|
-
return Object.freeze(new WebSocketClient());
|
|
1640
|
-
}
|
|
1422
|
+
return y.instance ? y.instance : Object.freeze(new y());
|
|
1641
1423
|
}
|
|
1642
1424
|
static get _instance() {
|
|
1643
1425
|
return this.getInstance();
|
|
1644
1426
|
}
|
|
1645
1427
|
}
|
|
1646
|
-
class
|
|
1647
|
-
constructor(
|
|
1648
|
-
this.cacheType =
|
|
1649
|
-
if (type === 1) {
|
|
1428
|
+
class ct {
|
|
1429
|
+
constructor(e = 1) {
|
|
1430
|
+
if (this.cacheType = e, e === 1)
|
|
1650
1431
|
this.storage = window.localStorage;
|
|
1651
|
-
|
|
1432
|
+
else if (e === 2)
|
|
1652
1433
|
this.storage = window.sessionStorage;
|
|
1653
|
-
|
|
1654
|
-
throw new Error(
|
|
1655
|
-
}
|
|
1434
|
+
else
|
|
1435
|
+
throw new Error(m.PARAMETER_ERROR);
|
|
1656
1436
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1437
|
+
/**
|
|
1438
|
+
* 设置带过期时间的LocalStorage
|
|
1439
|
+
* @param key 缓存关键字
|
|
1440
|
+
* @param value 缓存对象,可以是任意类型
|
|
1441
|
+
* @param expired 以秒为单位,默认为1小时
|
|
1442
|
+
* @returns {Object}
|
|
1443
|
+
*/
|
|
1444
|
+
setItem(e, n, r) {
|
|
1445
|
+
const a = { key: e, value: n };
|
|
1659
1446
|
if (this.cacheType === 1) {
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1662
|
-
tempObj.expired = currTime + expired * 1e3;
|
|
1663
|
-
}
|
|
1447
|
+
const s = Date.now();
|
|
1448
|
+
r && (a.expired = s + r * 1e3);
|
|
1664
1449
|
}
|
|
1665
|
-
this.storage[
|
|
1666
|
-
return tempObj;
|
|
1450
|
+
return this.storage[e] = JSON.stringify(a), a;
|
|
1667
1451
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1452
|
+
/***
|
|
1453
|
+
* 获取带过期时间的缓存
|
|
1454
|
+
* @param key
|
|
1455
|
+
* @returns {null|*}
|
|
1456
|
+
*/
|
|
1457
|
+
getItem(e) {
|
|
1458
|
+
const n = this.storage.getItem(e) || null, r = JSON.parse(n) || {};
|
|
1671
1459
|
if (this.cacheType === 1) {
|
|
1672
|
-
const
|
|
1673
|
-
if (Date.now() >
|
|
1674
|
-
this.remove(
|
|
1675
|
-
return null;
|
|
1676
|
-
}
|
|
1460
|
+
const a = r.expired || Date.now();
|
|
1461
|
+
if (Date.now() > a)
|
|
1462
|
+
return this.remove(e), null;
|
|
1677
1463
|
}
|
|
1678
|
-
return
|
|
1464
|
+
return r.value;
|
|
1679
1465
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1466
|
+
/**
|
|
1467
|
+
* 移除指定缓存
|
|
1468
|
+
* @param keys
|
|
1469
|
+
*/
|
|
1470
|
+
remove(e) {
|
|
1471
|
+
e && (e.indexOf(",") > -1 ? e.split(",").forEach((n) => {
|
|
1472
|
+
this.storage.removeItem(n);
|
|
1473
|
+
}) : this.storage.removeItem(e));
|
|
1690
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* 移出全部缓存
|
|
1477
|
+
*/
|
|
1691
1478
|
clear() {
|
|
1692
1479
|
this.storage.clear();
|
|
1693
1480
|
}
|
|
1694
1481
|
}
|
|
1695
|
-
class
|
|
1696
|
-
constructor(
|
|
1697
|
-
this.magnification =
|
|
1482
|
+
class lt {
|
|
1483
|
+
constructor(e = 1) {
|
|
1484
|
+
this.magnification = e;
|
|
1698
1485
|
}
|
|
1486
|
+
// 获取系统类型
|
|
1699
1487
|
_getSystem() {
|
|
1700
|
-
var
|
|
1701
|
-
if (
|
|
1702
|
-
return
|
|
1703
|
-
}
|
|
1488
|
+
var e = navigator.userAgent.toLowerCase();
|
|
1489
|
+
if (e.indexOf("windows") >= 0)
|
|
1490
|
+
return !0;
|
|
1704
1491
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
}
|
|
1492
|
+
// 获取页面缩放比例
|
|
1493
|
+
// _getDevicePixelRatio() {
|
|
1494
|
+
// let t = this;
|
|
1495
|
+
// }
|
|
1496
|
+
// 监听方法兼容写法
|
|
1497
|
+
_addHandler(e, n, r) {
|
|
1498
|
+
e.addEventListener ? e.addEventListener(n, r, !1) : e.attachEvent ? e.attachEvent("on" + n, r) : e["on" + n] = r;
|
|
1713
1499
|
}
|
|
1500
|
+
// 校正浏览器缩放比例
|
|
1714
1501
|
_correct() {
|
|
1715
|
-
let
|
|
1716
|
-
if (typeof
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
}
|
|
1723
|
-
if (pageWidth <= 750) {
|
|
1724
|
-
const baseSize = 75;
|
|
1725
|
-
const scale = document.documentElement.clientWidth / pageWidth;
|
|
1726
|
-
document.documentElement.style.fontSize = this.magnification * baseSize * Math.min(scale, 2) + "px";
|
|
1727
|
-
} else if (pageWidth > 750 && pageWidth <= 1200) {
|
|
1728
|
-
const baseSize = 85;
|
|
1729
|
-
const scale = document.documentElement.clientWidth / pageWidth;
|
|
1730
|
-
document.documentElement.style.fontSize = this.magnification * baseSize * Math.min(scale, 2) + "px";
|
|
1502
|
+
let e = window.innerWidth;
|
|
1503
|
+
if (typeof e != "number" && (document.compatMode == "CSS1Compat" ? e = document.documentElement.clientWidth : e = document.body.clientWidth), e <= 750) {
|
|
1504
|
+
const r = document.documentElement.clientWidth / e;
|
|
1505
|
+
document.documentElement.style.fontSize = this.magnification * 75 * Math.min(r, 2) + "px";
|
|
1506
|
+
} else if (e > 750 && e <= 1200) {
|
|
1507
|
+
const r = document.documentElement.clientWidth / e;
|
|
1508
|
+
document.documentElement.style.fontSize = this.magnification * 85 * Math.min(r, 2) + "px";
|
|
1731
1509
|
} else {
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
document.documentElement.style.fontSize = this.magnification * baseSize * Math.min(scale, 2) + "px";
|
|
1510
|
+
const r = document.documentElement.clientWidth / 1920;
|
|
1511
|
+
document.documentElement.style.fontSize = this.magnification * 100 * Math.min(r, 2) + "px";
|
|
1735
1512
|
}
|
|
1736
1513
|
}
|
|
1514
|
+
// 监听页面缩放
|
|
1737
1515
|
_watch() {
|
|
1738
|
-
let
|
|
1739
|
-
|
|
1740
|
-
|
|
1516
|
+
let e = this;
|
|
1517
|
+
e._addHandler(window, "resize", function() {
|
|
1518
|
+
e._correct();
|
|
1741
1519
|
});
|
|
1742
1520
|
}
|
|
1521
|
+
// 初始化页面比例
|
|
1743
1522
|
init() {
|
|
1744
|
-
let
|
|
1745
|
-
|
|
1746
|
-
t._correct();
|
|
1747
|
-
t._watch();
|
|
1748
|
-
}
|
|
1523
|
+
let e = this;
|
|
1524
|
+
e._getSystem() && (e._correct(), e._watch());
|
|
1749
1525
|
}
|
|
1750
1526
|
}
|
|
1751
|
-
export {
|
|
1527
|
+
export {
|
|
1528
|
+
Y as AnimateUtils,
|
|
1529
|
+
Q as ArrayUtils,
|
|
1530
|
+
at as AssertUtils,
|
|
1531
|
+
it as AudioPlayer,
|
|
1532
|
+
X as BrowserUtils,
|
|
1533
|
+
ot as CanvasDrawer,
|
|
1534
|
+
Z as Cookie,
|
|
1535
|
+
tt as CoordsUtils,
|
|
1536
|
+
et as DateUtils,
|
|
1537
|
+
lt as DevicePixelRatio,
|
|
1538
|
+
nt as DomUtils,
|
|
1539
|
+
m as ErrorType,
|
|
1540
|
+
k as EventDispatcher,
|
|
1541
|
+
v as EventType,
|
|
1542
|
+
rt as FileUtils,
|
|
1543
|
+
j as GeoUtils,
|
|
1544
|
+
J as GraphicType,
|
|
1545
|
+
U as HashMap,
|
|
1546
|
+
K as LayerType,
|
|
1547
|
+
g as MathUtils,
|
|
1548
|
+
V as MeasureMode,
|
|
1549
|
+
st as OptimizeUtils,
|
|
1550
|
+
q as StringUtils,
|
|
1551
|
+
E as Utils,
|
|
1552
|
+
y as WebSocketClient,
|
|
1553
|
+
ct as WebStorage
|
|
1554
|
+
};
|