|
@@ -8,11 +8,13 @@ import { SafetyCertificateOutlined, ExclamationCircleFilled } from '@ant-design/
|
|
|
import { useLogin2p } from '../Login2pContext'
|
|
|
import { ReactComponent as LoginMobile } from 'assets/login_mobile.svg'
|
|
|
import { ReactComponent as LoginPassword } from 'assets/login_passwode.svg'
|
|
|
-
|
|
|
import { Login2pService } from '../Login2p.service'
|
|
|
interface ISetUpPasswordProps {
|
|
|
visible: boolean
|
|
|
- onClose?: () => void
|
|
|
+ isBindMobile: number
|
|
|
+ encryptionPhone: string
|
|
|
+ phoneAreaCode: number
|
|
|
+ onCancelPassword: () => void
|
|
|
onRefresh?: () => void
|
|
|
}
|
|
|
|
|
@@ -21,7 +23,7 @@ interface ISetUpPasswordProps {
|
|
|
*/
|
|
|
const SetUpPassword: React.FC<ISetUpPasswordProps> = props => {
|
|
|
const { Option } = Select
|
|
|
- const { visible, onClose, onRefresh } = props
|
|
|
+ const { visible, isBindMobile, encryptionPhone, phoneAreaCode, onCancelPassword, onRefresh } = props
|
|
|
const [form] = Form.useForm()
|
|
|
const login2p = useLogin2p()
|
|
|
const next = new URLSearchParams(useLocation().search).get('next')
|
|
@@ -48,20 +50,34 @@ const SetUpPassword: React.FC<ISetUpPasswordProps> = props => {
|
|
|
onSuccess: result => message.success('验证码请求成功!'),
|
|
|
onError: e => message.error('验证码请求失败~')
|
|
|
})
|
|
|
- const handleToClose = () => {
|
|
|
- // onClose()
|
|
|
- }
|
|
|
+
|
|
|
+ // 点击了登录
|
|
|
const handleLoginegByCode = (value: any) => {
|
|
|
- login2p
|
|
|
- .login2pByCode(value.phone_number, value.code, next ? next : '/', wechatToken ? wechatToken : undefined)
|
|
|
- .then(r => undefined)
|
|
|
+ // 至少 6 位字符,包含字母和数字
|
|
|
+ const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{6,}$/
|
|
|
+
|
|
|
+ if (passwordRegex.test(value.password)) {
|
|
|
+ login2p.initPassword(
|
|
|
+ value.phone_number || encryptionPhone,
|
|
|
+ value.code || phoneAreaCode,
|
|
|
+ isBindMobile + '',
|
|
|
+ value.password,
|
|
|
+ next ? next : '/'
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ message.error('请设置6位以上数字字母组合')
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
const checkPhoneNumber = (phoneNumber: string) => {
|
|
|
const findItem = phoneAreaList.find(item => item.id === phoneArea)
|
|
|
return findItem ? findItem.regText.test(phoneNumber) : false
|
|
|
}
|
|
|
+
|
|
|
+ // 手机验证码
|
|
|
const getVCodeData = () => {
|
|
|
- if (!checkPhoneNumber(form.getFieldValue('phone_number'))) {
|
|
|
+ if (!checkPhoneNumber(form.getFieldValue('phone_number')) && !encryptionPhone) {
|
|
|
message.warning('格式错误,请输入正确的手机号码')
|
|
|
return
|
|
|
}
|
|
@@ -75,46 +91,56 @@ const SetUpPassword: React.FC<ISetUpPasswordProps> = props => {
|
|
|
setCaptchaBtnText('获取验证码')
|
|
|
clearInterval(captchaCountdown)
|
|
|
}, 60000)
|
|
|
- getLoginCode(phoneArea.toString(), form.getFieldValue('phone_number'))
|
|
|
+ getLoginCode(
|
|
|
+ phoneArea.toString() || phoneAreaCode.toString(),
|
|
|
+ form.getFieldValue('phone_number') || encryptionPhone
|
|
|
+ )
|
|
|
+ }
|
|
|
+ // 关闭弹框事件
|
|
|
+ const closeModalHandler = () => {
|
|
|
+ onCancelPassword()
|
|
|
}
|
|
|
return (
|
|
|
- <Modal
|
|
|
- open={visible}
|
|
|
- closable={false}
|
|
|
- onCancel={handleToClose}
|
|
|
- destroyOnClose={true}
|
|
|
- maskClosable={false}
|
|
|
- footer={null}
|
|
|
- width={800}
|
|
|
- >
|
|
|
- <div className={styles['set-up-password-text']}>
|
|
|
- <ExclamationCircleFilled style={{ color: '#E37318', fontSize: 18, marginRight: 8 }} />
|
|
|
- 该账号尚未设置登录密码,请先设置登录密码
|
|
|
- </div>
|
|
|
- <div className={styles['login-content-box-set-up']}>
|
|
|
+ <Modal open={visible} closable={false} destroyOnClose={true} maskClosable={false} footer={null} width={800}>
|
|
|
+ {isBindMobile === 1 && (
|
|
|
+ <div className={styles['set-up-password-text']}>
|
|
|
+ <ExclamationCircleFilled style={{ color: '#E37318', fontSize: 18, marginRight: 8 }} />
|
|
|
+ 该账号尚未设置登录密码,请先设置登录密码
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <div className={`${styles['login-content-bg-img']} ${styles['login-content-box-set-up']} `}>
|
|
|
<div className="password-dlg-title">设置密码</div>
|
|
|
<div className={styles['login-columncenter-content']}>
|
|
|
<Form form={form} onFinish={handleLoginegByCode}>
|
|
|
- <Form.Item style={{ marginBottom: '5px' }}>
|
|
|
- <Form.Item name="phone_number" rules={[{ required: true, message: 'Please input your phone number!' }]}>
|
|
|
- <div className={styles['input-content']}>
|
|
|
- <Select
|
|
|
- defaultValue={phoneArea}
|
|
|
- className="select-input"
|
|
|
- onChange={value => {
|
|
|
- setPhoneArea(value)
|
|
|
- }}
|
|
|
- >
|
|
|
- {phoneAreaList.map(item => (
|
|
|
- <Option value={item.id} key={item.id}>
|
|
|
- {item.optionName}
|
|
|
- </Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- <Input prefix={<LoginMobile style={{ width: 15 }} />} placeholder="请输入手机号" />
|
|
|
- </div>
|
|
|
+ {isBindMobile === 1 ? (
|
|
|
+ <div className={styles['encryption-phone-text']}>
|
|
|
+ +{phoneAreaCode}
|
|
|
+ {encryptionPhone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')}
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <Form.Item style={{ marginBottom: '5px' }}>
|
|
|
+ <Form.Item name="phone_number" rules={[{ required: true, message: 'Please input your phone number!' }]}>
|
|
|
+ <div className={styles['input-content']}>
|
|
|
+ <Select
|
|
|
+ defaultValue={phoneArea}
|
|
|
+ className="select-input"
|
|
|
+ onChange={value => {
|
|
|
+ setPhoneArea(value)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {phoneAreaList.map(item => (
|
|
|
+ <Option value={item.id} key={item.id}>
|
|
|
+ {item.optionName}
|
|
|
+ </Option>
|
|
|
+ ))}
|
|
|
+ </Select>
|
|
|
+ <Input prefix={<LoginMobile style={{ width: 15 }} />} placeholder="请输入手机号" />
|
|
|
+ </div>
|
|
|
+ </Form.Item>
|
|
|
</Form.Item>
|
|
|
- </Form.Item>
|
|
|
+ )}
|
|
|
+
|
|
|
<Form.Item style={{ marginBottom: '5px' }}>
|
|
|
<Form.Item name={'code'} rules={[{ required: true, message: 'Please input Captcha!' }]}>
|
|
|
<div className={styles['input-content']}>
|
|
@@ -142,10 +168,10 @@ const SetUpPassword: React.FC<ISetUpPasswordProps> = props => {
|
|
|
style={{ width: '100%', display: 'inline-block' }}
|
|
|
rules={[{ required: true, message: 'Please input Password!' }]}
|
|
|
>
|
|
|
- <Input
|
|
|
+ <Input.Password
|
|
|
style={{ height: 60 }}
|
|
|
prefix={<LoginPassword style={{ width: 20 }} />}
|
|
|
- placeholder="请输入密码"
|
|
|
+ placeholder="请设置登录密码(6位以上数字字母组合)"
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</div>
|
|
@@ -153,7 +179,12 @@ const SetUpPassword: React.FC<ISetUpPasswordProps> = props => {
|
|
|
</Form.Item>
|
|
|
<Form.Item>
|
|
|
<div className="password-btn-box">
|
|
|
- <Button htmlType="button" className="password-btn" style={{ color: '#faa12f' }}>
|
|
|
+ <Button
|
|
|
+ onClick={closeModalHandler}
|
|
|
+ htmlType="button"
|
|
|
+ className="password-btn"
|
|
|
+ style={{ color: '#faa12f' }}
|
|
|
+ >
|
|
|
取消
|
|
|
</Button>
|
|
|
<Button type="primary" htmlType="submit" className="password-btn">
|