js_ryl_v3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +775 -0
  2. package/dist/base64Img/index.d.ts +5 -0
  3. package/dist/base64Img/index.js +50 -0
  4. package/dist/cookie/index.d.ts +14 -0
  5. package/dist/cookie/index.js +39 -0
  6. package/dist/copy/index.d.ts +9 -0
  7. package/dist/copy/index.js +18 -0
  8. package/dist/deepCopy/index.d.ts +1 -0
  9. package/dist/deepCopy/index.js +28 -0
  10. package/dist/downExcel/index.d.ts +5 -0
  11. package/dist/downExcel/index.js +43 -0
  12. package/dist/emoji/index.d.ts +1 -0
  13. package/dist/emoji/index.js +64 -0
  14. package/dist/emojiToUnicode/index.d.ts +1 -0
  15. package/dist/emojiToUnicode/index.js +8 -0
  16. package/dist/esm/base64Img/index.d.ts +5 -0
  17. package/dist/esm/base64Img/index.js +47 -0
  18. package/dist/esm/cookie/index.d.ts +14 -0
  19. package/dist/esm/cookie/index.js +37 -0
  20. package/dist/esm/copy/index.d.ts +9 -0
  21. package/dist/esm/copy/index.js +15 -0
  22. package/dist/esm/deepCopy/index.d.ts +1 -0
  23. package/dist/esm/deepCopy/index.js +25 -0
  24. package/dist/esm/downExcel/index.d.ts +5 -0
  25. package/dist/esm/downExcel/index.js +7 -0
  26. package/dist/esm/emoji/index.d.ts +1 -0
  27. package/dist/esm/emoji/index.js +61 -0
  28. package/dist/esm/emojiToUnicode/index.d.ts +1 -0
  29. package/dist/esm/emojiToUnicode/index.js +5 -0
  30. package/dist/esm/filterTable/index.d.ts +5 -0
  31. package/dist/esm/filterTable/index.js +21 -0
  32. package/dist/esm/flyToCart/index.d.ts +5 -0
  33. package/dist/esm/flyToCart/index.js +47 -0
  34. package/dist/esm/function/index.d.ts +11 -0
  35. package/dist/esm/function/index.js +23 -0
  36. package/dist/esm/getMonthDays/index.d.ts +1 -0
  37. package/dist/esm/getMonthDays/index.js +4 -0
  38. package/dist/esm/getParamsUtil/index.d.ts +12 -0
  39. package/dist/esm/getParamsUtil/index.js +85 -0
  40. package/dist/esm/highLight/index.d.ts +1 -0
  41. package/dist/esm/highLight/index.js +7 -0
  42. package/dist/esm/index.d.ts +17 -0
  43. package/dist/esm/index.js +17 -0
  44. package/dist/esm/number/index.d.ts +8 -0
  45. package/dist/esm/number/index.js +160 -0
  46. package/dist/esm/reg/index.d.ts +11 -0
  47. package/dist/esm/reg/index.js +35 -0
  48. package/dist/esm/time/index.d.ts +8 -0
  49. package/dist/esm/time/index.js +78 -0
  50. package/dist/esm/verCode/index.d.ts +6 -0
  51. package/dist/esm/verCode/index.js +37 -0
  52. package/dist/filterTable/index.d.ts +5 -0
  53. package/dist/filterTable/index.js +24 -0
  54. package/dist/flyToCart/index.d.ts +5 -0
  55. package/dist/flyToCart/index.js +50 -0
  56. package/dist/function/index.d.ts +11 -0
  57. package/dist/function/index.js +25 -0
  58. package/dist/getMonthDays/index.d.ts +1 -0
  59. package/dist/getMonthDays/index.js +7 -0
  60. package/dist/getParamsUtil/index.d.ts +12 -0
  61. package/dist/getParamsUtil/index.js +87 -0
  62. package/dist/highLight/index.d.ts +1 -0
  63. package/dist/highLight/index.js +10 -0
  64. package/dist/index.d.ts +17 -0
  65. package/dist/index.js +40 -0
  66. package/dist/number/index.d.ts +8 -0
  67. package/dist/number/index.js +162 -0
  68. package/dist/reg/index.d.ts +11 -0
  69. package/dist/reg/index.js +37 -0
  70. package/dist/time/index.d.ts +8 -0
  71. package/dist/time/index.js +80 -0
  72. package/dist/verCode/index.d.ts +6 -0
  73. package/dist/verCode/index.js +39 -0
  74. package/package.json +36 -0
  75. package/src/base64Img/index.ts +66 -0
  76. package/src/cookie/index.ts +47 -0
  77. package/src/copy/index.ts +23 -0
  78. package/src/deepCopy/index.ts +26 -0
  79. package/src/downExcel/index.ts +16 -0
  80. package/src/emoji/index.ts +63 -0
  81. package/src/emojiToUnicode/index.ts +9 -0
  82. package/src/filterTable/index.ts +33 -0
  83. package/src/flyToCart/index.ts +67 -0
  84. package/src/function/index.ts +37 -0
  85. package/src/getMonthDays/index.ts +4 -0
  86. package/src/getParamsUtil/index.ts +107 -0
  87. package/src/highLight/index.ts +10 -0
  88. package/src/index.ts +17 -0
  89. package/src/number/index.ts +133 -0
  90. package/src/reg/index.ts +36 -0
  91. package/src/time/index.ts +90 -0
  92. package/src/verCode/index.ts +42 -0
@@ -0,0 +1,23 @@
1
+ const fun = {
2
+ throole(fn, delay = 500) {
3
+ let lastTime = 0;
4
+ return function (...args) {
5
+ const nowTime = Date.now();
6
+ if (nowTime - lastTime > delay) {
7
+ fn.apply(this, args);
8
+ lastTime = nowTime;
9
+ }
10
+ };
11
+ },
12
+ debounce(fn, delay = 500) {
13
+ let timer = null;
14
+ return function (...args) {
15
+ if (timer)
16
+ clearTimeout(timer);
17
+ timer = setTimeout(() => {
18
+ fn.apply(this, args);
19
+ }, delay);
20
+ };
21
+ }
22
+ };
23
+ export default fun;
@@ -0,0 +1 @@
1
+ export default function getMonthDays(year: number, month: number): number;
@@ -0,0 +1,4 @@
1
+ export default function getMonthDays(year, month) {
2
+ const thisDate = new Date(year, month, 0);
3
+ return thisDate.getDate();
4
+ }
@@ -0,0 +1,12 @@
1
+ type ParamType = 'string' | 'number' | 'boolean' | 'object';
2
+ interface ParamsObject {
3
+ [key: string]: string | string[];
4
+ }
5
+ declare const getParamsUtil: {
6
+ getParam<T = any>(name: string, url?: string, defaultValue?: T, type?: ParamType): T;
7
+ getParams(url?: string): ParamsObject;
8
+ buildQueryString(params: Record<string, any>): string;
9
+ joinParams(url: string, params: Record<string, any>): string;
10
+ removeParams(url: string, keys: string | string[]): string;
11
+ };
12
+ export default getParamsUtil;
@@ -0,0 +1,85 @@
1
+ const getParamsUtil = {
2
+ getParam(name, url, defaultValue, type) {
3
+ const params = this.getParams(url);
4
+ let value = params[name];
5
+ if (value === undefined) {
6
+ return defaultValue;
7
+ }
8
+ if (type === 'number') {
9
+ return Number(value);
10
+ }
11
+ else if (type === 'boolean') {
12
+ return (value === 'true' || value === '1');
13
+ }
14
+ else if (type === 'object') {
15
+ try {
16
+ return JSON.parse(String(value));
17
+ }
18
+ catch (e) {
19
+ return defaultValue;
20
+ }
21
+ }
22
+ return value;
23
+ },
24
+ getParams(url = window.location.href) {
25
+ const params = {};
26
+ const search = url.split('?')[1];
27
+ if (!search) {
28
+ return params;
29
+ }
30
+ const pairs = search.split('&');
31
+ pairs.forEach(pair => {
32
+ const [key, value] = pair.split('=');
33
+ if (key) {
34
+ const decodedKey = decodeURIComponent(key);
35
+ const decodedValue = value ? decodeURIComponent(value) : '';
36
+ if (params[decodedKey]) {
37
+ if (Array.isArray(params[decodedKey])) {
38
+ params[decodedKey].push(decodedValue);
39
+ }
40
+ else {
41
+ params[decodedKey] = [params[decodedKey], decodedValue];
42
+ }
43
+ }
44
+ else {
45
+ params[decodedKey] = decodedValue;
46
+ }
47
+ }
48
+ });
49
+ return params;
50
+ },
51
+ buildQueryString(params) {
52
+ const query = [];
53
+ Object.entries(params).forEach(([key, value]) => {
54
+ if (value !== undefined && value !== null) {
55
+ if (Array.isArray(value)) {
56
+ value.forEach(item => {
57
+ query.push(`${encodeURIComponent(key)}=${encodeURIComponent(item)}`);
58
+ });
59
+ }
60
+ else {
61
+ query.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
62
+ }
63
+ }
64
+ });
65
+ return query.join('&');
66
+ },
67
+ joinParams(url, params) {
68
+ const [baseUrl] = url.split('?');
69
+ const existingParams = this.getParams(url);
70
+ const mergedParams = Object.assign(Object.assign({}, existingParams), params);
71
+ const queryString = this.buildQueryString(mergedParams);
72
+ return queryString ? `${baseUrl}?${queryString}` : baseUrl;
73
+ },
74
+ removeParams(url, keys) {
75
+ const [baseUrl] = url.split('?');
76
+ const params = this.getParams(url);
77
+ const keysArray = Array.isArray(keys) ? keys : [keys];
78
+ keysArray.forEach(key => {
79
+ delete params[key];
80
+ });
81
+ const queryString = this.buildQueryString(params);
82
+ return queryString ? `${baseUrl}?${queryString}` : baseUrl;
83
+ }
84
+ };
85
+ export default getParamsUtil;
@@ -0,0 +1 @@
1
+ export default function highlight(searchName: string, backText: string, className: string): string;
@@ -0,0 +1,7 @@
1
+ export default function highlight(searchName, backText, className) {
2
+ if (!searchName)
3
+ return backText;
4
+ const escapedKeyword = searchName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
5
+ const regex = new RegExp(`(${escapedKeyword})`, 'gi');
6
+ return backText.replace(regex, `<span class="${className}">$1</span>`);
7
+ }
@@ -0,0 +1,17 @@
1
+ export { default as base64Img } from './base64Img';
2
+ export { default as cookie } from './cookie';
3
+ export { default as copy } from './copy';
4
+ export { default as deepCopy } from './deepCopy';
5
+ export { default as downExcel } from './downExcel';
6
+ export { default as emoji } from './emoji';
7
+ export { default as emojiToUnicode } from './emojiToUnicode';
8
+ export { default as filterTable } from './filterTable';
9
+ export { default as flyToCart } from './flyToCart';
10
+ export { default as fun } from './function';
11
+ export { default as getMonthDays } from './getMonthDays';
12
+ export { default as getParamsUtil } from './getParamsUtil';
13
+ export { default as highlight } from './highLight';
14
+ export { default as num } from './number';
15
+ export { default as reg } from './reg';
16
+ export { default as time } from './time';
17
+ export { default as verCode } from './verCode';
@@ -0,0 +1,17 @@
1
+ export { default as base64Img } from './base64Img';
2
+ export { default as cookie } from './cookie';
3
+ export { default as copy } from './copy';
4
+ export { default as deepCopy } from './deepCopy';
5
+ export { default as downExcel } from './downExcel';
6
+ export { default as emoji } from './emoji';
7
+ export { default as emojiToUnicode } from './emojiToUnicode';
8
+ export { default as filterTable } from './filterTable';
9
+ export { default as flyToCart } from './flyToCart';
10
+ export { default as fun } from './function';
11
+ export { default as getMonthDays } from './getMonthDays';
12
+ export { default as getParamsUtil } from './getParamsUtil';
13
+ export { default as highlight } from './highLight';
14
+ export { default as num } from './number';
15
+ export { default as reg } from './reg';
16
+ export { default as time } from './time';
17
+ export { default as verCode } from './verCode';
@@ -0,0 +1,8 @@
1
+ declare const num: {
2
+ NumFilter(v: number): number;
3
+ add(num1: number | string, num2: number | string): number;
4
+ sub(num1: number | string, num2: number | string): number;
5
+ div(num1: number | string, num2: number | string): number;
6
+ mul(num1: number | string, num2: number | string): number;
7
+ };
8
+ export default num;
@@ -0,0 +1,160 @@
1
+ function countDecimals(num) {
2
+ let len = 0;
3
+ try {
4
+ num = Number(num);
5
+ const str = num.toString().toUpperCase();
6
+ if (str.split('E').length === 2) {
7
+ let isDecimal = false;
8
+ if (str.split('.').length === 2) {
9
+ str.split('.')[1];
10
+ if (parseInt(str.split('E')[0]) !== 0) {
11
+ isDecimal = true;
12
+ }
13
+ }
14
+ const x = str.split('E');
15
+ if (isDecimal) {
16
+ len = x[0].length;
17
+ }
18
+ len -= parseInt(x[1]);
19
+ }
20
+ else if (str.split('.').length === 2) {
21
+ if (parseInt(str.split('.')[1]) !== 0) {
22
+ len = str.split('.')[1].length;
23
+ }
24
+ }
25
+ }
26
+ catch (e) {
27
+ throw e;
28
+ }
29
+ finally {
30
+ if (isNaN(len) || len < 0) {
31
+ len = 0;
32
+ }
33
+ return len;
34
+ }
35
+ }
36
+ function convertToInt(num) {
37
+ num = Number(num);
38
+ let newNum = num;
39
+ const times = countDecimals(num);
40
+ const temp_num = num.toString().toUpperCase();
41
+ if (temp_num.split('E').length === 2) {
42
+ newNum = Math.round(num * Math.pow(10, times));
43
+ }
44
+ else {
45
+ newNum = Number(temp_num.replace(".", ""));
46
+ }
47
+ return newNum;
48
+ }
49
+ function getCorrectResult(type, num1, num2, result) {
50
+ let temp_result = 0;
51
+ switch (type) {
52
+ case "add":
53
+ temp_result = num1 + num2;
54
+ break;
55
+ case "sub":
56
+ temp_result = num1 - num2;
57
+ break;
58
+ case "div":
59
+ temp_result = num1 / num2;
60
+ break;
61
+ case "mul":
62
+ temp_result = num1 * num2;
63
+ break;
64
+ }
65
+ if (Math.abs(result - temp_result) > 1) {
66
+ return temp_result;
67
+ }
68
+ if (!isLessThanTwoDecimalPlaces(result)) {
69
+ result = Number(result.toFixed(2));
70
+ }
71
+ return result;
72
+ }
73
+ function isLessThanTwoDecimalPlaces(num) {
74
+ return Math.floor(num * 100) === num * 100;
75
+ }
76
+ const num = {
77
+ NumFilter(v) {
78
+ const x = String(v).indexOf(".") + 1;
79
+ const y = String(v).length - x;
80
+ if (y > 0 && y >= 3) {
81
+ v = Math.floor(v * 100) / 100;
82
+ }
83
+ return v;
84
+ },
85
+ add(num1, num2) {
86
+ const n1 = this.NumFilter(Number(num1));
87
+ const n2 = this.NumFilter(Number(num2));
88
+ let dec1 = 0, dec2 = 0, times;
89
+ try {
90
+ dec1 = countDecimals(n1) + 1;
91
+ }
92
+ catch (e) {
93
+ dec1 = 0;
94
+ }
95
+ try {
96
+ dec2 = countDecimals(n2) + 1;
97
+ }
98
+ catch (e) {
99
+ dec2 = 0;
100
+ }
101
+ times = Math.pow(10, Math.max(dec1, dec2));
102
+ const result = (this.mul(n1, times) + this.mul(n2, times)) / times;
103
+ return getCorrectResult("add", n1, n2, result);
104
+ },
105
+ sub(num1, num2) {
106
+ const n1 = this.NumFilter(Number(num1));
107
+ const n2 = this.NumFilter(Number(num2));
108
+ let dec1 = 0, dec2 = 0, times;
109
+ try {
110
+ dec1 = countDecimals(n1) + 1;
111
+ }
112
+ catch (e) {
113
+ dec1 = 0;
114
+ }
115
+ try {
116
+ dec2 = countDecimals(n2) + 1;
117
+ }
118
+ catch (e) {
119
+ dec2 = 0;
120
+ }
121
+ times = Math.pow(10, Math.max(dec1, dec2));
122
+ const result = Number((this.mul(n1, times) - this.mul(n2, times)) / times);
123
+ return getCorrectResult("sub", n1, n2, result);
124
+ },
125
+ div(num1, num2) {
126
+ const n1 = Number(num1);
127
+ const n2 = Number(num2);
128
+ let t1 = 0, t2 = 0, dec1, dec2;
129
+ try {
130
+ t1 = countDecimals(n1);
131
+ }
132
+ catch (e) { }
133
+ try {
134
+ t2 = countDecimals(n2);
135
+ }
136
+ catch (e) { }
137
+ dec1 = convertToInt(n1);
138
+ dec2 = convertToInt(n2);
139
+ const result = this.mul((dec1 / dec2), Math.pow(10, t2 - t1));
140
+ return getCorrectResult("div", n1, n2, result);
141
+ },
142
+ mul(num1, num2) {
143
+ const n1 = Number(num1);
144
+ const n2 = Number(num2);
145
+ let times = 0;
146
+ const s1 = n1.toString();
147
+ const s2 = n2.toString();
148
+ try {
149
+ times += countDecimals(n1);
150
+ }
151
+ catch (e) { }
152
+ try {
153
+ times += countDecimals(n2);
154
+ }
155
+ catch (e) { }
156
+ const result = convertToInt(n1) * convertToInt(n2) / Math.pow(10, times);
157
+ return getCorrectResult("mul", n1, n2, result);
158
+ }
159
+ };
160
+ export default num;
@@ -0,0 +1,11 @@
1
+ declare const reg: {
2
+ Phone(value: string): boolean;
3
+ Email(value: string): boolean;
4
+ IdCard(value: string): boolean;
5
+ Common(value: string): boolean;
6
+ QQ(value: string): boolean;
7
+ Money(value: string): boolean;
8
+ imgUrl(value: string): boolean;
9
+ verChinese(value: string): boolean;
10
+ };
11
+ export default reg;
@@ -0,0 +1,35 @@
1
+ const reg = {
2
+ Phone(value) {
3
+ const regex = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
4
+ return regex.test(value);
5
+ },
6
+ Email(value) {
7
+ const regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
8
+ return regex.test(value);
9
+ },
10
+ IdCard(value) {
11
+ const regex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
12
+ return regex.test(value);
13
+ },
14
+ Common(value) {
15
+ const regex = /^[a-zA-Z0-9_]+$/;
16
+ return regex.test(value);
17
+ },
18
+ QQ(value) {
19
+ const regex = /^[1-9][0-9]{4,10}$/gim;
20
+ return regex.test(value);
21
+ },
22
+ Money(value) {
23
+ const regex = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
24
+ return regex.test(value);
25
+ },
26
+ imgUrl(value) {
27
+ const regex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
28
+ return regex.test(value);
29
+ },
30
+ verChinese(value) {
31
+ const regex = /[\u4e00-\u9fa5]/;
32
+ return regex.test(value);
33
+ }
34
+ };
35
+ export default reg;
@@ -0,0 +1,8 @@
1
+ type DateFormatType = 'yyyy-MM-dd' | 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH:mm:ss';
2
+ declare const time: {
3
+ toDate(v: number | string, type?: DateFormatType): string;
4
+ toStamp(v?: Date | string, len?: number): number;
5
+ getNow(): string;
6
+ timestampFormat(timestamp: number | string): string;
7
+ };
8
+ export default time;
@@ -0,0 +1,78 @@
1
+ function add0(m) {
2
+ return m < 10 ? '0' + m : String(m);
3
+ }
4
+ const time = {
5
+ toDate(v, type) {
6
+ let date;
7
+ if (String(v).length === 10) {
8
+ date = new Date(Number(v) * 1000);
9
+ }
10
+ else {
11
+ date = new Date(v);
12
+ }
13
+ const Y = date.getFullYear();
14
+ const M = date.getMonth() + 1;
15
+ const D = date.getDate();
16
+ const h = date.getHours();
17
+ const m = date.getMinutes();
18
+ const s = date.getSeconds();
19
+ let tim = '';
20
+ if (type === 'yyyy-MM-dd') {
21
+ tim = `${Y}-${add0(M)}-${add0(D)}`;
22
+ }
23
+ else if (type === 'yyyy-MM-dd HH:mm') {
24
+ tim = `${Y}-${add0(M)}-${add0(D)} ${add0(h)}:${add0(m)}`;
25
+ }
26
+ else {
27
+ tim = `${Y}-${add0(M)}-${add0(D)} ${add0(h)}:${add0(m)}:${add0(s)}`;
28
+ }
29
+ return tim;
30
+ },
31
+ toStamp(v = new Date(), len = 10) {
32
+ const tmp = new Date(String(v).replace(/-/g, '/')).getTime().toString();
33
+ if (len === 10) {
34
+ return parseInt(tmp.substr(0, 10));
35
+ }
36
+ return parseInt(tmp);
37
+ },
38
+ getNow() {
39
+ const ts = new Date().getTime();
40
+ return this.toDate(ts);
41
+ },
42
+ timestampFormat(timestamp) {
43
+ if (String(timestamp).length === 10) {
44
+ timestamp = Number(timestamp) * 1000;
45
+ }
46
+ function zeroize(num) {
47
+ return (String(num).length === 1 ? "0" : "") + num;
48
+ }
49
+ const curTimestamp = parseInt(String(new Date().getTime() / 1000));
50
+ const curDate = new Date(curTimestamp * 1000);
51
+ const tmDate = new Date(Number(timestamp));
52
+ const Y = tmDate.getFullYear();
53
+ const m = tmDate.getMonth() + 1;
54
+ const d = tmDate.getDate();
55
+ const H = tmDate.getHours();
56
+ const i = tmDate.getMinutes();
57
+ if (curDate.getFullYear() === Y &&
58
+ curDate.getMonth() + 1 === m &&
59
+ curDate.getDate() === d) {
60
+ return zeroize(H) + ":" + zeroize(i);
61
+ }
62
+ else {
63
+ const newDate = new Date((curTimestamp - 86400) * 1000);
64
+ if (newDate.getFullYear() === Y &&
65
+ newDate.getMonth() + 1 === m &&
66
+ newDate.getDate() === d) {
67
+ return "昨天 " + zeroize(H) + ":" + zeroize(i);
68
+ }
69
+ else if (curDate.getFullYear() === Y) {
70
+ return zeroize(m) + "/" + zeroize(d) + " " + zeroize(H) + ":" + zeroize(i);
71
+ }
72
+ else {
73
+ return Y + "/" + zeroize(m) + "/" + zeroize(d) + " " + zeroize(H) + ":" + zeroize(i);
74
+ }
75
+ }
76
+ }
77
+ };
78
+ export default time;
@@ -0,0 +1,6 @@
1
+ declare const verCode: {
2
+ PhoneCode(e: MouseEvent, ss?: number, cc?: string): void;
3
+ PhoneCodeClear(): void;
4
+ phoneCodeStatus: () => boolean;
5
+ };
6
+ export default verCode;
@@ -0,0 +1,37 @@
1
+ let phoneCodeStatus = false;
2
+ let phoneCodeTimer = null;
3
+ let phoneCodeName = '';
4
+ let phoneCodeSelf = null;
5
+ const verCode = {
6
+ PhoneCode(e, ss = 60, cc = '后重新获取') {
7
+ phoneCodeName = e.target.innerText;
8
+ phoneCodeSelf = e;
9
+ if (!phoneCodeStatus) {
10
+ phoneCodeStatus = true;
11
+ e.target.innerText = `${ss - 1}s${cc}`;
12
+ let timer = ss - 1;
13
+ phoneCodeTimer = setInterval(() => {
14
+ timer--;
15
+ if (timer <= 0) {
16
+ e.target.innerText = phoneCodeName;
17
+ this.PhoneCodeClear();
18
+ }
19
+ else {
20
+ e.target.innerText = `${timer}s${cc}`;
21
+ }
22
+ }, 1000);
23
+ }
24
+ },
25
+ PhoneCodeClear() {
26
+ phoneCodeStatus = false;
27
+ if (phoneCodeSelf) {
28
+ phoneCodeSelf.target.innerText = phoneCodeName;
29
+ }
30
+ if (phoneCodeTimer) {
31
+ clearInterval(phoneCodeTimer);
32
+ phoneCodeTimer = null;
33
+ }
34
+ },
35
+ phoneCodeStatus: () => phoneCodeStatus
36
+ };
37
+ export default verCode;
@@ -0,0 +1,5 @@
1
+ interface TableData {
2
+ [key: string]: any;
3
+ }
4
+ export default function filterTable(data: TableData[], params?: string, more?: (string | undefined | null)[]): TableData[];
5
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = filterTable;
4
+ const defaultTypes = ['', undefined, null];
5
+ function filterType(val, types) {
6
+ return types.some(v => v === val);
7
+ }
8
+ function filterTable(data, params = '--', more) {
9
+ const types = more && more.length ? [...defaultTypes, ...more] : defaultTypes;
10
+ const newArr = [];
11
+ for (const key in data) {
12
+ const obj = {};
13
+ const re = Object.entries(data[key]);
14
+ for (let i = 0; i < re.length; i++) {
15
+ const d = re[i];
16
+ if (filterType(d[1], types)) {
17
+ d[1] = params;
18
+ }
19
+ obj[d[0]] = d[1];
20
+ }
21
+ newArr.push(obj);
22
+ }
23
+ return newArr;
24
+ }
@@ -0,0 +1,5 @@
1
+ interface FlyToCartCallback {
2
+ (): void;
3
+ }
4
+ export default function flyToCart(event: MouseEvent, image: string, targets: HTMLElement, callback?: FlyToCartCallback): void;
5
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = flyToCart;
4
+ function flyToCart(event, image, targets, callback = () => { }) {
5
+ const button = event.target;
6
+ const flyEl = document.createElement('img');
7
+ flyEl.style.cssText = `position: fixed;
8
+ width: 20px;
9
+ height: 20px;
10
+ border-radius: 50%;
11
+ pointer-events: none;
12
+ transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s;
13
+ z-index: 10000;
14
+ opacity: 1;
15
+ transform-origin: center center;`;
16
+ flyEl.setAttribute('src', image);
17
+ document.body.appendChild(flyEl);
18
+ const startRect = button.getBoundingClientRect();
19
+ const startX = startRect.left + startRect.width / 2;
20
+ const startY = startRect.top + startRect.height / 2;
21
+ const cartRect = targets.getBoundingClientRect();
22
+ const endX = cartRect.left + cartRect.width / 2;
23
+ const endY = cartRect.top + cartRect.height / 2;
24
+ const controlX = (startX + endX) / 2;
25
+ const controlY = Math.min(startY, endY) - 150;
26
+ flyEl.style.left = startX + 'px';
27
+ flyEl.style.top = startY + 'px';
28
+ let t = 0;
29
+ const duration = 800;
30
+ const startTime = performance.now();
31
+ const animate = (time) => {
32
+ t = (time - startTime) / duration;
33
+ if (t > 1)
34
+ t = 1;
35
+ const x = (1 - t) * (1 - t) * startX + 2 * (1 - t) * t * controlX + t * t * endX;
36
+ const y = (1 - t) * (1 - t) * startY + 2 * (1 - t) * t * controlY + t * t * endY;
37
+ flyEl.style.left = x + 'px';
38
+ flyEl.style.top = y + 'px';
39
+ flyEl.style.transform = `scale(${1 - t * 0.7})`;
40
+ flyEl.style.opacity = `${1 - t}`;
41
+ if (t < 1) {
42
+ requestAnimationFrame(animate);
43
+ }
44
+ else {
45
+ flyEl.remove();
46
+ callback();
47
+ }
48
+ };
49
+ requestAnimationFrame(animate);
50
+ }
@@ -0,0 +1,11 @@
1
+ interface ThrottleFunction<T extends (...args: any[]) => any> {
2
+ (...args: Parameters<T>): void;
3
+ }
4
+ interface DebounceFunction<T extends (...args: any[]) => any> {
5
+ (...args: Parameters<T>): void;
6
+ }
7
+ declare const fun: {
8
+ throole<T extends (...args: any[]) => any>(fn: T, delay?: number): ThrottleFunction<T>;
9
+ debounce<T extends (...args: any[]) => any>(fn: T, delay?: number): DebounceFunction<T>;
10
+ };
11
+ export default fun;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fun = {
4
+ throole(fn, delay = 500) {
5
+ let lastTime = 0;
6
+ return function (...args) {
7
+ const nowTime = Date.now();
8
+ if (nowTime - lastTime > delay) {
9
+ fn.apply(this, args);
10
+ lastTime = nowTime;
11
+ }
12
+ };
13
+ },
14
+ debounce(fn, delay = 500) {
15
+ let timer = null;
16
+ return function (...args) {
17
+ if (timer)
18
+ clearTimeout(timer);
19
+ timer = setTimeout(() => {
20
+ fn.apply(this, args);
21
+ }, delay);
22
+ };
23
+ }
24
+ };
25
+ exports.default = fun;
@@ -0,0 +1 @@
1
+ export default function getMonthDays(year: number, month: number): number;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = getMonthDays;
4
+ function getMonthDays(year, month) {
5
+ const thisDate = new Date(year, month, 0);
6
+ return thisDate.getDate();
7
+ }