import React, { Component } from 'react'; import "../css/messagemy.css" import {getImageUrl} from 'educoder'; import { Modal,Input,Icon,Tooltip,Spin} from 'antd'; import axios from 'axios'; import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import moment from 'moment'; import Rightdialogue from './Rightdialogue' import Leftdialogue from './Leftdialogue' //私信聊天页面 class MessagChat extends Component{ constructor(props) { super(props); this.messageRef = React.createRef(); this.state={ isSpin:false, isSpins:false, limit:20, page:1, datay:[], limits:20, mess:false, myuserl:[], pages:1, mypagey:20, messages:[], objc:[], } } componentDidMount(){ this.getdata(1); let target_ids=this.props.match.params.private; this.getChatList(1,this.state.limit,target_ids); // console.log("MessagChat111111"); console.log(this.props.myysluser); this.setState({ myyslusers:this.props.myysluser }) try { this.props.Mtab(3); }catch (e) { } console.log("MessagChat111111"); console.log(this.props); console.log(this.props.match.params.userid); } // 滑动刷新 contentViewScrolledit=(e)=>{ //滑动到底判断 if(e.currentTarget.scrollHeight-e.currentTarget.scrollTop===e.currentTarget.clientHeight){ // console.log("滑动到底判断"); let {page}=this.state; let newpage=page+1 this.getdata(newpage); let ls=newpage*20 this.setState({ limits:ls, }) } }; getChatList=(page,listl,target_ids)=>{ this.setState({ isSpins:true, }); let url = `/users/${this.props.match.params.userid}/private_message_details.json`; axios.get((url),{params:{ target_id:target_ids, page: page, per_page:listl, }}).then((result) => { if (result) { if(result.data.message!==undefined){ return; } var datas=[] var datay=result.data.messages; var obj={}; for (var i=0;i { console.log(error); this.setState({ isSpins:false, }) }) }; getChatListtwo=(pages,listls,target_ids)=>{ this.setState({ isSpins:true, }); let url = `/users/${this.props.match.params.userid}/private_message_details.json`; axios.get((url),{params:{ target_id:target_ids, page: pages, per_page:listls, }}).then((result) => { if (result) { if(result.data.message!==undefined){ return; } if(result.data!==null){ console.log(result) this.setState({ messages:result.data.messages, myuserl:result.data.target, }); this.getdatatwo(this.state.page); } this.setState({ isSpins:false, }); } }).catch((error) => { console.log(error); this.setState({ isSpins:false, }); this.getdatatwo(this.state.page); }) }; //获取数据地方 getdata=(page)=>{ let{limit}=this.state; let url = `/users/${this.props.match&&this.props.match.params.userid}/private_messages.json`; // let url = `/users/71519/private_messages.json`; axios.get((url),{params:{ page:page, per_page:limit, }}).then((result) => { if (result) { // console.log(types); // console.log(result); if(result.data.message!==undefined){ // console.log("5151515151"); return; } // console.log("调用了消失的方法"); // console.log("5454545454"); if(result.data!==null){ if(result.data.private_messages!==null){ if(result.data.private_messages.length>0){ for (var i=0;i { console.log(error); this.setState({ isSpins:false, }) }) }; //获取数据地方 getdatatwo=(page)=>{ let{limits}=this.state; let url = `/users/${this.props.match&&this.props.match.params.userid}/private_messages.json`; // let url = `/users/71519/private_messages.json`; axios.get((url),{params:{ page:page, per_page:limits, }}).then((result) => { if (result) { // console.log(types); // console.log(result); if(result.data.message!==undefined){ // console.log("5151515151"); return; } // console.log("调用了消失的方法"); // console.log("5454545454"); // // if(result.data!==null){ // if(result.data.private_messages!==null){ // if(result.data.private_messages.length>0){ // for (var i=0;i { console.log(error); this.setState({ isSpins:false, }) }) }; // 跳转页面 smyJump =(i)=>{ // console.log("跳转页面"); // console.log(i); this.props.Modifyur(i); }; // 点击了用户 Clickedontheuser=(user)=>{ // debugger // console.log("点击了用户"); // console.log(user); // this.setState({ // myyslusers:user, // mess:true, // }) this.props.history.replace(`/message/${this.props.current_user.user_id}/${user.id}/message_detail`); // this.getdatatwo(this.state.page); this.getChatListtwo(this.state.pages,this.state.mypagey,user.id); } setreplyfun=()=>{ let contents=this.messageRef.current.getValue().trim(); let target_ids=this.props.match.params.private let url = `/users/${this.props.match.params.userid}/private_messages.json`; axios.post(url, { target_id: target_ids, content: contents }) .then((response) => { // console.log(response); }) .catch(function (error) { console.log(error); }); } render() { let{isSpins,datay,myyslusers,mess,limits,myuserl,messages}=this.state; // console.log(mess); // console.log(myyslusers); // console.log("MessagChat"); // console.log(this.state); // console.log("112"); console.log(limits); console.log(myuserl); console.log(messages); return (
{/*私信对话框*/}
{/*左边*/}

this.smyJump(2)}> {myuserl!==undefined?myuserl.name:""}与你的私信

{/*聊天页面*/}
{ messages===undefined? "" :messages.map((item,key)=>{ console.log("-----------------================-=-==-=="); console.log(item.sender_id); console.log(this.props.match.params.userid); return(
{ item.send_day===undefined?"":item.send_day===null?"":item.send_day===""?"":

{item.send_day}

} { parseInt(item.sender_id)===parseInt(this.props.match.params.userid)? {/*自己的*/} : {/*他人的*/} }
) }) }
{/*回复*/}
在问题反馈时,请同时发送问题发生页的网址链接,以便我们高效的为您服务 回复
{/*右边*/}
{/*右边头部*/}

私信列表

{/*列表数据*/} { datay===undefined? "" :datay.map((item,key)=>{ return(
this.Clickedontheuser(item.target)}>

{item.target.name} {item.unread === true? :""} {moment(item.send_time).fromNow()}

) })}
) } } export default MessagChat; // onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25137', '确定要删除该条记录吗?')" // // {/*左边*/}