dev_cs_new
杨树明 6 years ago
parent c245781db7
commit 65dce68b92

@ -11,7 +11,7 @@ import Leftdialogue from './Leftdialogue'
class MessagChat extends Component{ class MessagChat extends Component{
constructor(props) { constructor(props) {
super(props); super(props);
this.messageRef = React.createRef();
this.state={ this.state={
isSpin:false, isSpin:false,
isSpins:false, isSpins:false,
@ -53,8 +53,12 @@ class MessagChat extends Component{
} }
scrollToBottom() { scrollToBottom() {
this.el.scrollIntoView({ behavior: 'smooth' }); const scrollHeight = this.messageList.scrollHeight;
const height = this.messageList.clientHeight;
const maxScrollTop = scrollHeight - height;
this.messageList.scrollTop = maxScrollTop > 0 ? maxScrollTop : 0;
} }
// 滑动刷新 // 滑动刷新
contentViewScrolledit=(e)=>{ contentViewScrolledit=(e)=>{
@ -351,6 +355,8 @@ class MessagChat extends Component{
messages:this.state.messages, messages:this.state.messages,
isSpin:false, isSpin:false,
}) })
this.scrollToBottom()
} }
} }
} }
@ -391,10 +397,13 @@ class MessagChat extends Component{
{myuserl!==undefined?myuserl.name:""}与你的私信 {myuserl!==undefined?myuserl.name:""}与你的私信
</p> </p>
{/*聊天页面*/} {/*聊天页面*/}
<div className="dialogPanel"> <div className="dialogPanel"
ref={(div) => {
this.messageList = div;
}}>
<div > <div >
<Spin size="large" className="myw100baifenbi" spinning={isSpin}> <Spin size="large" className="myw100baifenbi" spinning={isSpin}>
<div id="yslysl" ref={el => { this.el = el; }}> <div id="yslysl" >
{ {
messages===undefined? messages===undefined?
"" ""
@ -477,12 +486,12 @@ class MessagChat extends Component{
<img src={getImageUrl("/images/"+item.target.image_url)} className="radius mr10 myimgw48 myimgh48"/> <img src={getImageUrl("/images/"+item.target.image_url)} className="radius mr10 myimgw48 myimgh48"/>
<div className="flex1"> <div className="flex1">
<p className="clearfix mb15 lineh-17"> <p className="clearfix mb15 lineh-17">
<span className="fl pr"> <span className="fl pr">
<span className="task-hide privatePartName">{item.target.name}</span> <span className="task-hide privatePartName">{item.target.name}</span>
{item.unread === true? {item.unread === true?
<span className="newLetter"></span> <span className="newLetter"></span>
:""} :""}
</span> </span>
<span className="color-grey-c fr">{moment(item.send_time).fromNow()}</span> <span className="color-grey-c fr">{moment(item.send_time).fromNow()}</span>
</p> </p>
<p className="color-grey-6 lineh-20 justify break_word task-hide-2" style={{wordBreak:"break-word"}} dangerouslySetInnerHTML={{__html:item.content}}></p> <p className="color-grey-6 lineh-20 justify break_word task-hide-2" style={{wordBreak:"break-word"}} dangerouslySetInnerHTML={{__html:item.content}}></p>

Loading…
Cancel
Save