From 390dcbdbd4d90c8498f70c4295b631b744e2c89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= Date: Fri, 17 Dec 2021 14:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/expert.js | 71 +++++++++++++++++++++++--------------- src/military/expert/api.js | 9 +++++ 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/military/expert.js b/src/military/expert.js index 1f2b3cba..41bcff7a 100644 --- a/src/military/expert.js +++ b/src/military/expert.js @@ -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 ( -
- - ( - - )} - > - ( - - )} - > - ( - - )} - > - -
- ); - } +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 ( +
+ + ( + + )} + > + ( + + )} + > + ( + + )} + > + +
+ ); } + export default withRouter( ImageLayerOfCommentHOC({ imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget", diff --git a/src/military/expert/api.js b/src/military/expert/api.js index 51bd1d23..faa43101 100644 --- a/src/military/expert/api.js +++ b/src/military/expert/api.js @@ -16,4 +16,13 @@ export async function expertList(params) { description: res.message || '请求错误', }); } +} + + +// 获取用户信息 +export function getUserInfo() { + return fetch({ + url: '/user/getUserInfo', + method: 'get' + }); } \ No newline at end of file