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 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<datay.length-1;i++){
if(datay[i].send_day===datay[i].send_day){
}
}
if(result.data!==null){
console.log(result)
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,
})
})
}
};
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.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<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)=>{
// 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 (
<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">
<a onClick={()=>this.smyJump(2)}><i className="iconfont icon-zuojiantou font-14 fl ml25 color-grey-9"
data-tip-down="返回到列表"></i></a>
{myyslusers!==undefined?myyslusers.name:""}与你的私信
{myuserl!==undefined?myuserl.name:""}与你的私信
</p>
{/*聊天页面*/}
<div className="dialogPanel">
<div className="dialogPanel">
<div>
<p className="mt30 edu-txt-center"><span className="letter-time">2019/07/20</span></p>
{/*右边*/}
<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>
{
messages===undefined?
""
:messages.map((item,key)=>{
console.log("-----------------================-=-==-==");
console.log(item.sender_id);
console.log(this.props.match.params.userid);
return(
<div key={key}>
<p className="mt30 edu-txt-center"><span className="letter-time">2019/07/20</span></p>
{
parseInt(item.sender_id)===parseInt(this.props.match.params.userid)?
<Rightdialogue objeysl={item}>
{/*自己的*/}
</Rightdialogue>
:<Leftdialogue objeysl={item}>
{/*他人的*/}
</Leftdialogue>
}
</div>
)
})
}
</div>
</div>
</div>
{/*回复*/}
@ -304,16 +422,3 @@ export default MessagChat;
// 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(){
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,

@ -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{
}
></Route>
{/*/!*私信聊天页面*! letters/*/}
<Route path="/message/:userid/message_detail"
<Route path="/message/:userid/:private/message_detail"
render={
(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