|
|
@@ -17,7 +17,7 @@ import {connect} from "react-redux";
|
|
|
import {CONFIG_TEACHER_MENU, CONFIG_PARENT_MENU, CONFIG_HOME_TOP_MENU} from "../../utils/homePage.constants";
|
|
|
import {getIntValue, getSearchParams, getStrValue, isObjEmpty} from "../../utils/common";
|
|
|
import 'css/home-page.css'
|
|
|
-import {fetchGet, fetchPost} from "../../utils/fetchRequest";
|
|
|
+import {fetchGet, fetchPost, fetchPostObj} from "../../utils/fetchRequest";
|
|
|
import {_baseURL, API} from "../../configs/api.config";
|
|
|
import icon_home_change from "../../style/imgs/icon_home_change.png";
|
|
|
|
|
|
@@ -180,7 +180,6 @@ class HomePage extends Component {
|
|
|
if (response && response.data) {
|
|
|
if (!isObjEmpty(response.data.teacher)) {
|
|
|
const teacherDOS = response.data.teacher
|
|
|
-
|
|
|
switchUser({
|
|
|
teacher: {
|
|
|
teacherId: getIntValue(teacherDOS, 'teacherId'),
|
|
|
@@ -254,7 +253,7 @@ class HomePage extends Component {
|
|
|
studentIndex: studentIndex,
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ console.log('raomeng',userInfo)
|
|
|
this.mySwiper.init()
|
|
|
}
|
|
|
}).catch((error) => {
|
|
|
@@ -268,49 +267,57 @@ class HomePage extends Component {
|
|
|
}
|
|
|
|
|
|
onIdentitySwitch = () => {
|
|
|
+ console.log('onIdentitySwitch')
|
|
|
+ //this.props.userInfo.userRole
|
|
|
operation([
|
|
|
{
|
|
|
- text: '家长', onPress: () => {
|
|
|
- //TODO 拿token
|
|
|
- fetchGet(API.leaveDetail, {}).then((response) => {
|
|
|
- if (response.success && !isObjEmpty(response.data)) {
|
|
|
+ text: '家长',
|
|
|
+ onPress: () => {
|
|
|
+ if(this.props.userInfo.userRole == 1) //当前是家长端时,点击家长不进行任何操作
|
|
|
+ return
|
|
|
+ this.switchEvent(1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '教师',
|
|
|
+ onPress: () => {
|
|
|
+ if(this.props.userInfo.userRole == 2) //当前是教师端时,点击教师不进行任何操作
|
|
|
+ return
|
|
|
+ this.switchEvent(0)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }).catch((error) => {
|
|
|
- console.log("error:", JSON.stringify(error));
|
|
|
- })
|
|
|
+ switchEvent = (type) => {
|
|
|
+ console.log('switchEvent,type',type)
|
|
|
|
|
|
- if (this.props.userInfo.userRole === 2) {
|
|
|
+ fetchPost(API.SWITCH_IDENTITY, {
|
|
|
+ personId: this.props.userInfo.user.userFunId,
|
|
|
+ type: type
|
|
|
+ }).then((response) => {
|
|
|
+ if (response.success && !isObjEmpty(response.data)) {
|
|
|
+ if (type === 0) { //家长
|
|
|
Toast.loading('身份切换中...', 0)
|
|
|
setTimeout(() => {
|
|
|
Toast.success('切换成功!', 1)
|
|
|
- switchCurrentUser(1)()
|
|
|
+ switchCurrentUser(2)()
|
|
|
}, 400)
|
|
|
- } else if (this.props.userInfo.userRole === 1) {
|
|
|
+ } else if (type === 1) { //教师
|
|
|
Toast.loading('身份切换中...', 0)
|
|
|
setTimeout(() => {
|
|
|
Toast.success('切换成功!', 1)
|
|
|
- switchCurrentUser(2)()
|
|
|
+ switchCurrentUser(1)()
|
|
|
}, 400)
|
|
|
}
|
|
|
switchUser({
|
|
|
- token: ''
|
|
|
+ token: response.data.token ? response.data.token: ''
|
|
|
})()
|
|
|
}
|
|
|
- },
|
|
|
- {
|
|
|
- text: '教师', onPress: () => {
|
|
|
+ }).catch((error) => {
|
|
|
+ Toast.hide()
|
|
|
+ })
|
|
|
|
|
|
- if (this.props.userInfo.userRole === 1) {
|
|
|
- Toast.loading('身份切换中...', 0)
|
|
|
- setTimeout(() => {
|
|
|
- Toast.success('切换成功!', 1)
|
|
|
- switchCurrentUser(2)()
|
|
|
- }, 400)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- ])
|
|
|
}
|
|
|
|
|
|
userInfoLayout = () => {
|