Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
55378da4
Commit
55378da4
authored
May 19, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加手机号登录组件
parent
87515a3b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
179 additions
and
38 deletions
+179
-38
LoginSms.jsx
src/pages/user/login/components/Login/LoginSms.jsx
+64
-0
index.jsx
src/pages/user/login/index.jsx
+50
-38
style.less
src/pages/user/login/style.less
+45
-0
login.js
src/services/login.js
+3
-0
validator.js
src/utils/validator.js
+17
-0
No files found.
src/pages/user/login/components/Login/LoginSms.jsx
0 → 100644
View file @
55378da4
import
React
,
{
useRef
,
forwardRef
}
from
'
react
'
;
import
{
Form
,
Input
,
Row
,
Col
,
Button
}
from
'
antd
'
;
import
{
getSMSCaptcha
}
from
'
@/services/login
'
;
import
{
getDefaultRule
}
from
'
@/utils/validator
'
;
import
styles
from
'
../../style.less
'
;
const
FormItem
=
Form
.
Item
;
const
LoginSMS
=
forwardRef
((
props
,
ref
)
=>
{
const
refPhone
=
useRef
();
const
onFinish
=
({
phone
,
code
})
=>
{
const
{
dispatch
}
=
props
;
dispatch
({
type
:
'
login/login
'
,
payload
:
{
username
:
phone
,
password
:
code
,
tenantId
:
560761
,
source
:
1
},
});
};
const
onGetCaptcha
=
async
()
=>
{
console
.
log
(
'
this.refPhone.current :>>
'
,
refPhone
);
// await getSMSCaptcha({
// phone: '',
// tenantId: 560761,
// source: 1,
// });
};
return
(
<
Form
onFinish=
{
onFinish
}
name=
"horizontal_login"
layout=
"inline"
>
<
FormItem
label=
""
ref=
{
refPhone
}
name=
"phone"
rules=
{
[
getDefaultRule
(
'
请输入手机号!
'
)]
}
>
<
Input
placeholder=
"请输入手机号"
prefix=
"+86"
maxLength=
{
11
}
className=
{
styles
.
txt
}
allowClear
/>
</
FormItem
>
<
FormItem
label=
""
name=
"code"
rules=
{
[
getDefaultRule
(
'
请输入验证码!
'
)]
}
>
<
Row
>
<
Col
span=
{
16
}
>
<
Input
placeholder=
"请输入验证码"
maxLength=
{
6
}
className=
{
styles
.
txt
}
allowClear
/>
</
Col
>
<
Col
span=
{
8
}
>
<
Button
type=
"primary"
onClick=
{
onGetCaptcha
}
className=
{
styles
.
btnCode
}
>
获取验证码
</
Button
>
</
Col
>
</
Row
>
</
FormItem
>
<
Button
type=
"primary"
htmlType=
"submit"
size=
"large"
className=
{
styles
.
btnSubmit
}
loading=
{
props
.
submitting
}
>
登录
</
Button
>
</
Form
>
);
});
export
default
LoginSMS
;
src/pages/user/login/index.jsx
View file @
55378da4
import
{
Alert
}
from
'
antd
'
;
import
{
Alert
,
Tabs
,
Form
,
Input
,
Row
,
Col
,
Button
}
from
'
antd
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
{
connect
}
from
'
dva
'
;
import
{
connect
}
from
'
dva
'
;
// import { getSMSCaptcha } from '@/services/login';
import
LoginComponents
from
'
./components/Login
'
;
import
LoginComponents
from
'
./components/Login
'
;
// import { getDefaultRule } from '@/utils/validator';
import
styles
from
'
./style.less
'
;
import
styles
from
'
./style.less
'
;
import
LoginSMS
from
'
./components/Login/LoginSms
'
;
const
{
UserName
,
Password
,
Submit
}
=
LoginComponents
;
const
{
UserName
,
Password
,
Submit
}
=
LoginComponents
;
// const FormItem = Form.Item;
@
connect
(({
login
,
loading
})
=>
({
@
connect
(({
login
,
loading
})
=>
({
userLogin
:
login
,
userLogin
:
login
,
...
@@ -39,6 +43,8 @@ class Login extends Component {
...
@@ -39,6 +43,8 @@ class Login extends Component {
const
{
status
}
=
userLogin
;
const
{
status
}
=
userLogin
;
return
(
return
(
<
div
className=
{
styles
.
main
}
>
<
div
className=
{
styles
.
main
}
>
<
Tabs
defaultActiveKey=
"1"
destroyInactiveTabPane
>
<
Tabs
.
TabPane
tab=
"账号密码登录"
key=
"1"
>
<
LoginComponents
<
LoginComponents
onSubmit=
{
this
.
handleSubmit
}
onSubmit=
{
this
.
handleSubmit
}
onCreate=
{
form
=>
{
onCreate=
{
form
=>
{
...
@@ -75,8 +81,14 @@ class Login extends Component {
...
@@ -75,8 +81,14 @@ class Login extends Component {
}
}
}
}
}
}
/>
/>
<
Submit
loading=
{
submitting
}
>
登录
</
Submit
>
<
Submit
loading=
{
submitting
}
>
登录
</
Submit
>
</
LoginComponents
>
</
LoginComponents
>
</
Tabs
.
TabPane
>
<
Tabs
.
TabPane
tab=
"手机号登录"
key=
"2"
>
<
LoginSMS
loading=
{
submitting
}
dispatch=
{
this
.
props
.
dispatch
}
/>
</
Tabs
.
TabPane
>
</
Tabs
>
</
div
>
</
div
>
);
);
}
}
...
...
src/pages/user/login/style.less
View file @
55378da4
...
@@ -35,5 +35,50 @@
...
@@ -35,5 +35,50 @@
width: 100%;
width: 100%;
margin-top: 24px;
margin-top: 24px;
}
}
.ant-tabs-tab {
font-size: 16px;
}
}
.ant-tabs-top > .ant-tabs-nav::before {
border-bottom: 1px solid #ddd;
}
.ant-form-inline .ant-form-item-with-help {
margin-bottom: 0;
}
.ant-form-item-control {
min-height: 65px;
}
.ant-form-item {
width: 100%;
}
.ant-input {
padding-left: 4px !important;
}
}
}
.txt {
position: relative;
display: inline-flex;
box-sizing: border-box;
width: 100%;
min-width: 0;
padding: 6.5px 11px;
color: rgba(0, 0, 0, 0.85);
font-size: 16px;
line-height: 1.5715;
background-color: #fff;
background-image: none;
border: 1px solid #d9d9d9;
border-radius: 0;
transition: all 0.3s;
}
.btnCode {
box-sizing: border-box;
width: 100%;
height: 100%;
border: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.btnSubmit {
width: 100%;
}
}
src/services/login.js
View file @
55378da4
...
@@ -11,6 +11,9 @@ export async function fakeAccountLogin(params) {
...
@@ -11,6 +11,9 @@ export async function fakeAccountLogin(params) {
export
async
function
getFakeCaptcha
(
mobile
)
{
export
async
function
getFakeCaptcha
(
mobile
)
{
return
request
(
`/v2/user/captcha?mobile=
${
mobile
}
`
);
return
request
(
`/v2/user/captcha?mobile=
${
mobile
}
`
);
}
}
export
async
function
getSMSCaptcha
(
data
)
{
return
request
.
post
(
'
/v2/sms/send
'
,
{
data
});
}
export
async
function
getResFreshToen
(
token
)
{
export
async
function
getResFreshToen
(
token
)
{
return
request
(
`/v2/oauth/refreshtoken?refreshtoken=
${
token
}
`
);
return
request
(
`/v2/oauth/refreshtoken?refreshtoken=
${
token
}
`
);
}
}
...
...
src/utils/validator.js
View file @
55378da4
...
@@ -435,3 +435,20 @@ export function isCheckPriceTwoDecimal(rule, value, callback) {
...
@@ -435,3 +435,20 @@ export function isCheckPriceTwoDecimal(rule, value, callback) {
callback
();
callback
();
}
}
}
}
// 获取默认校验规则
export
const
getDefaultRule
=
data
=>
{
const
isString
=
typeof
data
===
'
string
'
;
if
(
isString
)
{
return
{
required
:
true
,
message
:
data
,
};
}
return
Object
.
assign
(
{
required
:
true
,
},
data
,
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment