Merge remote-tracking branch 'origin/dev_Ysl' into dev_Ysl

dev_cs_new
杨树明 6 years ago
commit bf37262017

@ -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 (
<div className="OtherSide clearfix" id="message_content_25148">
<a href="/users/p94531287"><img alt="71519?1564061748" className="mr10 radius fl" height="48" src={"/images/avatars/User/71519?1564061748" } width="48"/></a>
<div className="fl pr OtherSide-info">
<span className="trangle"></span>
<div className="sms break_word" id="message_content_show_25148">你好</div>
<div className="edu-txt-right mt5">
<a className="color-grey-c" >删除</a>
</div>
</div>
<span className="fl ml15 color-grey-c lineh-15 mt15">22:21</span>
</div>
)
}
}
export default Leftdialogue;
// onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25148', '确定要删除该条记录吗?')"

@ -4,8 +4,9 @@ import {getImageUrl} from 'educoder';
import { Modal,Input,Icon,Tooltip,Spin} from 'antd'; import { Modal,Input,Icon,Tooltip,Spin} from 'antd';
import axios from 'axios'; import axios from 'axios';
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import moment from 'moment'; import moment from 'moment';
import Rightdialogue from './Rightdialogue'
import Leftdialogue from './Leftdialogue'
//私信聊天页面 //私信聊天页面
class MessagChat extends Component{ class MessagChat extends Component{
constructor(props) { constructor(props) {
@ -17,14 +18,20 @@ class MessagChat extends Component{
limit:20, limit:20,
page:1, page:1,
datay:[], datay:[],
limits:20,
mess:false, mess:false,
myuserl:[],
pages:1,
mypagey:20,
messages:[],
objc:[],
} }
} }
componentDidMount(){ componentDidMount(){
this.getdata(1); 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("MessagChat111111");
console.log(this.props.myysluser); console.log(this.props.myysluser);
this.setState({ this.setState({
@ -35,6 +42,10 @@ class MessagChat extends Component{
}catch (e) { }catch (e) {
} }
console.log("MessagChat111111");
console.log(this.props);
console.log(this.props.match.params.userid);
} }
// 滑动刷新 // 滑动刷新
contentViewScrolledit=(e)=>{ contentViewScrolledit=(e)=>{
@ -45,32 +56,43 @@ class MessagChat extends Component{
let {page}=this.state; let {page}=this.state;
let newpage=page+1 let newpage=page+1
this.getdata(newpage); this.getdata(newpage);
let ls=newpage*20
this.setState({
limits:ls,
})
} }
}; };
getChatList=(page)=>{ getChatList=(page,listl,target_ids)=>{
this.setState({ this.setState({
isSpins:true, isSpins:true,
}); });
let target_ids=this.props.match.params.userid; let url = `/users/${this.props.match.params.userid}/private_message_details.json`;
let url = `/users/${this.props.current_user&&this.props.current_user.user_id}/private_message_details.json`;
axios.get((url),{params:{ axios.get((url),{params:{
target_id:target_ids, target_id:target_ids,
page: page, page: page,
per_page:20, per_page:listl,
}}).then((result) => { }}).then((result) => {
if (result) { if (result) {
if(result.data.message!==undefined){ if(result.data.message!==undefined){
return; return;
} }
var datas=[]
var datay=result.data.messages;
for (var i=0;i<datay.length-1;i++){
if(datay[i].send_day===datay[i].send_day){
}
}
if(result.data!==null){ if(result.data!==null){
console.log(result) console.log(result)
this.setState({ this.setState({
private_messages:result.data.private_messages messages:result.data.messages,
myuserl:result.data.target,
}) })
} }
@ -85,12 +107,50 @@ class MessagChat extends Component{
isSpins:false, 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)=>{ getdata=(page)=>{
let{limit}=this.state; 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`; // let url = `/users/71519/private_messages.json`;
axios.get((url),{params:{ axios.get((url),{params:{
page:page, 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<result.data.private_messages.length;i++){
// this.state.datay.push(result.data.private_messages[i]);
// }
// }
// }
// }
this.setState({
page:page,
isSpins:false,
datay:result.data.private_messages===null?undefined:result.data.private_messages===undefined?undefined:result.data.private_messages===[]?undefined:result.data.private_messages==="[]"?undefined:result.data.private_messages.length===0?undefined:result.data.private_messages,
});
// console.log(this.state.datay);
}
}).catch((error) => {
console.log(error);
this.setState({
isSpins:false,
})
})
};
// 跳转页面 // 跳转页面
smyJump =(i)=>{ smyJump =(i)=>{
// console.log("跳转页面"); // console.log("跳转页面");
@ -147,14 +251,17 @@ class MessagChat extends Component{
// myyslusers:user, // myyslusers:user,
// mess:true, // 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=()=>{ setreplyfun=()=>{
let contents=this.messageRef.current.getValue().trim(); let contents=this.messageRef.current.getValue().trim();
let target_ids=this.props.match.params.userid; let target_ids=this.props.match.params.private
let url = `/users/${this.props.current_user&&this.props.current_user.user_id}/private_messages.json`; let url = `/users/${this.props.match.params.userid}/private_messages.json`;
axios.post(url, { axios.post(url, {
target_id: target_ids, target_id: target_ids,
content: contents content: contents
@ -169,12 +276,15 @@ class MessagChat extends Component{
render() { render() {
let{isSpins,datay,myyslusers,mess}=this.state; let{isSpins,datay,myyslusers,mess,limits,myuserl,messages}=this.state;
// console.log(mess); // console.log(mess);
// console.log(myyslusers); // console.log(myyslusers);
// console.log("MessagChat"); // console.log("MessagChat");
// console.log(this.state); // console.log(this.state);
// console.log("112"); // console.log("112");
console.log(limits);
console.log(myuserl);
console.log(messages);
return ( return (
<div className="edu-back-white ml20"> <div className="edu-back-white ml20">
{/*私信对话框*/} {/*私信对话框*/}
@ -184,36 +294,44 @@ class MessagChat extends Component{
<p className="clearfix pt30 pb30 edu-txt-center font-16 bor-bottom-greyE"> <p className="clearfix pt30 pb30 edu-txt-center font-16 bor-bottom-greyE">
<a onClick={()=>this.smyJump(2)}><i className="iconfont icon-zuojiantou font-14 fl ml25 color-grey-9" <a onClick={()=>this.smyJump(2)}><i className="iconfont icon-zuojiantou font-14 fl ml25 color-grey-9"
data-tip-down="返回到列表"></i></a> data-tip-down="返回到列表"></i></a>
{myyslusers!==undefined?myyslusers.name:""}与你的私信 {myuserl!==undefined?myuserl.name:""}与你的私信
</p> </p>
{/*聊天页面*/} {/*聊天页面*/}
<div className="dialogPanel"> <div className="dialogPanel">
<div className="dialogPanel"> <div className="dialogPanel">
<div> <div>
<p className="mt30 edu-txt-center"><span className="letter-time">2019/07/20</span></p> {
{/*右边*/} messages===undefined?
<div className="ThisSide clearfix" id="message_content_25137"> ""
<a href="/users/innov"><img alt="头像" className="ml10 radius fr myimgw48 myimgh48" src={"/images/avatars/User/1?1558048024"} /></a> :messages.map((item,key)=>{
<div className="fr pr ThisSide-info"> console.log("-----------------================-=-==-==");
<span className="trangle"></span> console.log(item.sender_id);
<div className="sms break_word" id="message_content_show_25137">hello</div> console.log(this.props.match.params.userid);
<div className="edu-txt-left mt5"> return(
<a className="color-grey-c" <div key={key}>
>删除</a>
</div> <p className="mt30 edu-txt-center"><span className="letter-time">2019/07/20</span></p>
</div> {
<span className="fr mr15 color-grey-c lineh-15 mt15">22:20</span> parseInt(item.sender_id)===parseInt(this.props.match.params.userid)?
</div> <Rightdialogue objeysl={item}>
{/*自己的*/}
</Rightdialogue>
:<Leftdialogue objeysl={item}>
{/*他人的*/}
</Leftdialogue>
}
</div>
)
})
}
</div> </div>
</div> </div>
</div> </div>
{/*回复*/} {/*回复*/}
@ -304,16 +422,3 @@ export default MessagChat;
// onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25137', '确定要删除该条记录吗?')" // onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25137', '确定要删除该条记录吗?')"
// //
// {/*左边*/} // {/*左边*/}
// <div className="OtherSide clearfix" id="message_content_25148">
// <a href="/users/p94531287"><img alt="71519?1564061748" className="mr10 radius fl" height="48"
// src="/images/avatars/User/71519?1564061748" width="48"></a>
// <div className="fl pr OtherSide-info">
// <span className="trangle"></span>
// <div className="sms break_word" id="message_content_show_25148">你好</div>
// <div className="edu-txt-right mt5">
// <a href="javascript:void(0)" className="color-grey-c"
// onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25148', '确定要删除该条记录吗?')">删除</a>
// </div>
// </div>
// <span className="fl ml15 color-grey-c lineh-15 mt15">22:21</span>
// </div>

@ -25,14 +25,15 @@ class MessagePrivate extends Component{
} }
componentDidMount(){ componentDidMount(){
console.log("初始化数据了MessagePrivate");
console.log(this.props);
this.getdata(1); this.getdata(1);
try { try {
this.props.Mtab(2); this.props.Mtab(2);
}catch (e) { }catch (e) {
} }
console.log("MessagePrivate");
console.log(this.props);
console.log(this.props.match.params.userid);
}; };
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
// console.log("11111111111"); // console.log("11111111111");
@ -50,7 +51,7 @@ class MessagePrivate extends Component{
isSpin:true, isSpin:true,
}); });
let{limit}=this.state; 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`; // let url = `/users/71519/private_messages.json`;
axios.get((url),{params:{ axios.get((url),{params:{
page:page, page:page,

@ -122,7 +122,7 @@ class Messagerouting extends Component{
myysluser:item, myysluser:item,
}); });
console.log("22222222222"); 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{
} }
></Route> ></Route>
{/*/!*私信聊天页面*! letters/*/} {/*/!*私信聊天页面*! letters/*/}
<Route path="/message/:userid/message_detail" <Route path="/message/:userid/:private/message_detail"
render={ render={
(props) => (<MessagChat {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagChat>) (props) => (<MessagChat {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagChat>)
} }

@ -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 (
<div className="ThisSide clearfix" id="message_content_25137">
<a href="/users/innov"><img alt="头像" className="ml10 radius fr myimgw48 myimgh48" src={"/images/avatars/User/1?1558048024"} /></a>
<div className="fr pr ThisSide-info">
<span className="trangle"></span>
<div className="sms break_word" id="message_content_show_25137">hello</div>
<div className="edu-txt-left mt5">
<a className="color-grey-c"
>删除</a>
</div>
</div>
<span className="fr mr15 color-grey-c lineh-15 mt15">22:20</span>
</div>
)
}
}
export default Rightdialogue;
Loading…
Cancel
Save