Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
linweijiong
jinfa-platform
Commits
ee6b2b19
Commit
ee6b2b19
authored
Nov 17, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 重构用户登录注册接口
parent
b8ad23c6
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
42 deletions
+25
-42
index.tsx
src/pages/user/agreement/index.tsx
+3
-4
LoginWrap.tsx
src/pages/user/components/LoginWrap.tsx
+2
-2
ScanLoginWrap.tsx
src/pages/user/components/ScanLoginWrap.tsx
+3
-3
forgetPwd.tsx
src/pages/user/forgetPwd.tsx
+3
-3
index.tsx
src/pages/user/index.tsx
+2
-2
register.tsx
src/pages/user/register.tsx
+6
-25
index.ts
src/pages/user/schema/index.ts
+3
-3
api.ts
src/services/api.ts
+2
-0
ytt.config.ts
ytt.config.ts
+1
-0
No files found.
src/pages/user/agreement/index.tsx
View file @
ee6b2b19
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
PublicApi
}
from
'@/services/api'
;
import
{
getManageContentNoticeFindAllByColumnType
}
from
'@/services/ManageV2Api'
;
import
styles
from
'./index.less'
import
Loading
from
'@/components/Loading'
;
...
...
@@ -17,10 +17,9 @@ const Agreement: React.FC<AgreementPropsType> = (props) => {
const
fetchAgreement
=
()
=>
{
let
param
=
{
columnType
:
2
columnType
:
'2'
}
//@ts-ignore
PublicApi
.
getManageContentNoticeFindAllByColumnType
(
param
).
then
(
res
=>
{
getManageContentNoticeFindAllByColumnType
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
initData
(
res
.
data
)
}
...
...
src/pages/user/components/LoginWrap.tsx
View file @
ee6b2b19
...
...
@@ -6,7 +6,7 @@ import {
LockOutlined
,
ExclamationCircleFilled
}
from
'@ant-design/icons'
;
import
{
PublicApi
}
from
'@/services/a
pi'
;
import
{
postMemberLogin
}
from
'@/services/MemberV2A
pi'
;
import
{
setAuth
,
setRouters
}
from
'@/utils/auth'
;
import
{
encryptedByAES
}
from
'@/utils/cryptoAes'
;
import
{
setUserCookie
}
from
'@/utils/siteCookie'
;
...
...
@@ -21,7 +21,7 @@ const LoginWrap: React.FC = () => {
const
finish
=
(
value
:
any
)
=>
{
value
.
password
=
encryptedByAES
(
value
.
password
)
setLoginLoading
(
true
)
PublicApi
.
postMemberLogin
(
value
).
then
(
res
=>
{
postMemberLogin
(
value
).
then
(
res
=>
{
const
{
data
,
code
}
=
res
if
(
code
===
1000
)
{
message
.
destroy
()
...
...
src/pages/user/components/ScanLoginWrap.tsx
View file @
ee6b2b19
...
...
@@ -3,7 +3,7 @@ import { message } from 'antd'
import
{
history
}
from
'umi'
;
import
{
setAuth
,
setRouters
}
from
'@/utils/auth'
;
import
QRCode
from
'qrcode'
;
import
{
PublicApi
}
from
'@/services/a
pi'
;
import
{
postMemberLoginAuthUrl
,
postMemberLoginInfo
}
from
'@/services/MemberV2A
pi'
;
const
ScanLoginWrap
:
React
.
FC
=
()
=>
{
const
{
redirect
}
=
history
.
location
.
query
...
...
@@ -43,7 +43,7 @@ const ScanLoginWrap: React.FC = () => {
}
const
AuthCode
=
()
=>
{
// /member/login/authUrl
PublicApi
.
postMemberLoginAuthUrl
({},
{
ctlType
:
'none'
}).
then
(
res
=>
{
postMemberLoginAuthUrl
({},
{
ctlType
:
'none'
}).
then
(
res
=>
{
hanleCountdown
(
res
.
data
.
authUrl
);
QRCode
.
toDataURL
(
res
.
data
.
authUrl
).
then
((
url
:
any
)
=>
{
setQrCode
(
url
)
...
...
@@ -58,7 +58,7 @@ const ScanLoginWrap: React.FC = () => {
const
loginInfo
=
(
authCode
)
=>
{
console
.
log
(
authCode
);
// return;
PublicApi
.
postMemberLoginInfo
({
authCode
},
{
ctlType
:
'none'
}).
then
(
res
=>
{
postMemberLoginInfo
({
authCode
},
{
ctlType
:
'none'
}).
then
(
res
=>
{
console
.
log
(
res
);
const
{
data
,
code
}
=
res
if
(
code
===
1000
)
{
...
...
src/pages/user/forgetPwd.tsx
View file @
ee6b2b19
...
...
@@ -7,7 +7,7 @@ import { forgetPwdSchema } from './schema';
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
omit
}
from
'@/utils'
;
import
{
createFormActions
}
from
'@formily/antd'
;
import
{
PublicApi
}
from
'@/services/a
pi'
;
import
{
postMemberRegisterResetEmail
,
postMemberRegisterResetSms
,
postMemberRegisterEmailCheck
}
from
'@/services/MemberV2A
pi'
;
import
{
encryptedByAES
}
from
'@/utils/cryptoAes'
;
import
PasswordInput
from
'./components/PasswordInput'
import
'./index.less'
...
...
@@ -22,7 +22,7 @@ const GetBack: React.FC = () => {
const
isEmail
=
PATTERN_MAPS
.
email
.
test
(
account
)
const
accountParams
=
isEmail
?
{
email
:
account
,
...
omit
(
value
,
[
'account'
,
'confirmPassword'
])}
:
{
phone
:
account
,
...
omit
(
value
,
[
'account'
,
'confirmPassword'
])
}
accountParams
.
password
=
encryptedByAES
(
accountParams
.
password
)
const
submitFn
=
isEmail
?
PublicApi
.
postMemberRegisterResetEmail
:
PublicApi
.
postMemberRegisterResetSms
const
submitFn
=
isEmail
?
postMemberRegisterResetEmail
:
postMemberRegisterResetSms
const
{
code
}
=
await
submitFn
(
accountParams
)
if
(
code
===
1000
)
{
...
...
@@ -61,7 +61,7 @@ const GetBack: React.FC = () => {
if
(
fieldState
.
valid
)
{
if
(
PATTERN_MAPS
.
email
.
test
(
fieldState
.
value
))
{
// 校验邮箱格式通过时, 需请求接口判断邮箱是否存在数据库
PublicApi
.
postMemberRegisterEmailCheck
({
postMemberRegisterEmailCheck
({
email
:
fieldState
.
value
},
{
ctlType
:
'none'
,
useCache
:
true
,
ttl
:
60
*
1000
}).
then
(({
code
,
data
})
=>
{
if
(
code
===
1000
)
{
...
...
src/pages/user/index.tsx
View file @
ee6b2b19
...
...
@@ -11,7 +11,7 @@ import {
import
{
Link
,
history
,
Helmet
}
from
'umi'
import
ScanLoginWrap
from
'./components/ScanLoginWrap'
;
// import leftPicture from '../../../mockStatic/image_ad.png'
import
{
PublicApi
}
from
'@/services/a
pi'
import
{
getManageContentImageFindAllByUseSceneAndPosition
}
from
'@/services/ManageV2A
pi'
import
wechat
from
'../../../mockStatic/Wechat.png'
import
qq
from
'../../../mockStatic/QQ.png'
import
alipay
from
'../../../mockStatic/Alipay.png'
...
...
@@ -48,7 +48,7 @@ const User: React.FC = () => {
position
:
1
}
PublicApi
.
getManageContentImageFindAllByUseSceneAndPosition
(
param
).
then
(
res
=>
{
getManageContentImageFindAllByUseSceneAndPosition
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
setSceneList
(
sortData
(
res
.
data
))
}
...
...
src/pages/user/register.tsx
View file @
ee6b2b19
...
...
@@ -8,11 +8,12 @@ import globalStyles from '@/global/styles/global.less'
import
cx
from
'classnames'
import
{
Link
,
history
,
Helmet
}
from
'umi'
import
im_success
from
'../../../mockStatic/im_success.png'
import
SchemaForm
,
{
Field
,
FormMegaLayout
,
FormButtonGroup
,
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
useCountDown
from
'@/utils/hooks'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
omit
,
transFormSchema
,
filterUndef
}
from
'@/utils'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
getManageContentNoticeFindAllByColumnType
}
from
'@/services/ManageV2Api'
;
import
{
getMemberMenuRegisterDetail
,
postMemberRegister
}
from
'@/services/MemberV2Api'
import
NiceForm
from
'@/components/NiceForm'
;
import
schemas
from
'./schema'
;
import
{
encryptedByAES
}
from
'@/utils/cryptoAes'
;
...
...
@@ -47,26 +48,6 @@ const useLinkageValidateEffects = () => {
state
.
errors
=
[]
})
})
onFieldValidateEnd$
(
'phone'
).
subscribe
(
fieldState
=>
{
// if (fieldState.valid && !fieldState.smsLoading) {
// // 校验手机号格式通过时, 需请求接口判断手机号是否存在数据库
// PublicApi.getMemberRegisterPhoneCheck({
// countryCode: prefixCode,
// phone: fieldState.value
// }, { ctlType: 'none', useCache: true, ttl: 60 * 1000 }).then(({ code, data }) => {
// if (code !== 1000) {
// setFieldState('phone', state => {
// state.errors = ['手机号已存在']
// eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
// })
// } else {
// eventEmitter.emit('SHOW_PHONE_VALIDATE', true)
// }
// })
// } else {
// eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
// }
})
onFieldValueChange$
(
'*(confirmPassword)'
).
subscribe
(
fieldState
=>
{
const
selfValue
=
fieldState
.
value
const
otherValue
=
getFieldState
(
'password'
,
state
=>
state
.
value
)
...
...
@@ -119,7 +100,7 @@ const UserRegistry = () => {
columnType
:
2
}
PublicApi
.
getManageContentNoticeFindAllByColumnType
(
param
).
then
(
res
=>
{
getManageContentNoticeFindAllByColumnType
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
setAgreementList
(
res
.
data
)
}
...
...
@@ -221,7 +202,7 @@ const UserRegistry = () => {
formCache
=
Object
.
assign
({},
formCache
,
filterUndef
(
values
))
const
{
businessTypeId
,
typeId
}
=
values
setSubmitLoading
(
true
)
PublicApi
.
getMemberMenuRegisterDetail
({
getMemberMenuRegisterDetail
({
businessTypeId
,
memberTypeId
:
typeId
}).
then
(
res
=>
{
...
...
@@ -254,7 +235,7 @@ const UserRegistry = () => {
const
params
=
omit
(
formCache
,
[
'isRead'
,
'confirmPassword'
])
params
.
password
=
encryptedByAES
(
params
.
password
)
setSubmitLoading
(
true
)
PublicApi
.
postMemberRegister
(
params
).
then
(({
code
})
=>
{
postMemberRegister
(
params
).
then
(({
code
})
=>
{
if
(
code
===
1000
)
{
actions
.
dispatch
(
'onFormStepNext'
,
{})
setCurrent
(
current
+
1
)
...
...
src/pages/user/schema/index.ts
View file @
ee6b2b19
import
{
ISchema
,
ISchemaFormActions
}
from
'@formily/antd'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
import
{
PublicApi
}
from
'@/services/a
pi'
;
import
{
postMemberRegisterPswSms
,
postMemberRegisterPswEmail
}
from
'@/services/MemberV2A
pi'
;
export
const
registerStep0Schema
:
ISchema
=
{
type
:
'object'
,
...
...
@@ -261,7 +261,7 @@ export const forgetPwdSchema: ISchema = {
if
(
isPhone
)
{
setLoading
(
true
)
PublicApi
.
postMemberRegisterPswSms
({
postMemberRegisterPswSms
({
countryCode
:
'+86'
,
phone
:
values
}).
then
(
res
=>
{
...
...
@@ -275,7 +275,7 @@ export const forgetPwdSchema: ISchema = {
if
(
isEmail
)
{
setLoading
(
true
)
PublicApi
.
postMemberRegisterPswEmail
({
postMemberRegisterPswEmail
({
email
:
values
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
...
...
src/services/api.ts
View file @
ee6b2b19
...
...
@@ -30,6 +30,7 @@ import * as MessageV2 from './MessageV2Api';
import
*
as
LogiticsV2
from
'./LogiticsV2Api'
;
import
*
as
MarketingApi
from
'./MarketingApi'
;
import
*
as
AfterServiceV2Api
from
'./AfterServiceV2Api'
;
import
*
as
ManageV2Api
from
'./ManageV2Api'
;
/**
...
...
@@ -73,4 +74,5 @@ export const PublicApi = {
...
LogiticsV2
,
...
MarketingApi
,
...
AfterServiceV2Api
,
...
ManageV2Api
,
}
ytt.config.ts
View file @
ee6b2b19
...
...
@@ -32,6 +32,7 @@ const tokenList = [
{
name
:
'LogiticsV2'
,
token
:
'732fb8e33970ff5dee830423a630e8e85c3ef3293abba7581b16749dfce8608b'
,
categoryIds
:
[
0
],
},
// 物流能力v2
{
name
:
'Marketing'
,
token
:
'd952d25c4e8272a6dff69245dbddf983dc886521e2623464e476922fc95f43af'
,
categoryIds
:
[
0
],
},
// 营销能力
{
name
:
'AfterServiceV2'
,
token
:
'58748fc89dcdb33ec5cac520c00293ba92abca362a8ddb979df589effd0db9bd'
,
categoryIds
:
[
0
],
},
// 售后能力V2
{
name
:
'ManageV2'
,
token
:
'9ee3a1cb5a73ca02935e70debeda5bde0464f2fe1eb32c25855fd8acff9f68f2'
,
categoryIds
:
[
0
]
},
// 平台后台v2
]
const
getConfigMap
=
(
tokens
)
=>
tokens
.
map
(
v
=>
({
...
...
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