import React, { Component } from 'react'; import {Input,Pagination,Tooltip} from 'antd'; import {TPMIndexHOC} from "../../../modules/tpm/TPMIndexHOC"; import { WordsBtn ,ActionBtn,SnackbarHOC,markdownToHTML,getImageUrl} from 'educoder'; import axios from 'axios'; import "../css/messagemy.css" import { Redirect } from 'react-router'; import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; import Loading from '../../../Loading' import Loadable from 'react-loadable'; // MessagSub 消息自路由 // MessagePrivate 私信 const MessagSub = Loadable({ loader: () => import('./MessagSub'), loading: Loading, }) const MessagePrivate = Loadable({ loader: () => import('./MessagePrivate'), loading: Loading, }) const MessagChat = Loadable({ loader: () => import('./MessagChat'), loading: Loading, }) class Messagerouting extends Component{ constructor(props) { super(props); this.state={ routing:1, unread_message_count:0, unread_tiding_count:0, } } componentDidMount(){ // console.log("Messagerouting"); // console.log(this.props); // let courstype=this.props.location.search; // // courstype=courstype.splice('/'); // // courstype=courstype[3]; // // console.log("45"); // console.log(courstype); } componentDidUpdate(prevProps) { // console.log("11111111111"); // console.log(prevProps); // console.log("22222222222"); // console.log(this.props); // console.log("33333333333"); if(prevProps.current_user !== this.props.current_user){ this.Messageprivatemessageunreadmessage(this.props.current_user.user_id); } } //消息未读 Messageprivatemessageunreadmessage=(user_id)=>{ const url=`/users/${user_id}/unread_message_info.json` axios.get(url).then((result) => { if(result===undefined){ return } // console.log("消息未读1"); // console.log(result); this.setState({ unread_message_count:result.data.unread_message_count, unread_tiding_count:result.data.unread_tiding_count, }) }).catch((error) => { console.log(error) }) }; SwitchonClick=(value)=>{ this.setState({ routing:value, }); this.Messageprivatemessageunreadmessage(this.props.current_user.user_id); if(value===1){ this.props.history.replace(`/message/${this.props.current_user.user_id}/user_tidings`); } if(value===2){ this.props.history.replace(`/message/${this.props.current_user.user_id}/private_messages`);; } }; Message2=(data)=>{ // console.log("64"); // console.log(data); this.setState({ unread_message_count:data.unread_message_count, unread_tiding_count:data.unread_tiding_count, }) }; //跳转到链接 Modifyur=(i,id)=>{ // console.log("跳转到链接1"); // console.log(i); // console.log(item); // console.log("跳转到链接2"); if(i<3){ this.setState({ routing:i, }); if(i===1){ this.props.history.replace(`/message/${this.props.current_user.user_id}/user_tidings`); } if(i===2){ this.props.history.replace(`/message/${this.props.current_user.user_id}/private_messages`); } }else { this.setState({ routing:i, }); console.log("22222222222"); this.props.history.replace(`/message/${this.props.current_user.user_id}/${id}/message_detail`); } }; myCome=(e)=>{ window.location.href="/users/"+e.target.login; } myxiaoxisixintab=(i)=>{ if(i===1){ this.setState({ routing:1, }); } if(i===2){ this.setState({ routing:2, }); } if(i===3){ this.setState({ routing:3, }); } } render() { let{routing,unread_message_count,unread_tiding_count} =this.state; // console.log(this.props); // console.log(routing); return (
{/*左边*/}
{/*头像*/}
{ this.props.current_user!== undefined? :"" }

{this.props.current_user&&this.props.current_user.username}

{this.props.current_user&&this.props.current_user.user_identity}

{/*路由跳转*/}
{/*右边*/}
{/*/!*消息自路由*!/*/} {/*{routing===1?this.Message2()}> :""}*/} {/*/!*私信*!/*/} {/*{routing===2?this.Message2()} Modifyur={(i,item)=>this.Modifyur(i,item)}> :""}*/} {/*/!*私信聊天页面*!/*/} {/*{routing===3?this.Message2()} Modifyur={(i)=>this.Modifyur(i)}>:""}*/} {/*/!*消息自路由*! name 是 /message/info/:userid/*/} (this.Message2()} Mtab={(i)=>this.myxiaoxisixintab(i)}>) } > {/*/!*私信*! name 是letter/*/} (this.Message2()} Modifyur={(i,item)=>this.Modifyur(i,item)} Mtab={(i)=>this.myxiaoxisixintab(i)}> ) } > {/*/!*私信聊天页面*! letters/*/} (this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}>) } >
) } } export default SnackbarHOC() (TPMIndexHOC ( Messagerouting ));