From d3a18bdc7652b80a0a3cadaa7320fb3ecd884526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 1 Aug 2019 20:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/message/js/MessagChat.js | 216 +++++++++--------- .../react/src/modules/message/js/MessagSub.js | 25 +- .../src/modules/message/js/MessagePrivate.js | 20 +- 3 files changed, 131 insertions(+), 130 deletions(-) diff --git a/public/react/src/modules/message/js/MessagChat.js b/public/react/src/modules/message/js/MessagChat.js index abb67dec8..8cfef4731 100644 --- a/public/react/src/modules/message/js/MessagChat.js +++ b/public/react/src/modules/message/js/MessagChat.js @@ -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 { 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 { 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 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 { @@ -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 { + this.messagesEnd.scrollIntoView({ behavior: "auto" }); + } + @@ -394,7 +400,7 @@ class MessagChat extends Component{
-
{ this.el = el; }}> +
{this.messagesEnd = el}}> { messages===undefined? "" diff --git a/public/react/src/modules/message/js/MessagSub.js b/public/react/src/modules/message/js/MessagSub.js index 479401681..c32ebeb37 100644 --- a/public/react/src/modules/message/js/MessagSub.js +++ b/public/react/src/modules/message/js/MessagSub.js @@ -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); diff --git a/public/react/src/modules/message/js/MessagePrivate.js b/public/react/src/modules/message/js/MessagePrivate.js index b0a137042..faa3c327b 100644 --- a/public/react/src/modules/message/js/MessagePrivate.js +++ b/public/react/src/modules/message/js/MessagePrivate.js @@ -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);