From f3a744b7121435ba95cdd9223ea6bf36df21327d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 31 Jul 2019 21:19:55 +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 --- public/react/src/App.js | 7 +- public/react/src/AppConfig.js | 1 - .../modules/forums/MemoDetailMDEditortwo.js | 346 ++++++++--------- .../src/modules/message/css/messagemy.css | 65 +++- .../src/modules/message/js/MessagChat.js | 215 ++++++++++- .../react/src/modules/message/js/MessagSub.js | 109 ++++-- .../src/modules/message/js/MessagePrivate.js | 142 ++++++- .../src/modules/message/js/Messagerouting.js | 76 +++- .../messagemodal/WriteaprivateletterModal.js | 354 ++++++++++++++++++ 9 files changed, 1090 insertions(+), 225 deletions(-) create mode 100644 public/react/src/modules/message/messagemodal/WriteaprivateletterModal.js diff --git a/public/react/src/App.js b/public/react/src/App.js index e7ff43e79..156651b3b 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -19,8 +19,6 @@ import Trialapplicationysl from './modules/login/Trialapplicationysl'; import Trialapplicationreview from './modules/user/Trialapplicationreview'; import Addcourses from "./modules/courses/coursesPublic/Addcourses"; import AccountProfile from "./modules/user/AccountProfile"; - -import Messagerouting from "./modules/message/js/Messagerouting"; import Trialapplication from './modules/login/Trialapplication' import NotFoundPage from './NotFoundPage' @@ -225,7 +223,10 @@ const Interestpage = Loadable({ loader: () => import('./modules/login/EducoderInteresse'), loading: Loading, }) - +const Messagerouting= Loadable({ + loader: () => import('./modules/message/js/Messagerouting'), + loading: Loading, +}) class App extends Component { constructor(props) { super(props) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 2ad7df0d5..e89d59d69 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -43,7 +43,6 @@ export function initAxiosInterceptors(props) { // proxy = "https://testeduplus2.educoder.net" proxy="http://47.96.87.25:48080/" - // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 const requestMap = {}; diff --git a/public/react/src/modules/forums/MemoDetailMDEditortwo.js b/public/react/src/modules/forums/MemoDetailMDEditortwo.js index 5eae90400..cc3a2b1af 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditortwo.js +++ b/public/react/src/modules/forums/MemoDetailMDEditortwo.js @@ -1,173 +1,173 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import { isDev } from 'educoder' - -import './MemoDetailEditor.css' - -require('codemirror/lib/codemirror.css'); - -const $ = window.$; -///作业回答 专用 -class MemoDetailMDEditortwo extends Component { - constructor(props) { - super(props) - this.state = { - isInited: this.props.usingMockInput ? false : true, - isError: false, - errorMsg: '' - } - } - componentDidUpdate(prevProps, prevState, snapshot) { - if (this.props.memo && (!prevProps.memo || this.props.memo.id != prevProps.memo.id)) { - // this.keEditor = window.sd_create_editor_from_data(this.props.memo.id, null, "100%", "Memo"); - // window._kk = this.keEditor - } - } - - initMDEditor = () => { - // 因为props.memo不存在时,本组件不会被加载,这里直接在didMount里初始化即可 - const placeholder = '我要回复...' - // const imageUrl = `/upload_with_markdown?container_id=${this.props.memo.id}&container_type=Memo`; - const imageUrl = `/api/attachments.json`; - - // 执行太快了,样式不正常 - window.__tt = 400; - setTimeout(() => { - var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => { - commentMDEditor.focus() - - this.initDrag() - - commentMDEditor.cm.on("change", (_cm, changeObj) => { - this.setState({ - isError: false, - errorMsg: '' - }) - }) - }, { - watch: false, - dialogLockScreen: false, - }); - this.commentMDEditor = commentMDEditor; - window.commentMDEditor = commentMDEditor; - - }, window.__tt) - } - componentDidMount() { - !this.props.usingMockInput && this.initMDEditor() - } - initDrag = () => { - window.initMDEditorDragResize(".editor__resize", this.commentMDEditor) - } - - onCommit = () => { - const content = this.commentMDEditor.getValue(); - // this.props.showError == - if (this.props.showError == true) { - if (!content || content.trim() == "") { - this.setState({ - isError: true, - errorMsg: '不能为空' - }) - return; - } else if (content.length > 2000) { - this.setState({ - isError: true, - errorMsg: '不能超过2000个字符' - }) - return; - } - - this.setState({ - isError: false, - errorMsg: '' - }) - } - window.$(document).trigger("onReply", { commentContent: content - , id: this.props.memo.id, editor: this.commentMDEditor } ); - - } - - showEditor() { - $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { - if (this.commentMDEditor) { - this.commentMDEditor.cm.focus() - } else { - $('#commentInput input')[0].click() - } - }); - } - onMockInputClick = () => { - this.setState({isInited: true}) - this.initMDEditor() - } - render() { - const { match, history, memo, placeholder } = this.props - const { isInited, errorMsg } = this.state - if (!memo) { - return
- } - - return ( - - -
- - - 发送 - -
- -
-
- -
-
调整高度
- { errorMsg && {errorMsg} } - - 发送 - -
-
- ); - } -} - -export default ( MemoDetailMDEditortwo ); +import React, { Component } from 'react'; +import { Redirect } from 'react-router'; + +import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; + +import PropTypes from 'prop-types'; + +import classNames from 'classnames' + +import { isDev } from 'educoder' + +import './MemoDetailEditor.css' + +require('codemirror/lib/codemirror.css'); + +const $ = window.$; +///作业回答 专用 +class MemoDetailMDEditortwo extends Component { + constructor(props) { + super(props) + this.state = { + isInited: this.props.usingMockInput ? false : true, + isError: false, + errorMsg: '' + } + } + componentDidUpdate(prevProps, prevState, snapshot) { + if (this.props.memo && (!prevProps.memo || this.props.memo.id != prevProps.memo.id)) { + // this.keEditor = window.sd_create_editor_from_data(this.props.memo.id, null, "100%", "Memo"); + // window._kk = this.keEditor + } + } + + initMDEditor = () => { + // 因为props.memo不存在时,本组件不会被加载,这里直接在didMount里初始化即可 + const placeholder = '我要回复...' + // const imageUrl = `/upload_with_markdown?container_id=${this.props.memo.id}&container_type=Memo`; + const imageUrl = `/api/attachments.json`; + + // 执行太快了,样式不正常 + window.__tt = 400; + setTimeout(() => { + var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => { + commentMDEditor.focus(); + + this.initDrag(); + + commentMDEditor.cm.on("change", (_cm, changeObj) => { + this.setState({ + isError: false, + errorMsg: '' + }) + }) + }, { + watch: false, + dialogLockScreen: false, + }); + this.commentMDEditor = commentMDEditor; + window.commentMDEditor = commentMDEditor; + + }, window.__tt) + }; + componentDidMount() { + !this.props.usingMockInput && this.initMDEditor() + } + initDrag = () => { + window.initMDEditorDragResize(".editor__resize", this.commentMDEditor) + } + + onCommit = () => { + const content = this.commentMDEditor.getValue(); + // this.props.showError == + if (this.props.showError == true) { + if (!content || content.trim() == "") { + this.setState({ + isError: true, + errorMsg: '不能为空' + }) + return; + } else if (content.length > 2000) { + this.setState({ + isError: true, + errorMsg: '不能超过2000个字符' + }) + return; + } + + this.setState({ + isError: false, + errorMsg: '' + }) + } + window.$(document).trigger("onReply", { commentContent: content + , id: this.props.memo.id, editor: this.commentMDEditor } ); + + } + + showEditor() { + $("html, body").animate({ scrollTop: $('#commentInput').offset().top - 100 }, 1000, () => { + if (this.commentMDEditor) { + this.commentMDEditor.cm.focus() + } else { + $('#commentInput input')[0].click() + } + }); + } + onMockInputClick = () => { + this.setState({isInited: true}) + this.initMDEditor() + } + render() { + const { match, history, memo, placeholder } = this.props + const { isInited, errorMsg } = this.state + if (!memo) { + return
+ } + + return ( + + +
+ + + 发送 + +
+ +
+
+ +
+
调整高度
+ { errorMsg && {errorMsg} } + + 发送 + +
+
+ ); + } +} + +export default ( MemoDetailMDEditortwo ); diff --git a/public/react/src/modules/message/css/messagemy.css b/public/react/src/modules/message/css/messagemy.css index 4bdd0f999..0da203568 100644 --- a/public/react/src/modules/message/css/messagemy.css +++ b/public/react/src/modules/message/css/messagemy.css @@ -3,4 +3,67 @@ } .myh120{ height: 120px; -} \ No newline at end of file +} +.myimgw48{ + width: 48px; +} +.myimgh48{ + height: 48px; +} +.mycenter{ + display: flex; + justify-content: center +} +.myw100baifenbi{ + width: 100%; +} +.ant-modal-header{ + border-radius: 0px !important; +} +.search-new{ + width: 100% !important; + margin-bottom: 0px !important; +height: 32px; +position: relative;} +.search-span{ +display: block; +position: absolute; +width: 100%; +height: 100%; +left: 0px; +top: 0px; +background-color: #F4F4F4; +border: 1px solid #EAEAEA; +border-radius: 4px; +z-index: 1; +} +.search-new-input{ +width: 100% !important; +height: 32px; +padding-left: 5px; +border: none; +box-sizing: border-box; +background: none; +outline: none; +position: absolute; +left: 0px; +top: 1px; +z-index: 2;} +.search-new img,.search-new a,.search-new .searchicon{ +cursor: pointer; +position: absolute; +right: 2px; +top: 2px; +z-index: 2; +} +.search-new a{top: 0px} +.search-new-input:focus + .search-span{background-color: #fff;} +.task-hide-2 + {height: 40px; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; +} + diff --git a/public/react/src/modules/message/js/MessagChat.js b/public/react/src/modules/message/js/MessagChat.js index 0598efb30..fbe2b7a0a 100644 --- a/public/react/src/modules/message/js/MessagChat.js +++ b/public/react/src/modules/message/js/MessagChat.js @@ -1,21 +1,230 @@ import React, { Component } from 'react'; +import "../css/messagemy.css" +import {getImageUrl} from 'educoder'; +import { Modal,Input,Icon,Tooltip,Spin} from 'antd'; +import axios from 'axios'; //私信聊天页面 class MessagChat extends Component{ constructor(props) { super(props); this.state={ - + isSpin:false, + isSpins:false, + limit:20, + page:1, + datay:[], } } componentDidMount(){ + this.getdata(1); + console.log("MessagChat"); + console.log(this.props); + } + // 滑动刷新 + contentViewScrolledit=(e)=>{ + + //滑动到底判断 + if(e.currentTarget.scrollHeight-e.currentTarget.scrollTop===e.currentTarget.clientHeight){ + console.log("滑动到底判断"); + let {page}=this.state; + let newpage=page+1 + this.getdata(newpage); + } + + }; + //获取数据地方 + getdata=(page)=>{ + this.setState({ + isSpins:true, + }); + let{limit}=this.state; + let url = `/users/${this.props.current_user.user_id}/private_messages.json`; + // let url = `/users/71519/private_messages.json`; + axios.get((url),{params:{ + page:page, + 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"); + + + if(result.data!==null){ + if(result.data.private_messages!==null){ + if(result.data.private_messages.length>0){ + for (var i=0;i { + console.log(error); + this.setState({ + isSpins:false, + }) + }) + }; + // 跳转页面 + smyJump =(i)=>{ + console.log("跳转页面"); + console.log(i); + this.props.Modifyur(i); + }; + FormatTime=(timestamp)=> { + var datetime = new Date(timestamp.replace(/-/,"/")) + var mistiming = Math.round(new Date() / 1000) - datetime; + var postfix = mistiming > 0 ? '前' : '后' + mistiming = Math.abs(mistiming) + var arrr = ['年', '个月', '星期', '天', '小时', '分钟', '秒']; + var arrn = [31536000, 2592000, 604800, 86400, 3600, 60, 1]; + + for (var i = 0; i < 7; i++) { + var inm = Math.floor(mistiming / arrn[i]) + if (inm != 0) { + return inm + arrr[i] + postfix + } + } } render() { + let{isSpins,datay}=this.state; return ( -
+
+ {/*私信对话框*/} +
+ {/*左边*/} +
+

+ this.smyJump(2)}> + 117llj与你的私信 +

+ {/*聊天页面*/} +
+
+
+

2019/07/20

+ {/*右边*/} +
+ 1?1558048024 +
+ +
hello
+
+ 删除 +
+
+ 22:20 +
+ +
+
+ + + + + + + +
+ + {/*回复*/} +
+ + + +
+ + + +
+ {/*右边*/} +
+ {/*右边头部*/} +

私信列表

+ +
+ {/*列表数据*/} + { + datay===undefined? + "" + :datay.map((item,key)=>{ + return( +
+
+ +
+

+ + {item.target.name} + {item.unread === true? + + :""} + + {(time)=>this.FormatTime(item.send_time)} +

+

+
+ +
+
+ ) + })} + + + + +
+
+ + +
+ + + + + + + + +
) } } -export default MessagChat; \ No newline at end of file +export default MessagChat; + + +// onClick="delete_confirm_box('/users/innov/delete_message?mess_id=25137', '确定要删除该条记录吗?')" +// +// {/*左边*/} +//
+// 71519?1564061748 +//
+// +//
你好
+//
+// 删除 +//
+//
+// 22:21 +//
\ No newline at end of file diff --git a/public/react/src/modules/message/js/MessagSub.js b/public/react/src/modules/message/js/MessagSub.js index a58d059a7..bf61fc3ff 100644 --- a/public/react/src/modules/message/js/MessagSub.js +++ b/public/react/src/modules/message/js/MessagSub.js @@ -4,7 +4,8 @@ import { Pagination, } from "antd"; import axios from 'axios'; - +import {getImageUrl} from 'educoder'; +import "../css/messagemy.css" //消息页面 class MessagSub extends Component{ constructor(props) { @@ -14,14 +15,15 @@ class MessagSub extends Component{ limit:10, typeysl:"", count:0, - isSpin:true, + isSpin:false, + data:undefined, } } // 初始化数据 componentDidMount(){ - debugger console.log("初始化数据了"); this.getdata("",this.state.page); + // this.Messageprivatemessageunreadmessage(); } //塞选页数 @@ -45,18 +47,20 @@ class MessagSub extends Component{ per_page:limit, }}).then((result) => { if (result) { - console.log(types); - console.log(result); + // console.log(types); + // console.log(result); if(result.data.message!==undefined){ - console.log("5151515151"); + // console.log("5151515151"); return; } - console.log("调用了消失的方法"); - console.log("5454545454"); + // 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, }) } }).catch((error) => { @@ -74,48 +78,93 @@ class MessagSub extends Component{ } } render() { - let{page,limit,typeysl,count,isSpin}=this.state; - console.log("6868686868"); - console.log(isSpin); + let{page,limit,typeysl,count,isSpin,data}=this.state; + // console.log("6868686868"); + // console.log(data); return (
{/*头部筛选数据*/} {/*下面内容页面*/} -
+
{/*这里可以进行数据处理*/} - -
- - -
+
+ + + { + data===undefined? +
+ +

暂无数据哦~

+
+ :data.map((item,key)=>{ + return( +
+
+ +
+

+ {item.trigger_user.name} + {item.time} + {this.state.typeysl==="apply"?( + item.status===0? + 待处理:"" + ):""} + {this.state.typeysl==="apply"?( + item.status===1? + 已处理:"" + ):""} + +

+

+ { + item.content + } +

+ +
+ + +
+ +
+ ) + })}
{/*页数*/} -
-
- + { data===undefined?"" + : + (count>10? +
+
+ +
+
:"" + ) + + }
-
diff --git a/public/react/src/modules/message/js/MessagePrivate.js b/public/react/src/modules/message/js/MessagePrivate.js index 7a7c61174..8885d101b 100644 --- a/public/react/src/modules/message/js/MessagePrivate.js +++ b/public/react/src/modules/message/js/MessagePrivate.js @@ -1,20 +1,158 @@ import React, { Component } from 'react'; +import { + Spin, + Pagination, +} from "antd"; +import axios from 'axios'; +import {getImageUrl} from 'educoder'; +import "../css/messagemy.css" +import WriteaprivateletterModal from '../messagemodal/WriteaprivateletterModal'; //私信页面 class MessagePrivate extends Component{ constructor(props) { super(props); this.state={ - - } + page:1, + limit:10, + count:0, + data:undefined, + isSpin:false, + modalsType:false, + }; + console.log("MessagePrivate"); + console.log(this.props); } componentDidMount(){ + this.getdata(1); + }; + + //获取数据地方 + getdata=(page)=>{ + this.setState({ + isSpin:true, + }); + let{limit}=this.state; + let url = `/users/${this.props.current_user.user_id}/private_messages.json`; + // let url = `/users/71519/private_messages.json`; + axios.get((url),{params:{ + page:page, + 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, + 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); + this.setState({ + isSpin:false, + }) + }) + }; + + paginationonChanges=(pageNumber)=>{ + this.setState({ + page: pageNumber, + }) + this.getdata(pageNumber); + }; + okmodalsType=()=>{ + this.setState({ + modalsType:true, + }) + } + cancelmodalsType=()=>{ + this.setState({ + modalsType:false, + }) + }; + // 跳转页面 + smyJump =(i)=>{ + console.log("跳转页面"); + console.log(i); + this.props.Modifyur(i); } render() { + let{page,limit,typeysl,count,isSpin,data,modalsType}=this.state; + // console.log( this.props); + // console.log("37"); return (
+ { + modalsType===true? + this.smyJump(is)} > + :"" + } +
+

+ 全部私信 + this.okmodalsType()}>写私信 +

+ + + { + data===undefined? +
+ +

暂无数据哦~

+
+ :data.map((item,key)=>{ + return( + +
this.smyJump(3)}> + + + +
+

+ this.smyJump()} className="mr20 private_message_a">{item.target.name} + 与你的私信 + [{item.message_count}{"条"}] + {item.send_time} +

+ + +
+ {item.unread === true ?:""} +
+ ) + })} +
+ + +
+ + {/*页数*/} + { data===undefined?"" + : + (count>10? +
+
+ +
+
+ :"" + ) + + }
+ ) } } diff --git a/public/react/src/modules/message/js/Messagerouting.js b/public/react/src/modules/message/js/Messagerouting.js index 6cf717e6d..56eafec7e 100644 --- a/public/react/src/modules/message/js/Messagerouting.js +++ b/public/react/src/modules/message/js/Messagerouting.js @@ -16,21 +16,71 @@ class Messagerouting extends Component{ super(props); this.state={ routing:1, + unread_message_count:0, + unread_tiding_count:0, } } componentDidMount(){ } - // 切换路由 + 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.Messageprivatemessageunreadmessage(this.props.current_user.user_id); + } + } + //消息未读 + Messageprivatemessageunreadmessage=(user_id)=>{ + const url=`/users/${user_id}/unread_message_info.json` + axios.get(url).then((result) => { + if(result===undefined){ + return + } + console.log("消息未读1"); + console.log(result); + this.setState({ + unread_message_count:result.data.unread_message_count, + unread_tiding_count:result.data.unread_tiding_count, + }) + }).catch((error) => { + console.log(error) + }) + }; SwitchonClick=(value)=>{ this.setState({ routing:value, - }) + }); + this.Messageprivatemessageunreadmessage(this.props.current_user.user_id); + }; + + + + Message2=(data)=>{ + console.log("64"); + console.log(data); + this.setState({ + unread_message_count:data.unread_message_count, + unread_tiding_count:data.unread_tiding_count, + }) + }; + + //跳转到链接 + Modifyur=(i)=>{ + console.log("跳转到链接"); + console.log(i); + this.setState({ + routing:i, + }) } render() { - let{routing} =this.state; + let{routing,unread_message_count,unread_tiding_count} =this.state; + console.log(this.props); return (
@@ -38,34 +88,36 @@ class Messagerouting extends Component{
{/*头像*/}
- - + + -

杨树林

-

工程师

+

{this.props.current_user&&this.props.current_user.username}

+

{this.props.current_user&&this.props.current_user.user_identity}

{/*路由跳转*/}
{/*右边*/}
-
+
{/*消息自路由*/} - {routing===1? :""} + {routing===1?this.Message2()}> :""} {/*私信*/} - {routing===2? :""} + {routing===2?this.Message2()} Modifyur={(i)=>this.Modifyur(i)}> :""} {/*私信聊天页面*/} - {routing===3?:""} + {routing===3?this.Message2()} Modifyur={(i)=>this.Modifyur(i)}>:""}
diff --git a/public/react/src/modules/message/messagemodal/WriteaprivateletterModal.js b/public/react/src/modules/message/messagemodal/WriteaprivateletterModal.js new file mode 100644 index 000000000..bb23b4f25 --- /dev/null +++ b/public/react/src/modules/message/messagemodal/WriteaprivateletterModal.js @@ -0,0 +1,354 @@ +import React, { Component } from 'react'; +import { Modal,Input,Icon,Tooltip,Spin} from 'antd'; +import axios from 'axios'; +// import '../../modules/user/common.css'; +//完善个人资料 +class WriteaprivateletterModal extends Component { + + constructor(props) { + super(props) + this.state ={ + modalsType:false, + Pleaseselectthesender:false, + Pleaseselectthesenders:false, + inputvulue:"", + inputvulues:"", + floatingboxdisplay:false, + users:[], + Personalid:undefined, + isSpin:false, + Recentcontacts:false, + floatingboxdisplays:false, + + } + + } + componentDidMount() { + //用户id + console.log(this.props.current_user.user_id); + this.Recentcontacts(); + + } + //获取最近联系人 + Recentcontacts=()=>{ + this.setState({ + isSpin:true + }); + const url =`/users/${this.props.current_user.user_id}/recent_contacts.json` + axios.get(url).then((result) => { + if(result===undefined){ + return + } + console.log(result); + this.setState({ + users:result.data.users, + Recentcontacts:false, + floatingboxdisplay:true, + isSpin:false + }) + }).catch((error) => { + console.log(error) + this.setState({ + isSpin:false + }) + }) + }; + + //发送私信 + SendprivatemessageAPI=(idvalue,contentvalue)=>{ + const url =`/users/${this.props.current_user.user_id}/private_messages.json` + let data={ + target_id:idvalue, + content:contentvalue, + } + axios.post(url, data).then((result) => { + if(result===undefined){ + return + } + this.setState({ + floatingboxdisplays:false, + Pleaseselectthesender:false, + }); + this.props.smyJump(3); + console.log(result); + }).catch((error) => { + console.log(error) + }) + }; + + //搜索私信人 + Retrieveprivatemessageusers=(value)=>{ + this.setState({ + isSpin:true + }) + const url =`/users_for_private_messages.json` + axios.get((url),{params:{ + keyword:value, + }}).then((result) => { + if(result===undefined){ + return + } + this.setState({ + users:result.data.users, + Recentcontacts:true, + floatingboxdisplay:true, + isSpin:false + }) + console.log(result); + }).catch((error) => { + console.log(error) + this.setState({ + isSpin:false + }) + }) + }; + + modalCancel=()=>{ + // var weekArray = JSON.parse(window.sessionStorage.getItem('yslgeturls')); + // if(weekArray===undefined){ + // weekArray="/"; + // } + // if(weekArray===null){ + // weekArray="/"; + // } + // if(weekArray==="null"){ + // weekArray="/"; + // } + // window.location.href = weekArray; + } + + setDownload=()=>{ + // window.location.href ='/account/profile'; + }; + + // 搜索 + search_message_person=()=>{ + console.log("点击搜索按钮"); + if(this.state.inputvulue.length===0){ + this.Recentcontacts(); + }else { + this.Retrieveprivatemessageusers(this.state.inputvulue); + + } + }; + + //取消事件 + HideModal=()=>{ + this.props.cancelmodalsType(); + }; + + //确认事件 + OKModal=()=>{ + let{inputvulue,Personalid,inputvulues}=this.state; + // console.log("发送私信了"); + // console.log(inputvulue); + // console.log(Personalid); + // console.log(inputvulues); + if(inputvulue.length===0){ + this.setState({ + Pleaseselectthesender:true + }); + return; + + } + if(inputvulues.length===0){ + this.setState({ + floatingboxdisplays:true + }) + return; + } + else { + if(Personalid===undefined){ + this.setState({ + Pleaseselectthesender:true + }); + return + } + + + this.SendprivatemessageAPI(Personalid,inputvulues) + + } + }; + + // 回车事件 + Myοnkeydοwn=()=>{ + console.log("点击了回车事件"); + if(this.state.inputvulue.length===0){ + this.Recentcontacts(); + }else { + this.Retrieveprivatemessageusers(this.state.inputvulue); + + } + }; + + //判断点击的键盘的keyCode是否为13,是就调用上面的搜索函数 + handleEnterKey = (e) => { + console.log(""); + if(e.nativeEvent.keyCode === 13){ //e.nativeEvent获取原生的事件对像 + this.Myοnkeydοwn() + } + }; + // 查找联系人输入模式 + setdatafunsval=(e)=>{ + if(e.target.value.length===0){ + this.setState({ + inputvulue:e.target.value, + Pleaseselectthesender:false, + floatingboxdisplay:true, + Personalid:undefined + }); + this.Recentcontacts(); + }else { + this.setState({ + inputvulue:e.target.value, + Pleaseselectthesender:false, + floatingboxdisplay:true, + }); + } + + console.log(e.target.value); + }; + // 输入内容 + setdatafunsvals=(e)=>{ + console.log(e.target.value); + this.setState({ + inputvulues:e.target.value, + Pleaseselectthesenders:false, + floatingboxdisplays:false, + floatingboxdisplay:false, + }); + } + //失去焦点 + myonBlur=(e)=>{ + console.log("失去焦点了"); + e.preventDefault(); + this.setState({ + // floatingboxdisplay:false, + }) +}; + //获取焦点 + myonFocus=(e)=>{ + console.log("获取到焦点了"); + this.setState({ + floatingboxdisplay:true, + }) + }; + + //获取用户信息 + Getuserinformation=(item)=>{ + console.log("获取到了用户信息"); + console.log(item.id); + this.setState({ + Personalid:item.id===undefined?undefined:item.id===null?undefined:item.id, + inputvulue:item.name, + floatingboxdisplay:false, + }) + } + + + render() { + // console.log(this.props) + let{Pleaseselectthesender,inputvulue,inputvulues,floatingboxdisplay,users,floatingboxdisplays,Recentcontacts,isSpin}=this.state; + return( + +
+
+ {/*搜索框*/} + {/*
*/} + {/* */} + {/* */} + {/* this.search_message_person()}/>*/} + {/*
*/} +
+ this.search_message_person()}/> + } + /> +
+ {/*搜索框下面悬浮框*/} +
+ +

{Recentcontacts===false?"最近联系人":"搜索结果"}

+ + { + users.map((item,key)=>{ + return( +

this.Getuserinformation(item)}> + 1?1558048024 + {item.name} +

+ ) + }) + } +
+ {/*

*/} + {/* 1?1558048024*/} + {/* 实践教学*/} + {/*

*/} + {/*

*/} + {/* B?1532489442*/} + {/* innov*/} + {/*

*/} + +
+ + +
+ {/*私信内容*/} +
+ + 200 +
+
+ { + Pleaseselectthesender === true ? +

请选择发送对象

+ :(floatingboxdisplays ===false?

:"") + } + { + floatingboxdisplays===true? +

请输入发送内容

+ : "" + } + {/*确认事件*/} +

+ this.HideModal()} className="pop_close task-btn mr30">取消 + this.OKModal()} id="submit_send_letter">确定 +

+ {/*
*/} + {/*

完善您的资料,将获得更多的使用权限

*/} + {/* */} + {/*
*/} +
+ ) + } +} + +export default WriteaprivateletterModal; \ No newline at end of file