dev_cs_new
杨树林 6 years ago
parent c245781db7
commit d3a18bdc76

@ -52,9 +52,6 @@ class MessagChat extends Component{
this.scrollToBottom();
}
scrollToBottom() {
this.el.scrollIntoView({ behavior: 'smooth' });
}
// 滑动刷新
contentViewScrolledit=(e)=>{
@ -96,43 +93,40 @@ class MessagChat extends Component{
per_page:listl,
}}).then((result) => {
if (result) {
// if (result.data.status === 0) {
if (result.data !== null) {
var datas = []
var datay = result.data.messages;
datay = datay.reverse();
var obj = {};
for (var i = 0; i < datay.length; i++) {
if (i === 0) {
obj = datay[i];
datas.push(datay[i]);
} else {
if (moment(obj.send_day).isSame(datay[i].send_day)) {
datay[i].send_day = "";
} else {
obj = datay[i];
}
if(result.data.message!==undefined){
return;
}
if(result.data!==null){
var datas=[]
var datay=result.data.messages;
var obj={};
for (var i=0;i<datay.length;i++){
if(i===0){
obj=datay[i];
datas.push(datay[i]);
}else{
if( moment(obj.send_day).isSame(datay[i].send_day)){
datay[i].send_day="";
}else {
obj=datay[i];
datas.push(datay[i]);
}
datas.push(datay[i]);
}
//颠倒数组
this.setState({
messages: datas,
myuserl: result.data.target,
})
// }
}
//颠倒数组
datas=datas.reverse();
this.setState({
messages:datas,
myuserl:result.data.target,
})
isSpin: false,
});
}
this.setState({
isSpin:false,
});
}
}).catch((error) => {
console.log(error);
@ -152,44 +146,41 @@ class MessagChat extends Component{
per_page:listls,
}}).then((result) => {
if (result) {
// if (result.data.status === 0) {
if (result.data !== null) {
var datas = []
var datay = result.data.messages;
datay = datay.reverse();
var obj = {};
for (var i = 0; i < datay.length; i++) {
if (i === 0) {
obj = datay[i];
datas.push(datay[i]);
} else {
if (moment(obj.send_day).isSame(datay[i].send_day)) {
datay[i].send_day = "";
} else {
obj = datay[i];
}
if(result.data.message!==undefined){
return;
}
if(result.data!==null){
var datas=[]
var datay=result.data.messages;
var obj={};
for (var i=0;i<datay.length;i++){
if(i===0){
obj=datay[i];
datas.push(datay[i]);
}else{
if( moment(obj.send_day).isSame(datay[i].send_day)){
datay[i].send_day="";
}else {
obj=datay[i];
datas.push(datay[i]);
}
datas.push(datay[i]);
}
//颠倒数组
this.setState({
messages: datas,
myuserl: result.data.target,
});
// this.getdatatwo(this.state.page);
// }
}
//颠倒数组
datas=datas.reverse();
this.setState({
messages:datas,
myuserl:result.data.target,
isSpin: false,
});
// this.getdatatwo(this.state.page);
}
this.setState({
isSpin:false,
});
}
}
}).catch((error) => {
console.log(error);
@ -212,31 +203,29 @@ class MessagChat extends Component{
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.status===0) {
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]);
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: this.state.datay,
data: 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,
});
}
this.setState({
page:page,
isSpins:false,
datay:this.state.datay,
data: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({
@ -255,30 +244,14 @@ class MessagChat extends Component{
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]);
// }
// }
// }
// if(result.data.status===0){
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,
});
// }
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) => {
@ -320,7 +293,36 @@ class MessagChat extends Component{
content: contents
})
.then((response) => {
// console.log(response);
if(response===undefined){
return
}
// if(response.data.status===0){
//
// }
console.log("回复成功");
console.log(response);
var datas=[];
var dataso=this.state.messages;
var datays=result.data.private_message;
var obj={};
for (var i=0;i<dataso.length;i++){
if(i===0){
obj=dataso[i];
datas.push(dataso[i]);
}else{
if( moment(obj.send_day).isSame(dataso[i].send_day)){
dataso[i].send_day="";
}else {
obj=dataso[i];
}
datas.push(dataso[i]);
}
}
datas.push(datays);
//颠倒数组
this.setState({
messages: datas,
})
})
.catch(function (error) {
console.log(error);
@ -364,6 +366,10 @@ class MessagChat extends Component{
}
scrollToBottom = () => {
this.messagesEnd.scrollIntoView({ behavior: "auto" });
}
@ -394,7 +400,7 @@ class MessagChat extends Component{
<div className="dialogPanel">
<div >
<Spin size="large" className="myw100baifenbi" spinning={isSpin}>
<div id="yslysl" ref={el => { this.el = el; }}>
<div id="yslysl" ref={(el) => {this.messagesEnd = el}}>
{
messages===undefined?
""

@ -53,21 +53,16 @@ class MessagSub extends Component{
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");
this.setState({
page:page,
count:result.data.count,
typeysl:types,
isSpin:false,
data:result.data.tidings===null?undefined:result.data.tidings===undefined?undefined:result.data.tidings===[]?undefined:result.data.tidings==="[]"?undefined:result.data.tidings.length===0?undefined:result.data.tidings,
})
// if (result.data.status === 0) {
this.setState({
page: page,
count: result.data.count,
typeysl: types,
isSpin: false,
data: result.data.tidings === null ? undefined : result.data.tidings === undefined ? undefined : result.data.tidings === [] ? undefined : result.data.tidings === "[]" ? undefined : result.data.tidings.length === 0 ? undefined : result.data.tidings,
})
// }
}
}).catch((error) => {
console.log(error);

@ -60,18 +60,18 @@ class MessagePrivate extends Component{
if (result) {
// console.log(types);
// console.log(result);
if(result.data.message!==undefined){
// console.log("5151515151");
return;
}
// console.log("调用了消失的方法");
// console.log("5454545454");
this.setState({
page:page,
count:result.data.count,
isSpin:false,
data: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,
})
// if (result.data.status === 0) {
this.setState({
page: page,
count: result.data.count,
isSpin: false,
data: 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,
})
// }
}
}).catch((error) => {
console.log(error);

Loading…
Cancel
Save