diff --git a/public/react/src/modules/message/js/Leftdialogue.js b/public/react/src/modules/message/js/Leftdialogue.js new file mode 100644 index 000000000..95ef00188 --- /dev/null +++ b/public/react/src/modules/message/js/Leftdialogue.js @@ -0,0 +1,57 @@ +import React, { Component } from 'react'; +import { + Spin, + Pagination, +} from "antd"; +import axios from 'axios'; +import moment from 'moment'; +import {getImageUrl} from 'educoder'; +import "../css/messagemy.css" +import WriteaprivateletterModal from '../messagemodal/WriteaprivateletterModal'; +//私信页面 +class Leftdialogue extends Component{ + constructor(props) { + super(props); + this.state={ + }; + + } + + componentDidMount(){ + console.log("Leftdialogue"); + console.log(this.props); + }; + 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.getdata(1); + // } + } + //获取数据地方 + + // 跳转页面 + + render() { + let{page,limit,typeysl,count,isSpin,data,modalsType}=this.state; + + return ( +
+ 71519?1564061748 +
+ +
你好
+
+ 删除 +
+
+ 22:21 +
+ ) + } +} +export default Leftdialogue; +// onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25148', '确定要删除该条记录吗?')" \ No newline at end of file diff --git a/public/react/src/modules/message/js/MessagChat.js b/public/react/src/modules/message/js/MessagChat.js index c390a5ec0..9bc97cb43 100644 --- a/public/react/src/modules/message/js/MessagChat.js +++ b/public/react/src/modules/message/js/MessagChat.js @@ -4,8 +4,9 @@ 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) { @@ -17,14 +18,20 @@ class MessagChat extends Component{ limit:20, page:1, datay:[], + limits:20, mess:false, + myuserl:[], + pages:1, + mypagey:20, + messages:[], + objc:[], } } - componentDidMount(){ this.getdata(1); - this.getChatList(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({ @@ -35,6 +42,10 @@ class MessagChat extends Component{ }catch (e) { } + console.log("MessagChat111111"); + console.log(this.props); + console.log(this.props.match.params.userid); + } // 滑动刷新 contentViewScrolledit=(e)=>{ @@ -45,32 +56,43 @@ class MessagChat extends Component{ let {page}=this.state; let newpage=page+1 this.getdata(newpage); + let ls=newpage*20 + this.setState({ + limits:ls, + }) } }; - getChatList=(page)=>{ + getChatList=(page,listl,target_ids)=>{ this.setState({ isSpins:true, }); - let target_ids=this.props.match.params.userid; - let url = `/users/${this.props.current_user&&this.props.current_user.user_id}/private_message_details.json`; - + let url = `/users/${this.props.match.params.userid}/private_message_details.json`; axios.get((url),{params:{ target_id:target_ids, page: page, - per_page:20, + per_page:listl, }}).then((result) => { if (result) { if(result.data.message!==undefined){ return; } + var datas=[] + var datay=result.data.messages; + for (var i=0;i{ + 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.current_user&&this.props.current_user.user_id}/private_messages.json`; + 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, @@ -131,6 +191,50 @@ class MessagChat extends Component{ }) }) }; + //获取数据地方 + 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("跳转页面"); @@ -147,14 +251,17 @@ class MessagChat extends Component{ // myyslusers:user, // mess:true, // }) - this.props.history.replace(`/message/${user.id}/message_detail`); + + 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.userid; - let url = `/users/${this.props.current_user&&this.props.current_user.user_id}/private_messages.json`; + 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 @@ -169,12 +276,15 @@ class MessagChat extends Component{ render() { - let{isSpins,datay,myyslusers,mess}=this.state; + 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 (
{/*私信对话框*/} @@ -184,36 +294,44 @@ class MessagChat extends Component{

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

{/*聊天页面*/}
-

2019/07/20

- {/*右边*/} -
- 头像 -
- -
hello
-
- 删除 -
-
- 22:20 -
+ { + messages===undefined? + "" + :messages.map((item,key)=>{ + console.log("-----------------================-=-==-=="); + console.log(item.sender_id); + console.log(this.props.match.params.userid); + return( +
+ +

2019/07/20

+ { + parseInt(item.sender_id)===parseInt(this.props.match.params.userid)? + + {/*自己的*/} + + + + : + {/*他人的*/} + + + + } + +
+ ) + }) + }
- - - - - - -
{/*回复*/} @@ -304,16 +422,3 @@ export default MessagChat; // onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25137', '确定要删除该条记录吗?')" // // {/*左边*/} -//
-// 71519?1564061748 -//
-// -//
你好
-//
-// 删除 -//
-//
-// 22:21 -//
\ No newline at end of file diff --git a/public/react/src/modules/message/js/MessagePrivate.js b/public/react/src/modules/message/js/MessagePrivate.js index 95712f720..8b2cd5048 100644 --- a/public/react/src/modules/message/js/MessagePrivate.js +++ b/public/react/src/modules/message/js/MessagePrivate.js @@ -25,14 +25,15 @@ class MessagePrivate extends Component{ } componentDidMount(){ - console.log("初始化数据了MessagePrivate"); - console.log(this.props); this.getdata(1); try { this.props.Mtab(2); }catch (e) { } + console.log("MessagePrivate"); + console.log(this.props); + console.log(this.props.match.params.userid); }; componentDidUpdate(prevProps) { // console.log("11111111111"); @@ -50,7 +51,7 @@ class MessagePrivate extends Component{ isSpin:true, }); let{limit}=this.state; - let url = `/users/${this.props.current_user&&this.props.current_user.user_id}/private_messages.json`; + 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, diff --git a/public/react/src/modules/message/js/Messagerouting.js b/public/react/src/modules/message/js/Messagerouting.js index 949da308d..3a6b4d1b1 100644 --- a/public/react/src/modules/message/js/Messagerouting.js +++ b/public/react/src/modules/message/js/Messagerouting.js @@ -122,7 +122,7 @@ class Messagerouting extends Component{ myysluser:item, }); console.log("22222222222"); - this.props.history.replace(`/message/${this.props.current_user.user_id}/message_detail`); + this.props.history.replace(`/message/${this.props.current_user.user_id}/${item.id}/message_detail`); } }; @@ -209,7 +209,7 @@ class Messagerouting extends Component{ } > {/*/!*私信聊天页面*! letters/*/} - (this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}>) } diff --git a/public/react/src/modules/message/js/Rightdialogue.js b/public/react/src/modules/message/js/Rightdialogue.js new file mode 100644 index 000000000..6d8852a6d --- /dev/null +++ b/public/react/src/modules/message/js/Rightdialogue.js @@ -0,0 +1,58 @@ +import React, { Component } from 'react'; +import { + Spin, + Pagination, +} from "antd"; +import axios from 'axios'; +import moment from 'moment'; +import {getImageUrl} from 'educoder'; +import "../css/messagemy.css" +import WriteaprivateletterModal from '../messagemodal/WriteaprivateletterModal'; +//私信页面 +class Rightdialogue extends Component{ + constructor(props) { + super(props); + this.state={ + }; + + } + + componentDidMount(){ + console.log("Rightdialogue"); + console.log(this.props); + + }; + 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.getdata(1); + // } + } + //获取数据地方 + + // 跳转页面 + + render() { + let{page,limit,typeysl,count,isSpin,data,modalsType}=this.state; + + return ( +
+ 头像 +
+ +
hello
+
+ 删除 +
+
+ 22:20 +
+ ) + } +} +export default Rightdialogue; \ No newline at end of file