@tmsfe/tms-core 0.0.200 → 0.2.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.
- package/package.json +1 -1
- package/src/index.js +15 -0
- package/src/regCheck.ts +40 -0
- package/src/request.js +1 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -56,6 +56,14 @@ import * as storage from './storage';
|
|
|
56
56
|
import * as uiUtil from './tmsuiUtils';
|
|
57
57
|
import { throttle, debounce } from './funcUtils';
|
|
58
58
|
import { formatAmount } from './priceUtils';
|
|
59
|
+
import {
|
|
60
|
+
validTaxId,
|
|
61
|
+
validPhone,
|
|
62
|
+
validName,
|
|
63
|
+
validEmail,
|
|
64
|
+
validIdNumber,
|
|
65
|
+
} from './regCheck';
|
|
66
|
+
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* @public
|
|
@@ -241,6 +249,13 @@ const api = {
|
|
|
241
249
|
/* 金额方法 */
|
|
242
250
|
formatAmount,
|
|
243
251
|
|
|
252
|
+
/* 常见正则校验 */
|
|
253
|
+
validTaxId,
|
|
254
|
+
validPhone,
|
|
255
|
+
validName,
|
|
256
|
+
validEmail,
|
|
257
|
+
validIdNumber,
|
|
258
|
+
|
|
244
259
|
/* 时间方法 */
|
|
245
260
|
groupTimeDuration,
|
|
246
261
|
formatTimeDuration,
|
package/src/regCheck.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 常见正则校验
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// 校验税号
|
|
6
|
+
function validTaxId(taxId) {
|
|
7
|
+
return /^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(taxId);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 校验电话、手机号
|
|
11
|
+
function validPhone(phone) {
|
|
12
|
+
const reg = /^(1[3456789]\d{9}|(\d{3,4}-\d{7,8}))$/;
|
|
13
|
+
return reg.test(phone);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 校验姓名只允许中英文
|
|
17
|
+
function validName(name) {
|
|
18
|
+
const reg = /^[\u4e00-\u9fa5a-zA-Z]+$/;
|
|
19
|
+
return reg.test(name);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 验证邮箱地址
|
|
23
|
+
function validEmail(email) {
|
|
24
|
+
const regExp = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/;
|
|
25
|
+
return regExp.test(email);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 匹配身份证号
|
|
29
|
+
function validIdNumber(idNumber: string): boolean {
|
|
30
|
+
const regExp = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
|
|
31
|
+
return regExp.test(idNumber);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
validTaxId,
|
|
36
|
+
validPhone,
|
|
37
|
+
validName,
|
|
38
|
+
validEmail,
|
|
39
|
+
validIdNumber,
|
|
40
|
+
};
|
package/src/request.js
CHANGED
|
@@ -574,7 +574,7 @@ export default class Request {
|
|
|
574
574
|
* @returns {Promise} 返回 wx.request 的 requestTask
|
|
575
575
|
*/
|
|
576
576
|
async createStreamRequestTask(path, params = {}) {
|
|
577
|
-
const { param = {}, method = 'POST', header = {}, callbacks = {}
|
|
577
|
+
const { param = {}, method = 'POST', header = {}, callbacks = {} } = params;
|
|
578
578
|
const requestParam = await composeParam(param, this.withAuth, this.baseParam);
|
|
579
579
|
const data = sign(requestParam, this.secretKey);
|
|
580
580
|
|
|
@@ -586,7 +586,6 @@ export default class Request {
|
|
|
586
586
|
header,
|
|
587
587
|
method,
|
|
588
588
|
data,
|
|
589
|
-
timeout,
|
|
590
589
|
enableHttp2: this.enableHttp2,
|
|
591
590
|
enableChunked: this.enableChunked,
|
|
592
591
|
responseType: this.responseType,
|