forked from Gitlink/forgeplus-react
修改用户信息
This commit is contained in:
parent
7823a70a37
commit
390dcbdbd4
|
@ -1,4 +1,4 @@
|
|||
import React, { Component } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import { withRouter } from "react-router";
|
||||
|
@ -7,6 +7,7 @@ import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
|
|||
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
|
||||
import Loadable from "react-loadable";
|
||||
import Loading from "../Loading";
|
||||
import { getUserInfo } from './expert/api';
|
||||
import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC";
|
||||
import './index.scss';
|
||||
|
||||
|
@ -25,34 +26,48 @@ const Review = Loadable({
|
|||
loading: Loading,
|
||||
});
|
||||
|
||||
class Expert extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="newMain clearfix">
|
||||
<Switch {...this.props}>
|
||||
<Route
|
||||
path="/expert/register"
|
||||
render={(props) => (
|
||||
<Register {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/expert/list"
|
||||
render={(props) => (
|
||||
<ExpertList {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/expert"
|
||||
render={(props) => (
|
||||
<Review {...this.props} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const Expert = (propsTransmit) => {
|
||||
|
||||
// 开发时,从代理的位置获取用户信息
|
||||
const [currentUser, setCurrentUser] = useState(propsTransmit.current_user);
|
||||
// const isDev = window.location.href.indexOf('3007') > -1 ? true : false;
|
||||
useEffect(() => {
|
||||
getUserInfo().then(res => {
|
||||
if (res && res.data) {
|
||||
setCurrentUser(res.data);
|
||||
}
|
||||
})
|
||||
}, []);
|
||||
let propsF = { ...propsTransmit };
|
||||
propsF.current_user = currentUser;
|
||||
console.log(currentUser);
|
||||
|
||||
return (
|
||||
<div className="newMain clearfix">
|
||||
<Switch {...propsF}>
|
||||
<Route
|
||||
path="/expert/register"
|
||||
render={(props) => (
|
||||
<Register {...propsF} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/expert/list"
|
||||
render={(props) => (
|
||||
<ExpertList {...propsF} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/expert"
|
||||
render={(props) => (
|
||||
<Review {...propsF} {...props} />
|
||||
)}
|
||||
></Route>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default withRouter(
|
||||
ImageLayerOfCommentHOC({
|
||||
imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
|
||||
|
|
|
@ -16,4 +16,13 @@ export async function expertList(params) {
|
|||
description: res.message || '请求错误',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取用户信息
|
||||
export function getUserInfo() {
|
||||
return fetch({
|
||||
url: '/user/getUserInfo',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue