message-verify 1.0.1-beta.15 → 1.0.1-beta.17
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/main.js +4 -0
- package/dist/utils/type.d.ts +2 -0
- package/dist/verify-modal.js +25 -30
- package/package.json +1 -1
- package/src/main.tsx +4 -0
- package/src/utils/type.ts +2 -0
- package/src/verify-modal.tsx +18 -21
package/dist/main.js
CHANGED
@@ -49,6 +49,10 @@ createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children:
|
|
49
49
|
},
|
50
50
|
lang: 'en',
|
51
51
|
http: axios,
|
52
|
+
myReject: () => {
|
53
|
+
},
|
54
|
+
myResolve: () => {
|
55
|
+
}
|
52
56
|
}), children: "Show verify Modal" }), _jsx("button", { onClick: () => createReLoginModal({
|
53
57
|
goLogin: () => {
|
54
58
|
console.log('goLogin');
|
package/dist/utils/type.d.ts
CHANGED
package/dist/verify-modal.js
CHANGED
@@ -11,7 +11,7 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
11
11
|
const [captchaImage, setCaptchaImage] = useState('');
|
12
12
|
const [captchCode, setCaptchCode] = useState('');
|
13
13
|
const [captchaKey, setCaptchaKey] = useState('');
|
14
|
-
const { data, http, lang, api = '/admin/sms/send', config,
|
14
|
+
const { data, http, lang, api = '/admin/sms/send', config, myResolve, myReject } = props || {};
|
15
15
|
const dataObj = JSON.parse(data || '{}');
|
16
16
|
const { mobile, verifyCodeKey } = dataObj || {};
|
17
17
|
const getKey = async () => {
|
@@ -68,36 +68,31 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
68
68
|
}, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: async (val) => {
|
69
69
|
setOtp(val);
|
70
70
|
if (val.length === 6) {
|
71
|
-
try {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
});
|
81
|
-
console.log('组件打印res', res);
|
82
|
-
const { data: { status: { code, detail } } } = res || {};
|
83
|
-
if (code !== 0) {
|
84
|
-
console.log('失败了');
|
85
|
-
const detailObj = JSON.parse(detail || '{}');
|
86
|
-
console.log('detailObj', detailObj);
|
87
|
-
message.error(detailObj?.message || t('sendFailed', lang));
|
88
|
-
setVisible(false);
|
89
|
-
return;
|
71
|
+
// try {
|
72
|
+
http({
|
73
|
+
...config,
|
74
|
+
headers: {
|
75
|
+
...http.defaults.headers.common,
|
76
|
+
'sms-code': val,
|
77
|
+
'sms-code-key': verifyCodeKey,
|
78
|
+
'Content-Type': config.headers['Content-Type'],
|
90
79
|
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
80
|
+
}).then(res => {
|
81
|
+
setVisible(false);
|
82
|
+
myResolve(res);
|
83
|
+
// return res;
|
84
|
+
}).catch(err => {
|
85
|
+
myReject(err);
|
86
|
+
});
|
87
|
+
// console.log('组件打印res', res);
|
88
|
+
// if(!res) {
|
89
|
+
// message.error('验证失败');
|
90
|
+
// } else {
|
91
|
+
// message.success('验证成功');
|
92
|
+
// }
|
93
|
+
// } catch (error: any) {
|
94
|
+
// message.error(error?.message || t('sendFailed', lang));
|
95
|
+
// }
|
101
96
|
}
|
102
97
|
} }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
|
103
98
|
_jsxs("div", { style: { marginTop: 12, display: 'flex', alignItems: 'center' }, children: [_jsx(Input, { placeholder: t('pleaseEnterPicVerifyCode', lang), onChange: (e) => {
|
package/package.json
CHANGED
package/src/main.tsx
CHANGED
package/src/utils/type.ts
CHANGED
package/src/verify-modal.tsx
CHANGED
@@ -12,7 +12,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
12
12
|
const [captchaImage, setCaptchaImage] = useState<string>('');
|
13
13
|
const [captchCode, setCaptchCode] = useState<string>('');
|
14
14
|
const [captchaKey, setCaptchaKey] = useState<string>('');
|
15
|
-
const { data, http, lang, api='/admin/sms/send', config,
|
15
|
+
const { data, http, lang, api='/admin/sms/send', config, myResolve, myReject } = props || {};
|
16
16
|
const dataObj = JSON.parse(data || '{}');
|
17
17
|
const { mobile, verifyCodeKey } = dataObj || {};
|
18
18
|
|
@@ -83,8 +83,8 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
83
83
|
onChange={async (val) => {
|
84
84
|
setOtp(val);
|
85
85
|
if (val.length === 6) {
|
86
|
-
try {
|
87
|
-
|
86
|
+
// try {
|
87
|
+
http({
|
88
88
|
...config,
|
89
89
|
headers: {
|
90
90
|
...http.defaults.headers.common,
|
@@ -92,25 +92,22 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
92
92
|
'sms-code-key': verifyCodeKey,
|
93
93
|
'Content-Type': config.headers['Content-Type'],
|
94
94
|
}
|
95
|
-
})
|
96
|
-
console.log('组件打印res', res);
|
97
|
-
const {data: {status: {code, detail}}} = res || {} as any;
|
98
|
-
if (code !== 0) {
|
99
|
-
console.log('失败了')
|
100
|
-
const detailObj = JSON.parse(detail || '{}');
|
101
|
-
console.log('detailObj', detailObj);
|
102
|
-
message.error(detailObj?.message || t('sendFailed', lang));
|
103
|
-
setVisible(false);
|
104
|
-
return;
|
105
|
-
} else {
|
106
|
-
console.log('成功了')
|
107
|
-
// message.success(t('verifySuccess', lang));
|
95
|
+
}).then(res => {
|
108
96
|
setVisible(false);
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
97
|
+
myResolve(res);
|
98
|
+
// return res;
|
99
|
+
}).catch(err => {
|
100
|
+
myReject(err);
|
101
|
+
});
|
102
|
+
// console.log('组件打印res', res);
|
103
|
+
// if(!res) {
|
104
|
+
// message.error('验证失败');
|
105
|
+
// } else {
|
106
|
+
// message.success('验证成功');
|
107
|
+
// }
|
108
|
+
// } catch (error: any) {
|
109
|
+
// message.error(error?.message || t('sendFailed', lang));
|
110
|
+
// }
|
114
111
|
}
|
115
112
|
}} />
|
116
113
|
<Button
|