@intercartx/booster-core 0.0.1-beta.27 → 0.0.1-beta.29
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/api/order/index.d.ts +1 -0
- package/dist/api/order/index.js +1 -0
- package/dist/api/order/quick.d.ts +12 -0
- package/dist/api/order/quick.js +4 -0
- package/dist/api/types.d.ts +1 -0
- package/dist/models/business/CustomInfo.js +1 -1
- package/dist/models/business/address/Address.js +2 -0
- package/dist/models/business/address/MultiRegions.d.ts +1 -0
- package/dist/models/business/address/MultiRegions.js +5 -0
- package/dist/validate/phone.js +14 -5
- package/package.json +1 -1
package/dist/api/order/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OrderProduct } from "../types";
|
|
2
|
+
export interface QuickOrderRequest {
|
|
3
|
+
products: OrderProduct;
|
|
4
|
+
confirmUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export interface QuickOrderResponse {
|
|
7
|
+
sourceToken: string;
|
|
8
|
+
newToken: string;
|
|
9
|
+
newOrderId: string;
|
|
10
|
+
newTradeId: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function apiCreateQuickOrder(token: string, body: QuickOrderRequest): Promise<QuickOrderResponse>;
|
package/dist/api/types.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class CustomInfoModel extends BusinessModel {
|
|
|
49
49
|
inputMode: 'numeric',
|
|
50
50
|
maxLength: 16,
|
|
51
51
|
...props.phone,
|
|
52
|
-
validateFn: validatePhone,
|
|
52
|
+
validateFn: (e, m) => validatePhone(`${this.phone.prefix}${e}`, m),
|
|
53
53
|
validateMessages: validateMessages.phone,
|
|
54
54
|
region: 'US'
|
|
55
55
|
});
|
|
@@ -50,6 +50,7 @@ export declare class MultiRegionsModel extends BusinessModel<MultiRegionsData> i
|
|
|
50
50
|
getFieldModel(fieldName: string): InputModel<import("../../types").FieldProps> | SelectModel<import("../../types").FieldProps> | undefined;
|
|
51
51
|
getValue(): MultiRegionsData;
|
|
52
52
|
setValue(value: MultiRegionsData): void;
|
|
53
|
+
clearErrorValues(): void;
|
|
53
54
|
validate(): boolean;
|
|
54
55
|
clearAllFields(): void;
|
|
55
56
|
}
|
|
@@ -70,6 +70,11 @@ export class MultiRegionsModel extends BusinessModel {
|
|
|
70
70
|
this.province.setValue(value.province);
|
|
71
71
|
this.zip.setValue(value.zip);
|
|
72
72
|
}
|
|
73
|
+
clearErrorValues() {
|
|
74
|
+
this.city.setError('');
|
|
75
|
+
this.province.setError('');
|
|
76
|
+
this.zip.setError('');
|
|
77
|
+
}
|
|
73
78
|
validate() {
|
|
74
79
|
return [
|
|
75
80
|
this.city.validate(),
|
package/dist/validate/phone.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parsePhoneNumber } from 'libphonenumber-js';
|
|
2
2
|
export function validatePhone(phone, validateMessages) {
|
|
3
3
|
var _a, _b;
|
|
4
|
+
console.log('phone', phone);
|
|
4
5
|
if (!phone) {
|
|
5
6
|
return (_a = validateMessages === null || validateMessages === void 0 ? void 0 : validateMessages.required) !== null && _a !== void 0 ? _a : 'Required!';
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
try {
|
|
9
|
+
// parsePhoneNumber 可以解析 E.164 格式(以 + 开头)的号码
|
|
10
|
+
// PhoneModel 会将号码格式化为 E.164 格式,所以这里可以直接验证
|
|
11
|
+
const phoneNumber = parsePhoneNumber(phone);
|
|
12
|
+
console.log('phoneNumber', phoneNumber);
|
|
13
|
+
if (phoneNumber && phoneNumber.isValid()) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
|
-
|
|
17
|
+
catch (error) {
|
|
18
|
+
// parsePhoneNumber 会抛出错误如果号码无效或格式不正确
|
|
19
|
+
}
|
|
20
|
+
return (_b = validateMessages === null || validateMessages === void 0 ? void 0 : validateMessages.invalid) !== null && _b !== void 0 ? _b : 'Invalid phone number';
|
|
12
21
|
}
|