dev_cs_new
杨树林 6 years ago
parent cad8f2fbbd
commit f3a744b712

@ -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)

@ -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 = {};

@ -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 <div></div>
}
return (
<React.Fragment>
<style>{`
.mockInputWrapper {
display: flex;
padding: 30px;
}
.mockInputWrapper input {
flex:1;
padding-left: 10px;
height: 40px;
background: rgb(246,246,246);
margin-right: 20px;
}
.mockInputWrapper a.commentsbtn {
height: 40px;
display: inline-block;
margin-top: 0px !important;
vertical-align: text-top;
padding-top: 6px;
width: 60px;
margin-right: 0px !important;
}
#commentInput .editormd{
width:100%!important;
}
`}</style>
<div style={{ display: isInited ? 'none' : ''}} className="mockInputWrapper" id="commentInput">
<input onClick={this.onMockInputClick} placeholder={placeholder || '我要回复'}></input>
<a href="javascript:void(0)"
onClick={this.onMockInputClick} className="commentsbtn task-btn task-btn-blue">
发送
</a>
</div>
<div nhname={`new_message_${memo.id}`} className=""
style={{ padding: '30px',boxSizing:"border-box", display: isInited ? '' : 'none' }} id="commentInput">
<div id="memo_comment_editorMd" className="editorMD" style={{ marginBottom: '0px'
, border: errorMsg ? '1px solid red' : '1px solid #ddd'}}>
<textarea style={{'display': 'none'}}>
</textarea>
</div>
<div className="editor__resize" href="javascript:void(0);">调整高度</div>
{ errorMsg && <input className="fl" style={{color: 'red', marginTop: '6px',
marginLeft: '4px'}}>{errorMsg}</input> }
<a id={`new_message_submit_btn_${memo.id}`} href="javascript:void(0)"
onClick={this.onCommit} className="commentsbtn task-btn-blue task-btn fr ">
发送
</a>
</div>
</React.Fragment>
);
}
}
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 <div></div>
}
return (
<React.Fragment>
<style>{`
.mockInputWrapper {
display: flex;
padding: 30px;
}
.mockInputWrapper input {
flex:1;
padding-left: 10px;
height: 40px;
background: rgb(246,246,246);
margin-right: 20px;
}
.mockInputWrapper a.commentsbtn {
height: 40px;
display: inline-block;
margin-top: 0px !important;
vertical-align: text-top;
padding-top: 6px;
width: 60px;
margin-right: 0px !important;
}
#commentInput .editormd{
width:100%!important;
}
`}</style>
<div style={{ display: isInited ? 'none' : ''}} className="mockInputWrapper" id="commentInput">
<input onClick={this.onMockInputClick} placeholder={placeholder || '我要回复'}></input>
<a href="javascript:void(0)"
onClick={this.onMockInputClick} className="commentsbtn task-btn task-btn-blue">
发送
</a>
</div>
<div nhname={`new_message_${memo.id}`} className=""
style={{ padding: '30px',boxSizing:"border-box", display: isInited ? '' : 'none' }} id="commentInput">
<div id="memo_comment_editorMd" className="editorMD" style={{ marginBottom: '0px'
, border: errorMsg ? '1px solid red' : '1px solid #ddd'}}>
<textarea style={{'display': 'none'}}>
</textarea>
</div>
<div className="editor__resize" href="javascript:void(0);">调整高度</div>
{ errorMsg && <input className="fl" style={{color: 'red', marginTop: '6px',
marginLeft: '4px'}}>{errorMsg}</input> }
<a id={`new_message_submit_btn_${memo.id}`} href="javascript:void(0)"
onClick={this.onCommit} className="commentsbtn task-btn-blue task-btn fr ">
发送
</a>
</div>
</React.Fragment>
);
}
}
export default ( MemoDetailMDEditortwo );

@ -3,4 +3,67 @@
}
.myh120{
height: 120px;
}
}
.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;
}

@ -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<result.data.private_messages.length;i++){
this.state.datay.push(result.data.private_messages[i]);
}
}
}
}
this.setState({
page:page,
isSpins:false,
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({
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 (
<div>
<div className="edu-back-white ml20">
{/*私信对话框*/}
<div className="df clearfix">
{/*左边*/}
<div className="flex1">
<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>
117llj与你的私信
</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="1?1558048024" 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 href="javascript:void(0)" className="color-grey-c"
>删除</a>
</div>
</div>
<span className="fr mr15 color-grey-c lineh-15 mt15">22:20</span>
</div>
</div>
</div>
</div>
{/*回复*/}
<div className="bor-top-greyE padding20">
</div>
</div>
{/*右边*/}
<div className="bor-left-greyE" style={{width:"290px"}}>
{/*右边头部*/}
<p className="pt30 pb30 pl30 edu-txt-left font-16 bor-bottom-greyE">私信列表</p>
<Spin size="large" className="myw100baifenbi" spinning={isSpins}>
<div className="private-list " style={{maxHeight:"628px"}} onScroll={this.contentViewScrolledit}>
{/*列表数据*/}
{
datay===undefined?
""
:datay.map((item,key)=>{
return(
<div className="private-part clearfix" key={key}>
<div className="part-line df">
<img src={item.target.image_url} className="radius mr10 myimgw48 myimgh48"/>
<div className="flex1">
<p className="clearfix mb15 lineh-17">
<span className="fl pr">
<span className="task-hide privatePartName">{item.target.name}</span>
{item.unread === true?
<span className="newLetter"></span>
:""}
</span>
<span className="color-grey-c fr">{(time)=>this.FormatTime(item.send_time)}</span>
</p>
<p className="color-grey-6 lineh-20 justify break_word task-hide-2" style={{wordBreak:"break-word"}} dangerouslySetInnerHTML={{__html:item.content}}></p>
</div>
</div>
</div>
)
})}
</div>
</Spin>
</div>
</div>
</div>
)
}
}
export default MessagChat;
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>

@ -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 (
<div className="clearfix ml20">
{/*头部筛选数据*/}
<ul className="pl10 ridingNav clearfix edu-back-white">
<li className={typeysl===""?"active":""}><a onClick={()=>this.getdata("")}>全部消息</a></li>
<li className={typeysl===""?"active":""}><a onClick={(s,i)=>this.getdata("",1)}>全部</a></li>
<li className={typeysl&&typeysl==="course"?"active":""} ><a onClick={()=>this.getdata("course")}>课堂提醒</a></li>
<li className={typeysl&&typeysl==="course"?"active":""} ><a onClick={(s,i)=>this.getdata("course",1)}>课堂提醒</a></li>
<li className={typeysl&&typeysl==="project"?"active":""} ><a onClick={()=>this.getdata("project")}>项目提醒</a></li>
<li className={typeysl&&typeysl==="project"?"active":""} ><a onClick={(s,i)=>this.getdata("project",1)}>项目提醒</a></li>
<li className={typeysl&&typeysl==="project_package"?"active":""}><a onClick={()=>this.getdata("project_package")}>众包</a></li>
<li className={typeysl&&typeysl==="project_package"?"active":""}><a onClick={(s,i)=>this.getdata("project_package",1)}>众包提醒</a></li>
<li className={typeysl&&typeysl==="apply"?"active":""}><a onClick={()=>this.getdata("apply")}>审核</a></li>
<li className={typeysl&&typeysl==="interactive"?"active":""}><a onClick={(s,i)=>this.getdata("interactive",1)}>互动提醒</a></li>
<li className={typeysl&&typeysl==="system"?"active":""}><a onClick={()=>this.getdata("system")}>通知</a></li>
<li className={typeysl&&typeysl==="apply"?"active":""}><a onClick={(s,i)=>this.getdata("apply",1)}>审核</a></li>
<li className={typeysl&&typeysl==="system"?"active":""}><a onClick={(s,i)=>this.getdata("system",1)}>通知</a></li>
<li className={typeysl&&typeysl==="interactive"?"active":""}><a onClick={()=>this.getdata("interactive")}>互动提醒</a></li>
</ul>
{/*下面内容页面*/}
<div className="bor-top-greyE">
<div className="bor-top-greyE mycenter">
{/*这里可以进行数据处理*/}
<Spin size="large" spinning={isSpin}>
<div className="pl25 ridinglist edu-back-white">
</div>
<div className="myw100baifenbi">
<Spin size="large" className="myw100baifenbi" spinning={isSpin}>
{
data===undefined?
<div className="edu-tab-con-box clearfix edu-txt-center">
<img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb20">暂无数据哦~</p>
</div>
:data.map((item,key)=>{
return(
<div className="pl25 ridinglist edu-back-white" key={key}>
<div className="ridinglist-sub clearfix df tiding_item">
<img src={item.trigger_user.image_url} className="radius mr10 fl myimgw48 myimgh48"/>
<div className="fl flex1">
<p>
<span className="mr20">{item.trigger_user.name}</span>
<span className="color-grey-c">{item.time}</span>
{this.state.typeysl==="apply"?(
item.status===0?
<span className="edu-filter-btn ml20 edu-filter-btn-red">待处理</span>:""
):""}
{this.state.typeysl==="apply"?(
item.status===1?
<span className="edu-filter-btn ml20 edu-filter-btn-green">已处理</span>:""
):""}
</p>
<p className="color-grey-6 break_word_firefox" style={{wordBreak: "break-word"}}>
{
item.content
}
</p>
</div>
<span className={item.new_tiding===true?"new-point fr mr40 mt22":""}></span>
</div>
</div>
)
})}
</Spin>
{/*页数*/}
<div style={{textAlign:"center"}} class="new_expand mt10">
<div className="edu-txt-center mt30">
<Pagination showQuickJumper current={page}
onChange={this.paginationonChanges} pageSize={limit}
total={count}></Pagination>
{ data===undefined?""
:
(count>10?
<div style={{textAlign: "center"}} className="new_expand mt10">
<div className="edu-txt-center mt30">
<Pagination showQuickJumper current={page}
onChange={this.paginationonChanges} pageSize={limit}
total={count}></Pagination>
</div>
</div>:""
)
}
</div>
</div>
</div>
</div>

@ -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 (
<div>
{
modalsType===true?
<WriteaprivateletterModal {...this.state} {...this.props} modalsType={modalsType} cancelmodalsType={this.cancelmodalsType} smyJump={(is)=>this.smyJump(is)} ></WriteaprivateletterModal>
:""
}
<div className="edu-back-white ml25">
<p className="clearfix font-16 padding30-20 bor-bottom-greyE">
<span className="fl">全部私信</span>
<a href="javascript:void(0);" className="color-blue fr" onClick={()=>this.okmodalsType()}>写私信</a>
</p>
<Spin size="large" className="myw100baifenbi" spinning={isSpin}>
{
data===undefined?
<div className="edu-tab-con-box clearfix edu-txt-center">
<img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb20">暂无数据哦~</p>
</div>
:data.map((item,key)=>{
return(
<div className="private-item clearfix df" key={key} onClick={(i)=>this.smyJump(3)}>
<a className="fl mr10 private_message_a">
<img src={item.target.image_url} className="radius myimgw48 myimgh48"/>
</a>
<div className="fl flex1">
<p>
<a href="javascript:void(0);" onClick={()=>this.smyJump()} className="mr20 private_message_a">{item.target.name}</a>
<span>与你的私信</span>
<span className="color-grey-c mr20">[{item.message_count}{"条"}]</span>
<span className="color-grey-c">{item.send_time}</span>
</p>
<span className="color-grey-6 break_word_firefox " dangerouslySetInnerHTML={{__html:item.content}}></span>
</div>
{item.unread === true ?<span className="new-point fr mt22"></span>:""}
</div>
)
})}
</Spin>
</div>
{/*页数*/}
{ data===undefined?""
:
(count>10?
<div style={{textAlign: "center"}} className="new_expand mt10">
<div className="edu-txt-center mt30">
<Pagination showQuickJumper current={page}
onChange={this.paginationonChanges} pageSize={limit}
total={count}></Pagination>
</div>
</div>
:""
)
}
</div>
)
}
}

@ -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 (
<div className="newMain clearfix">
<div className="educontent mt20 mb80 clearfix">
@ -38,34 +88,36 @@ class Messagerouting extends Component{
<div className="leftPanel">
{/*头像*/}
<div className="mb20 edu-back-white pt40 pb40 edu-txt-center">
<a>
<img className="person radius myw120 myh120" src={"/images/avatars/User/71519?1564061748"}/>
<a href="javascript:void(0);">
<img className="person radius myw120 myh120" src={this.props.current_user&&this.props.current_user.image_url}/>
</a>
<p className="font-24 lineh-25 mt10" >杨树林</p>
<p className="color-grey-6 mt5" >工程师</p>
<p className="font-24 lineh-25 mt10" >{this.props.current_user&&this.props.current_user.username}</p>
<p className="color-grey-6 mt5" >{this.props.current_user&&this.props.current_user.user_identity}</p>
</div>
{/*路由跳转*/}
<ul className="edu-back-white">
<li className={routing ===1?"nav pr active":"nav pr"}>
<a onClick={(value)=>this.SwitchonClick(1)}>消息</a>
{unread_tiding_count>0?<span className="new-info">{unread_message_count}</span>:""}
</li>
<li className={routing ===2?"nav pr active":"nav pr"}>
<li className={routing ===2?"nav pr active":routing ===3?"nav pr active":"nav pr"}>
<a onClick={(value)=>this.SwitchonClick(2)}>私信</a>
{unread_tiding_count>0?<span className="new-info">{unread_tiding_count}</span>:""}
</li>
</ul>
</div>
{/*右边*/}
<div className="rightPanel">
<div className="clearfix ml20">
<div className="clearfix">
{/*消息自路由*/}
{routing===1?<MessagSub></MessagSub> :""}
{routing===1?<MessagSub {...this.state} {...this.props} Message2={()=>this.Message2()}></MessagSub> :""}
{/*私信*/}
{routing===2?<MessagePrivate></MessagePrivate> :""}
{routing===2?<MessagePrivate {...this.state} {...this.props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)}></MessagePrivate> :""}
{/*私信聊天页面*/}
{routing===3?<MessagChat></MessagChat>:""}
{routing===3?<MessagChat {...this.state} {...this.props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)}></MessagChat>:""}
</div>
</div>
</div>

@ -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(
<Modal
keyboard={false}
closable={false}
footer={null}
destroyOnClose={true}
title={"写私信"}
centered={true}
visible={this.props.modalsType}
width="550px"
>
<div >
<div className="mb20 pr">
{/*搜索框*/}
{/*<div className="search-new myw100baifenbi" >*/}
{/* <input type="text" className="search-new-input fl " value={inputvulue} onKeyPress={this.handleEnterKey} onBlur={this.myonBlur} onFocus={this.myonFocus} onChange={this.setdatafunsval} utoComplete="off"*/}
{/* placeholder="发送给..." id="sendFor"/>*/}
{/* <span className="search-span"></span>*/}
{/* <img src={"/images/educoder/icon/search.svg"} className="fl mt5"*/}
{/* onClick={()=>this.search_message_person()}/>*/}
{/*</div>*/}
<div className="myw100baifenbi">
<Input
className=""
placeholder="发送给..."
value={inputvulue}
onKeyPress={this.handleEnterKey}
onBlur={this.myonBlur}
onFocus={this.myonFocus}
onChange={this.setdatafunsval}
suffix={
<img src={"/images/educoder/icon/search.svg"} onClick={()=>this.search_message_person()}/>
}
/>
</div>
{/*搜索框下面悬浮框*/}
<div className="recently_person" style={floatingboxdisplay===false?{display: "none"}:{display: "block"}}>
<Spin size="large" className="myw100baifenbi" spinning={isSpin}>
<p className="padding10-20 color-grey-9 cdefault">{Recentcontacts===false?"最近联系人":"搜索结果"}</p>
{
users.map((item,key)=>{
return(
<p className="clearfix recently_item" onMouseDown={(c)=>this.Getuserinformation(item)}>
<img alt="1?1558048024" className="radius fl mr10 myimgw48 myimgh48" src={item.image_url}
/>
<span className="recently_name">{item.name}</span>
</p>
)
})
}
</Spin>
{/*<p className="clearfix recently_item">*/}
{/* <img alt="1?1558048024" className="radius fl mr10 myimgw48 myimgh48" src={"/images/avatars/User/1?1558048024"}*/}
{/* />*/}
{/* <span className="recently_name" data-user="1">实践教学</span>*/}
{/*</p>*/}
{/*<p className="clearfix recently_item">*/}
{/* <img alt="B?1532489442" className="radius fl mr10 myimgw48 myimgh48" src={"/images/avatars/User/b?1532489442"}*/}
{/* />*/}
{/* <span className="recently_name" data-user="20523">innov</span>*/}
{/*</p>*/}
</div>
</div>
{/*私信内容*/}
<div className="writeLetter_Info">
<textarea className="writeLetter_text greyInput" value={inputvulues} onChange={this.setdatafunsvals} name="content" id="writeLetter_text"
maxLength="200"></textarea>
<span className="longchar">200</span>
</div>
</div>
{
Pleaseselectthesender === true ?
<p className="color-orange-tip " style={{height: "25px"}}><span id="notice_send_person">请选择发送对象</span></p>
:(floatingboxdisplays ===false?<p style={{height:"25px"}}></p>:"")
}
{
floatingboxdisplays===true?
<p className="color-orange-tip " style={{height: "25px"}}><span id="notice_send_person">请输入发送内容</span></p>
: ""
}
{/*确认事件*/}
<p className="clearfix edu-txt-center">
<a href="javascript:void(0);" onClick={()=>this.HideModal()} className="pop_close task-btn mr30">取消</a>
<a href="javascript:void(0);" className="task-btn task-btn-orange" onClick={()=>this.OKModal()} id="submit_send_letter">确定</a>
</p>
{/*<div className="educouddiv">*/}
{/* <div className={"tabeltext-alignleft"}><p style={{fontSize: "16px"}}>完善您的资料,将获得更多的使用权限</p></div>*/}
{/* <div className="clearfix mt30 edu-txt-center">*/}
{/* <a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a>*/}
{/* <a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>立即完善</a>*/}
{/* </div>*/}
{/*</div>*/}
</Modal>
)
}
}
export default WriteaprivateletterModal;
Loading…
Cancel
Save