|
|
@@ -8,6 +8,7 @@ import { Alert, CircularProgress } from '@mui/joy';
|
|
|
// import CircularProgress from '@mui/joy/CircularProgress';
|
|
|
import httpRequest from '../http/http'
|
|
|
import qs from 'qs';
|
|
|
+import axios from 'axios'
|
|
|
|
|
|
// eslint-disable-next-line no-useless-escape
|
|
|
const regEmail = new RegExp("^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$");
|
|
|
@@ -52,23 +53,19 @@ function Login(props) {
|
|
|
let progressTimer = setInterval(() => {
|
|
|
setProgress()
|
|
|
}, 100);
|
|
|
+ let aa = window.location.hostname.indexOf('cocorobo.cn') > -1||window.location.hostname.indexOf('localhost') > -1
|
|
|
let params = {
|
|
|
loginUsername: email.trim(),
|
|
|
- loginPassword: window.btoa(passworld.trim()),
|
|
|
+ // loginPassword: passworld.trim(),
|
|
|
+ loginPassword: aa ? window.btoa(passworld.trim()) : passworld.trim(),
|
|
|
geetest_challenge: "",
|
|
|
geetest_validate: "",
|
|
|
geetest_seccode: ""
|
|
|
}
|
|
|
- httpRequest(`${config.api}api/user`, {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- body: JSON.stringify(params)
|
|
|
- }).then(res => {
|
|
|
- console.log(res)
|
|
|
+ axios.defaults.withCredentials = true;
|
|
|
+ axios.post(`${config.api}api/user`, qs.stringify(params)).then(res => {
|
|
|
clearInterval(progressTimer)
|
|
|
- if (res[0].length > 0) {
|
|
|
+ if (res.data.length > 0) {
|
|
|
setProgressValue(100)
|
|
|
showAlert(props.lang.loginSuccess)
|
|
|
setAlertShow(true)
|
|
|
@@ -76,7 +73,7 @@ function Login(props) {
|
|
|
setLoading(false)
|
|
|
setProgressValue(0)
|
|
|
setAlertShow(false)
|
|
|
- postMessageToParent('loginVerify', 'logged', res[0][0])
|
|
|
+ postMessageToParent('loginVerify', 'logged', res.data[0][0])
|
|
|
}, 1000)
|
|
|
} else {
|
|
|
setLoading(false)
|
|
|
@@ -94,6 +91,7 @@ function Login(props) {
|
|
|
showAlert(props.lang.loginError)
|
|
|
console.log(err)
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
const postMessageToParent = (id, status, data) => {
|
|
|
//TODO: replace origin
|
|
|
@@ -119,17 +117,11 @@ function Login(props) {
|
|
|
|
|
|
const getSchool = e => {
|
|
|
// 获取学校信息
|
|
|
- httpRequest(`${config.edu}admin/selectorganize`, {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
- },
|
|
|
- body: qs.stringify({ mode: e })
|
|
|
- }).then(res => {
|
|
|
+ axios.post(`${config.edu}admin/selectorganize`, qs.stringify({ mode: e })).then(res => {
|
|
|
console.log(res)
|
|
|
- if (res[0].length > 0) {
|
|
|
- setSchoolNum(res[0][0].mail)
|
|
|
- setSchoolName(res[0][0].name)
|
|
|
+ if (res.data.length > 0) {
|
|
|
+ setSchoolNum(res.data[0][0].mail)
|
|
|
+ setSchoolName(res.data[0][0].name)
|
|
|
setSchoolShow(true)
|
|
|
} else {
|
|
|
setSchoolName(props.lang.notSchool)
|