Browse Source

commit

main
mac 5 months ago
parent
commit
076271b5a9
  1. 4
      .env
  2. 31
      src/pages/login/index.tsx

4
.env

@ -1,3 +1,3 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_BASE_URL=https://matontrading.com
REACT_APP_ORIGIN_URL=https://matontrading.com
REACT_APP_BASE_URL=http://203.161.61.234:8082
REACT_APP_ORIGIN_URL=http://162.254.37.253:8086

31
src/pages/login/index.tsx

@ -22,6 +22,7 @@ const LoginForm: FC<Props> = ({
const [form] = Form.useForm()
const nameRef = useRef('')
const google_token = useRef('')
const [codeUrl, setCodeUrl] = useState('')
const codeId = useRef('')
const [visible, setVisible] = useState(false)
@ -53,18 +54,23 @@ const LoginForm: FC<Props> = ({
const { username } = values;
common.login({ ...values, id: codeId.current }).then((res: any) => {
console.log(res);
if (res.code === 0 && !res.data.google) {
// 登录后返回的数据,包括权限
const resData = {
userName: username,
token: res.data.token,
permission: res.data.c || []
if (res.code === 0) {
if (res.data.google) {
nameRef.current = username
google_token.current = res.data.google_token
setVisible(true)
} else {
// 登录后返回的数据,包括权限
const resData = {
userName: username,
token: res.data.token,
permission: res.data.c || []
}
setUserInfo(resData, setStoreData)
history.push('/')
}
setUserInfo(resData, setStoreData)
history.push('/')
} else {
nameRef.current = username
setVisible(true)
}
})
@ -114,7 +120,8 @@ const LoginForm: FC<Props> = ({
const onVerifyFinish = async (values) => {
const res: any = await api.verify_googleCode({
code: Number(values.code)
code: Number(values.code),
google_token: google_token.current
})
if (res.code === 0) {
// 登录后返回的数据,包括权限

Loading…
Cancel
Save