Commit ee6b2b19 authored by 前端-许佳敏's avatar 前端-许佳敏

refactor: 重构用户登录注册接口

parent b8ad23c6
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)
}
......
......@@ -6,7 +6,7 @@ import {
LockOutlined,
ExclamationCircleFilled
} from '@ant-design/icons';
import { PublicApi } from '@/services/api';
import { postMemberLogin } from '@/services/MemberV2Api';
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()
......
......@@ -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/api';
import { postMemberLoginAuthUrl, postMemberLoginInfo } from '@/services/MemberV2Api';
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) {
......
......@@ -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/api';
import { postMemberRegisterResetEmail, postMemberRegisterResetSms, postMemberRegisterEmailCheck } from '@/services/MemberV2Api';
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) {
......
......@@ -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/api'
import { getManageContentImageFindAllByUseSceneAndPosition } from '@/services/ManageV2Api'
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))
}
......
......@@ -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)
......
import { ISchema, ISchemaFormActions } from '@formily/antd';
import { PATTERN_MAPS } from '@/constants/regExp';
import { GlobalConfig } from '@/global/config';
import { PublicApi } from '@/services/api';
import { postMemberRegisterPswSms, postMemberRegisterPswEmail } from '@/services/MemberV2Api';
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) {
......
......@@ -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,
}
......@@ -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 => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment