Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_admin
daiao 6 years ago
commit d49e8ba5f3

@ -911,6 +911,7 @@ class CoursesController < ApplicationController
CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id]) CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id) StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id)
end end
student_role = 1
end end
# 创建教师身份 # 创建教师身份
@ -928,19 +929,21 @@ class CoursesController < ApplicationController
course_message.save! course_message.save!
role = course_message.content == 2 ? '7' : '9' # 7:助教 9:教师 role = course_message.content == 2 ? '9' : '7' # 7:助教 9:教师
ApplyTeacherRoleJoinCourseNotifyJob.perform_later(current_user.id, course.id, role) ApplyTeacherRoleJoinCourseNotifyJob.perform_later(current_user.id, course.id, role)
message = "#{course_message.content == 2 ? '教' : ''}申请已提交,请等待审核" message = "#{course_message.content == 2 ? '' : '教'}申请已提交,请等待审核"
else else
message = "#{existing_course_message.content == 2 ? '教' : ''}申请已提交,请等待审核" message = "#{existing_course_message.content == 2 ? '' : '教'}申请已提交,请等待审核"
end end
else
message = "您已是课堂成员"
end end
teacher_role = 1 teacher_role = 1
end end
if teacher_role && current_user.student_of_course?(course) if teacher_role && student_role
render json: { status: 0, message: message, course_id: course.id} render json: { status: 0, message: message, course_id: course.id}
elsif current_user.student_of_course?(course) elsif student_role
render json: { status: 0, message: "加入成功", course_id: course.id} render json: { status: 0, message: "加入成功", course_id: course.id}
else else
normal_status(message) normal_status(message)

@ -1,7 +1,7 @@
class DiscussesController < ApplicationController class DiscussesController < ApplicationController
LIMIT = 10 LIMIT = 10
before_action :find_container, only: [:index, :hidden] before_action :find_container, only: [:index, :hidden]
before_action :find_discuss, except: [:create, :index, :new_message, :reward_code, :forum_discusses] before_action :find_discuss, except: [:create, :index, :new_message, :reward_code, :forum_discusses, :plus]
def index def index
page = params[:page].to_i page = params[:page].to_i

@ -30,6 +30,7 @@ module TidingDecorator
end end
def strip_html(text, len = 0, suffix = "...") def strip_html(text, len = 0, suffix = "...")
text = text.to_s
str = "" str = ""
if !text.nil? && text.length > 0 if !text.nil? && text.length > 0
str = text.gsub(/<\/?.*?>/, '').strip str = text.gsub(/<\/?.*?>/, '').strip

@ -130,15 +130,15 @@ module ApplicationHelper
if source.class.to_s == 'User' if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"]) File.join(relative_path, ["#{source.class}", "#{source.id}"])
else else
File.join("images/avatars", ["#{source.class}", "#{source.id}"]) File.join("avatars", ["#{source.class}", "#{source.id}"])
end end
elsif source.class.to_s == 'User' elsif source.class.to_s == 'User'
str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g" str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g"
File.join(relative_path, "#{source.class}", str) File.join(relative_path, "#{source.class}", str)
elsif source.class.to_s == 'Subject' elsif source.class.to_s == 'Subject'
File.join("images","educoder", "index", "subject", "subject#{rand(17)}.jpg") File.join("educoder", "index", "subject", "subject#{rand(17)}.jpg")
elsif source.class.to_s == 'Shixun' elsif source.class.to_s == 'Shixun'
File.join("images","educoder", "index", "shixun", "shixun#{rand(23)}.jpg") File.join("educoder","index", "shixun", "shixun#{rand(23)}.jpg")
end end
end end

@ -9,6 +9,7 @@ class ApplyAddSchool < ApplicationRecord
private private
def send_notify def send_notify
tidings.create!(user_id: 1, status: 0, trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply') Tiding.create!(user_id: 1, status: 0, container_id: id, container_type: 'ApplyAddSchools',
trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply')
end end
end end

@ -28,7 +28,7 @@ class CourseMessage < ApplicationRecord
def send_deal_tiding def send_deal_tiding
# 发送申请处理结果消息 # 发送申请处理结果消息
Tiding.create!( Tiding.create!(
user_id: user_id, trigger_user: User.current, container_id: course_id, container_type: 'DealCourse', user_id: course_message_id, trigger_user: User.current, container_id: course_id, container_type: 'DealCourse',
belong_container: course, extra: content.to_i == 2 ? '7' : '9', tiding_type: 'System', status: status == :PASSED ? 1 : 2 belong_container: course, extra: content.to_i == 2 ? '7' : '9', tiding_type: 'System', status: status == :PASSED ? 1 : 2
) )
# 将申请消息置为已处理 # 将申请消息置为已处理

@ -25,6 +25,8 @@ class JournalsForMessage < ApplicationRecord
# "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言
# "hidden", 隐藏 # "hidden", 隐藏
after_create :send_tiding
# course_identity 课堂用户身份 # course_identity 课堂用户身份
def contents_show course_identity def contents_show course_identity
@ -47,4 +49,29 @@ class JournalsForMessage < ApplicationRecord
JournalsForMessage.includes(:user).where(m_parent_id: self.id).page(page).per(limit).reorder("created_on asc") JournalsForMessage.includes(:user).where(m_parent_id: self.id).page(page).per(limit).reorder("created_on asc")
end end
def send_tiding
# 回复和@同一个人时:只发@的消息(因@的消息先创建)
case self.jour_type
# 用户留言当做私信处理 不发消息
when "Principal"
=begin
user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : self.jour_id
if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present?
self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => self.jour_id, :belong_container_type => "User", :viewed => 0, :tiding_type => self.m_parent_id.present? ? "Comment" : "Journal")
end
=end
when "HomeworkCommon", "GraduationTopic"
user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : (self.jour_type == "HomeworkCommon" ? self.jour.user_id : self.jour.tea_id)
if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present?
self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => self.jour.course_id, :belong_container_type => "Course", :viewed => 0, :tiding_type => "Comment")
end
when "StudentWorksScore"
course_id = self.jour.try(:student_work).try(:homework_common).try(:course_id)
user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : self.jour.user_id
if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present?
self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => course_id, :belong_container_type => "Course", :viewed => 0, :tiding_type => "Comment")
end
end
end
end end

@ -38,6 +38,7 @@ class Shixun < ApplicationRecord
belongs_to :user belongs_to :user
# 实训服务配置 # 实训服务配置
has_many :shixun_service_configs, :dependent => :destroy has_many :shixun_service_configs, :dependent => :destroy
has_many :tidings, as: :container, dependent: :destroy
scope :search_by_name, ->(keyword) { where("name like ? or description like ? ", scope :search_by_name, ->(keyword) { where("name like ? or description like ? ",
"%#{keyword}%", "%#{keyword}%") } "%#{keyword}%", "%#{keyword}%") }
@ -62,6 +63,8 @@ class Shixun < ApplicationRecord
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) } scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
scope :find_by_ids,lambda{|k| where(id:k)} scope :find_by_ids,lambda{|k| where(id:k)}
after_create :send_tiding
# REDO:  # REDO: 
def propaedeutics def propaedeutics
shixun_info.try(:propaedeutics) shixun_info.try(:propaedeutics)
@ -242,4 +245,11 @@ class Shixun < ApplicationRecord
def finished_challenges_count(user) def finished_challenges_count(user)
Game.joins(:myshixun).where(user_id: user.id, status: 2, myshixuns: { shixun_id: id }).count Game.joins(:myshixun).where(user_id: user.id, status: 2, myshixuns: { shixun_id: id }).count
end end
private
def send_tiding
self.tidings << Tiding.new(:user_id => user_id, :trigger_user_id => 1, :belong_container_id => id, :belong_container_type =>'Shixun', :tiding_type => "System", :viewed => 0)
end
end end

@ -9,16 +9,15 @@ class Tiding < ApplicationRecord
def identifier def identifier
value = nil value = nil
if Object.const_defined?(container_type)
value = container.try(:identifier)
end
if value.blank? && parent_container_type && Object.const_defined?(parent_container_type) value = container.try(:identifier) rescue nil
value = parent_container_type.try(:identifier)
if value.blank? && parent_container_type
value = parent_container_type.try(:identifier) rescue nil
end end
if value.blank? && belong_container_type && Object.const_defined?(belong_container_type) if value.blank? && belong_container_type
value = belong_container.try(:identifier) value = belong_container.try(:identifier) rescue nil
end end
value value

@ -234,7 +234,7 @@ class User < ApplicationRecord
# 课堂的老师(创建者、老师、助教),不用考虑当前身份 # 课堂的老师(创建者、老师、助教),不用考虑当前身份
def teacher_of_course_non_active?(course) def teacher_of_course_non_active?(course)
course.course_members.exists?(user_id: id, role: [1,2,3]) || admin? || business? course.course_members.exists?(user_id: id, role: [1,2,3])
end end
# 是否是教师,课堂管理员或者超级管理员 # 是否是教师,课堂管理员或者超级管理员

@ -11,6 +11,6 @@ if message.m_parent_id
json.can_delete message.can_delete(identity) json.can_delete message.can_delete(identity)
else else
json.praise_count message.praise_treads.select{|pt| pt.praise_or_tread == 1}.count json.praise_count message.praise_treads.select{|pt| pt.praise_or_tread == 1}.count
json.user_praise message.praise_treads.select{|pt| pt.praise_or_tread == 1 && user_id == current_user.id}.count json.user_praise message.praise_treads.select{|pt| pt.praise_or_tread == 1 && pt.user_id == current_user.id}.count
json.child_message_count message.m_reply_count json.child_message_count message.m_reply_count
end end

@ -9,6 +9,6 @@ json.memo do
json.tag memo.tag_repertoires.map(&:name) json.tag memo.tag_repertoires.map(&:name)
json.time memo.created_at json.time memo.created_at
json.replies_count memo.all_replies_count json.replies_count memo.all_replies_count
json.user_praise memo.praise_treads.user_liker(@user.try(:id)).count > 1 ? true : false json.user_praise memo.praise_treads.user_liker(@user.try(:id)).count > 0 ? true : false
json.memo_praise_count memo.praise_treads.liker.count json.memo_praise_count memo.praise_treads.liker.count
end end

@ -21,6 +21,9 @@
"7_2_end": "你提交的加入课堂申请:%s助教, 审核未通过" "7_2_end": "你提交的加入课堂申请:%s助教, 审核未通过"
StudentJoinCourse_end: "加入了课堂:%s学生" StudentJoinCourse_end: "加入了课堂:%s学生"
TeacherJoinCourse: TeacherJoinCourse:
"2_end": "%s将你加入课堂%s教师"
"3_end": "%s将你加入课堂%s助教"
"4_end": "%s将你加入课堂%s学生"
"9_end": "%s将你加入课堂%s教师" "9_end": "%s将你加入课堂%s教师"
"7_end": "%s将你加入课堂%s助教" "7_end": "%s将你加入课堂%s助教"
"10_end": "%s将你加入课堂%s学生" "10_end": "%s将你加入课堂%s学生"

@ -0,0 +1,5 @@
class TranferTidingData < ActiveRecord::Migration[5.2]
def change
Tiding.where(container_type: 'ApplyAddSchool').update_all(container_type: 'ApplyAddSchools')
end
end

Binary file not shown.

@ -351,16 +351,21 @@ class App extends Component {
{/*课堂*/} {/*课堂*/}
<Route path="/courses" component={CoursesIndex} {...this.props}></Route> <Route path="/courses" component={CoursesIndex} {...this.props}></Route>
{/* <Route path="/forums" component={ForumsIndexComponent}>
</Route> */}
<Route path="/forums"
render={
(props)=>(<ForumsIndexComponent {...this.props} {...props} {...this.state}></ForumsIndexComponent>)
}
>
</Route>
<Route path="/comment" component={CommentComponent}/> <Route path="/comment" component={CommentComponent}/>
<Route path="/testMaterial" component={TestMaterialDesignComponent}/> <Route path="/testMaterial" component={TestMaterialDesignComponent}/>
<Route path="/test" component={TestIndex}/> <Route path="/test" component={TestIndex}/>
<Route path="/testCodeMirror" component={TestCodeMirrorComponent}/> <Route path="/testCodeMirror" component={TestCodeMirrorComponent}/>
<Route path="/testRCComponent" component={TestComponent}/> <Route path="/testRCComponent" component={TestComponent}/>
<Route path="/testUrlQuery" component={TestUrlQueryComponent}/> <Route path="/testUrlQuery" component={TestUrlQueryComponent}/>
<Route path="/message" <Route path="/messages"
render={ render={
(props)=>(<Messagerouting {...this.props} {...props} {...this.state}></Messagerouting>) (props)=>(<Messagerouting {...this.props} {...props} {...this.state}></Messagerouting>)
} }

@ -75,6 +75,7 @@ class Addcourses extends Component{
if(e.target.checked===true){ if(e.target.checked===true){
this.setState({ this.setState({
assistant_professor:1, assistant_professor:1,
professor:null,
Checkboxteachingchecked:e.target.checked, Checkboxteachingchecked:e.target.checked,
Checkboxteachertype:true Checkboxteachertype:true
}) })
@ -95,6 +96,7 @@ class Addcourses extends Component{
if(e.target.checked===true){ if(e.target.checked===true){
this.setState({ this.setState({
professor:1, professor:1,
assistant_professor:null,
Checkboxteacherchecked:e.target.checked, Checkboxteacherchecked:e.target.checked,
Checkboxteachingtype:true Checkboxteachingtype:true
}) })

@ -57,7 +57,7 @@ class SchoolSelect extends Component{
const { value, onChange } = this.props; const { value, onChange } = this.props;
return ( return (
<AutoComplete allowClear placeholder="请输入单位名称" value={value} <AutoComplete allowClear placeholder="请输入单位名称" value={value}
style={{ width: '200px'}} style={{ width: '221px'}}
onSearch={this.onOrgNameSearch} onSearch={this.onOrgNameSearch}
onSelect={onChange} onSelect={onChange}
onChange={onChange} onChange={onChange}

@ -195,7 +195,7 @@ class AddStudentModal extends Component{
<div className="df"> <div className="df">
<span className="mr10">姓名:</span> <span className="mr10">姓名:</span>
<Input allowClear placeholder="请输入真实姓名" value={name} onChange={(e) => {this.setState({name: e.target.value})}} <Input allowClear placeholder="请输入真实姓名" value={name} onChange={(e) => {this.setState({name: e.target.value})}}
style={{ width: '242px'}} style={{ width: '221px'}}
></Input> ></Input>
<span className="label" style={{ minWidth: '36px' }}>单位:</span> <span className="label" style={{ minWidth: '36px' }}>单位:</span>
{/* <Input allowClear placeholder="" value={school_name} onChange={(e) => {this.setState({school_name: e.target.value})}} {/* <Input allowClear placeholder="" value={school_name} onChange={(e) => {this.setState({school_name: e.target.value})}}
@ -210,14 +210,7 @@ class AddStudentModal extends Component{
>搜索</a> >搜索</a>
</div> </div>
{/* <Divider /> */} {/* <Divider /> */}
{course_groups && course_groups.length && <div className="df" style={{ marginTop: '24px' }} >
<span className="mr10">分班:</span>
<Select style={{ width:500 }} onChange={this.handleCourseGroupChange} value={courseGroup}>
{ course_groups.map((item) => {
return <Option value={item.id}>{item.name}</Option>
})}
</Select>
</div>}
<p className="clearfix mb2" style={{ margin: '0px 15px 6px' }}> <p className="clearfix mb2" style={{ margin: '0px 15px 6px' }}>
<Checkbox className="fl" style={{ visibility: 'hidden' }} ></Checkbox> <Checkbox className="fl" style={{ visibility: 'hidden' }} ></Checkbox>
@ -247,7 +240,12 @@ class AddStudentModal extends Component{
<Checkbox className="fl" value={candidate.id} disabled={candidate.added}></Checkbox> <Checkbox className="fl" value={candidate.id} disabled={candidate.added}></Checkbox>
<span className="fl with25"> <span className="fl with25">
<ConditionToolTip title={candidate.name} condition={candidate.name && candidate.name.length > 12 }> <ConditionToolTip title={candidate.name} condition={candidate.name && candidate.name.length > 12 }>
<label className="task-hide fl" style={{"maxWidth":"208px;"}}>{candidate.name || ' '}</label> <label className="task-hide fl" style={{"maxWidth":"208px;"}}>
{ candidate.name ?
<a href={`/users/${candidate.login}`} target="_blank">
{ candidate.name }
</a> : <span> </span> }
</label>
</ConditionToolTip> </ConditionToolTip>
</span> </span>
<span className="fl with25"> <span className="fl with25">
@ -271,6 +269,14 @@ class AddStudentModal extends Component{
</InfiniteScroll> </InfiniteScroll>
</div> </div>
{course_groups && course_groups.length && <div className="df" style={{ marginTop: '12px' }} >
<span className="mr10" style={{ width: '148px' }}>所选学生分班至(选填):</span>
<Select style={{ width: 236 }} onChange={this.handleCourseGroupChange} value={courseGroup}>
{ course_groups.map((item) => {
return <Option value={item.id}>{item.name}</Option>
})}
</Select>
</div>}
</div> : <NoneData></NoneData> } </div> : <NoneData></NoneData> }
</Spin> </Spin>
</ModalWrapper> </ModalWrapper>

@ -203,7 +203,7 @@ class CoursesNew extends Component {
// debugger // debugger
if (response.data.status === 0) { if (response.data.status === 0) {
// this.goback() // this.goback()
this.props.history.push(first_category_url); window.location.href=first_category_url;
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -247,7 +247,7 @@ class CoursesNew extends Component {
).then((response) => { ).then((response) => {
if (response.status === 200) { if (response.status === 200) {
// this.goback // this.goback
this.props.history.push(response.data.first_category_url); window.location.href=response.data.first_category_url;
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)

@ -5,6 +5,9 @@
.discuss-tab { .discuss-tab {
height: 90px; height: 90px;
} }
.discuss-tab ._forum_tab a.navItem {
line-height: 2;
}
.discuss-tab ._forum_tab a.navItem:hover { .discuss-tab ._forum_tab a.navItem:hover {
color: #4CACFF !important; color: #4CACFF !important;
border-bottom: none !important; border-bottom: none !important;

@ -44,7 +44,7 @@ class MemoDetail extends Component {
this.state = { this.state = {
memoLoading: true, memoLoading: true,
hasMoreComments: false, hasMoreComments: false,
pageCount: 1, pageCount: 2,
goldRewardDialogOpen: false goldRewardDialogOpen: false
} }
@ -54,12 +54,12 @@ class MemoDetail extends Component {
const { match } = this.props const { match } = this.props
const memoUrl = `/api/v1/memos/${match.params.memoId}`; const memoUrl = `/memos/${match.params.memoId}.json`;
this.setState({ this.setState({
memoLoading: true memoLoading: true
}) })
axios.get(memoUrl,{ axios.get(memoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const memo = response.data.memo const memo = response.data.memo
@ -86,14 +86,16 @@ class MemoDetail extends Component {
} }
this.setState({ this.setState({
hasMoreComments, hasMoreComments,
pageCount: 1, pageCount: 2,
comments: memo_replies comments: memo_replies
}) })
delete response.data.memo_replies; delete response.data.memo_replies;
// reset
response.data.memo.praise_count = response.data.memo.memo_praise_count
this.props.initForumState(response.data) this.props.initForumState(response.data)
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
} }
this.setState({ this.setState({
memoLoading: false memoLoading: false
@ -116,10 +118,10 @@ class MemoDetail extends Component {
$('body>#root').off('onMemoDelete') $('body>#root').off('onMemoDelete')
} }
onMemoDelete(memo) { onMemoDelete(memo) {
const deleteUrl = `/api/v1/memos/${memo.id}`; const deleteUrl = `/memos/${memo.id}.json`;
// 获取memo list // 获取memo list
axios.delete(deleteUrl, { axios.delete(deleteUrl, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
@ -158,14 +160,14 @@ class MemoDetail extends Component {
clickPraise(){ clickPraise(){
const { memo } = this.props; const { memo } = this.props;
const url = `/api/v1/discusses/${memo.id}/plus`; const url = `/discusses/${memo.id}/plus.json`;
console.log(url) console.log(url)
axios.post(url, { axios.post(url, {
container_type: 'Memo', container_type: 'Memo',
type: 1 // "踩0赞1" type: 1 // "踩0赞1"
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
console.log(response); console.log(response);
@ -223,7 +225,8 @@ class MemoDetail extends Component {
this.createNewComment(commentContent, id, editor); this.createNewComment(commentContent, id, editor);
return; return;
} }
const url = `/api/v1/memos/${id}/reply`; // /${id}
const url = `/memos/reply.json`;
const { comments } = this.state; const { comments } = this.state;
const user = this._getUser(); const user = this._getUser();
/* /*
@ -235,12 +238,14 @@ class MemoDetail extends Component {
commentContent = commentContent.replace(/(\n<p>\n\t<br \/>\n<\/p>)*$/g,''); commentContent = commentContent.replace(/(\n<p>\n\t<br \/>\n<\/p>)*$/g,'');
} }
axios.post(url, { axios.post(url, {
parent_id: id,
content: commentContent content: commentContent
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
response.data.memo = response.data
if (response.data.memo) { if (response.data.memo) {
let newDiscuss = response.data.memo; let newDiscuss = response.data.memo;
@ -303,12 +308,12 @@ class MemoDetail extends Component {
if (childCommentId) { if (childCommentId) {
deleteCommentId = childCommentId; deleteCommentId = childCommentId;
} }
const url = `/api/v1/memos/${deleteCommentId}` const url = `/memos/${deleteCommentId}.json`
let comments = this.state.comments; let comments = this.state.comments;
axios.delete(url, axios.delete(url,
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
// TODO 删除成功或失败 // TODO 删除成功或失败
@ -346,7 +351,7 @@ class MemoDetail extends Component {
const { comments } = this.state; const { comments } = this.state;
const commentIndex = this._findById(discussId, comments); const commentIndex = this._findById(discussId, comments);
const url = `/api/v1/discusses/${discussId}/plus` const url = `/discusses/${discussId}/plus.json`
axios.post(url, { axios.post(url, {
// id: discussId, // id: discussId,
// container_id: challenge.id, // container_id: challenge.id,
@ -354,7 +359,7 @@ class MemoDetail extends Component {
type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0赞1" type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0赞1"
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
if (response.data.praise_count === 0 || response.data.praise_count) { if (response.data.praise_count === 0 || response.data.praise_count) {
@ -379,7 +384,7 @@ class MemoDetail extends Component {
handleComment = childComment; handleComment = childComment;
} }
let handleCommentId = handleComment.id; let handleCommentId = handleComment.id;
const url = `/api/v1/discusses/${handleCommentId}/reward_code` const url = `/discusses/${handleCommentId}/reward_code.json`
axios.post(url, { axios.post(url, {
id: handleCommentId, id: handleCommentId,
@ -389,7 +394,7 @@ class MemoDetail extends Component {
user_id: handleComment.user_id user_id: handleComment.user_id
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
if (response.data && response.data.code) { if (response.data && response.data.code) {
@ -423,7 +428,7 @@ class MemoDetail extends Component {
const id = item.id const id = item.id
const { showSnackbar } = this.props; const { showSnackbar } = this.props;
const user = this._getUser(); const user = this._getUser();
const url = `/api/v1/memos/${id}/hidden` const url = `/memos/${id}/hidden.json`
const { comments } = this.state; const { comments } = this.state;
const commentIndex = this._findById(id, comments); const commentIndex = this._findById(id, comments);
@ -432,14 +437,14 @@ class MemoDetail extends Component {
hidden: !comment.hidden ? "1" : "0" hidden: !comment.hidden ? "1" : "0"
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
showSnackbar(response.data.message) showSnackbar(response.data.message)
return; return;
} }
if (response.data.status === 1) { if (response.data.status === 0) {
if (!childCommentId) { if (!childCommentId) {
comment.hidden = !comment.hidden; comment.hidden = !comment.hidden;
@ -473,14 +478,16 @@ class MemoDetail extends Component {
return; return;
} }
} }
const url = `/api/v1/memos/${memo.id}/reply`; // /${memo.id}
const url = `/memos/reply.json`;
let { comments } = this.state; let { comments } = this.state;
const user = this._getUser(); const user = this._getUser();
axios.post(url, { axios.post(url, {
parent_id: memo.id,
content: content content: content
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
@ -488,6 +495,7 @@ class MemoDetail extends Component {
return; return;
} }
if (response.data) { if (response.data) {
response.data.memo = response.data
const newMemo = response.data.memo; const newMemo = response.data.memo;
// ke // ke
editor.html && editor.html(''); editor.html && editor.html('');
@ -536,12 +544,12 @@ class MemoDetail extends Component {
let { comments, pageCount } = this.state; let { comments, pageCount } = this.state;
let { memo } = this.props; let { memo } = this.props;
const user = this._getUser(); const user = this._getUser();
const url = `/api/v1/memos/${memo.id}/more_reply?page=${pageCount}`; const url = `/memos/${memo.id}/more_reply.json?page=${pageCount}`;
axios.get(url, { axios.get(url, {
}, },
{ {
withCredentials: true // withCredentials: true
} }
).then((response) => { ).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
@ -584,10 +592,10 @@ class MemoDetail extends Component {
params.forum_id = this.state.p_forum_id; params.forum_id = this.state.p_forum_id;
} }
let paramsUrl = urlStringify(params) let paramsUrl = urlStringify(params)
const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`; const set_top_or_down_Url = `/memos/${memo.id}/sticky_or_cancel.json?${paramsUrl}`;
// 获取memo list // 获取memo list
axios.get(set_top_or_down_Url, { axios.post(set_top_or_down_Url, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
@ -608,9 +616,8 @@ class MemoDetail extends Component {
const { memo, author_info } = this.props; const { memo, author_info } = this.props;
const newMemo = Object.assign({}, memo); const newMemo = Object.assign({}, memo);
const _reward = parseInt(inputVal) const _reward = parseInt(inputVal)
const newMemoUrl = `/api/v1/memos/${memo.id}/update`
const url = `/api/v1/discusses/${memo.id}/reward_code` const url = `/discusses/${memo.id}/reward_code.json`
axios.post(url, { axios.post(url, {
id: memo.id, id: memo.id,
@ -619,7 +626,7 @@ class MemoDetail extends Component {
score: _reward, score: _reward,
user_id: author_info.user_id user_id: author_info.user_id
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { code } = response.data; const { code } = response.data;
@ -659,14 +666,24 @@ class MemoDetail extends Component {
const { memo, recommend_shixun, current_user,author_info } = this.props; const { memo, recommend_shixun, current_user,author_info } = this.props;
const { comments, hasMoreComments, goldRewardDialogOpen } = this.state; const { comments, hasMoreComments, goldRewardDialogOpen } = this.state;
if (this.state.memoLoading) { if (!memo || this.state.memoLoading) {
return <div className="edu-back-white" id="forum_index_list"></div> return <div className="edu-back-white" id="forum_index_list"></div>
} }
current_user.user_url = `/users/${current_user.login}`; let _current_user = {}
if (current_user) {
_current_user = current_user
}
(_current_user.user_url = `/users/${_current_user.login}`);
memo.isDetailPage = true; memo.isDetailPage = true;
// TODO 图片上传地址 // TODO 图片上传地址
return ( return (
<div className="edu-back-white" id="forum_index_list"> {/* fl with100 */} <div className="edu-back-white memoDetail" id="forum_index_list"> {/* fl with100 */}
<style>{`
.memoDetail .commentsbtn {
margin-top: 6px;
}
`}</style>
<RewardDialog goldRewardDialogOpen={goldRewardDialogOpen} <RewardDialog goldRewardDialogOpen={goldRewardDialogOpen}
setRewardDialogVisible={this.setRewardDialogVisible} setRewardDialogVisible={this.setRewardDialogVisible}
rewardCode={this.rewardCodeMemo} rewardCode={this.rewardCodeMemo}
@ -681,11 +698,11 @@ class MemoDetail extends Component {
data-tip-down={`获得平台奖励金币:${memo.reward}`} > data-tip-down={`获得平台奖励金币:${memo.reward}`} >
<i className="iconfont icon-gift mr5"></i>{memo.reward} <i className="iconfont icon-gift mr5"></i>{memo.reward}
</span> } </span> }
{ current_user && (current_user.admin === true || current_user.user_id === author_info.user_id) && { _current_user && (_current_user.admin === true || _current_user.user_id === author_info.user_id) &&
<div className="edu-position-hidebox" style={{position: 'absolute', right: '18px',top:'4px'}}> <div className="edu-position-hidebox" style={{position: 'absolute', right: '12px',top:'4px'}}>
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a> <a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
<ul className="edu-position-hide undis"> <ul className="edu-position-hide undis">
{ current_user.admin === true && { _current_user.admin === true &&
( memo.sticky === true ? ( memo.sticky === true ?
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li> <li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
: :
@ -701,15 +718,22 @@ class MemoDetail extends Component {
</ul> </ul>
</div> </div>
} }
<Link className={`task-hide fr return_btn color-grey-6 mt2 ${ current_user && (current_user.admin === true <Link className={`task-hide fr return_btn color-grey-6 mt2 ${ _current_user && (_current_user.admin === true
|| current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums" > || _current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums"
style={{ marginRight: '10px'}}
>
返回 返回
</Link> </Link>
</div> </div>
<div className="color-grey-9 clearfix"> <div className="color-grey-9 clearfix">
<span className="fl">{moment(memo.time).fromNow()} 发布</span> <span className="fl">{moment(memo.time).fromNow()} 发布</span>
<div className="fr"> <div className="fr detailIcons">
{ current_user.admin && <Tooltip title={ "帖子奖励" }> <style>{`
.detailIcons i{
vertical-align: sub;
}
`}</style>
{ _current_user.admin && <Tooltip title={ "帖子奖励" }>
<span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}> <span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}>
<i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i> <i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i>
</span> </span>
@ -770,7 +794,7 @@ class MemoDetail extends Component {
<span className="count">{memo.replies_count}</span> <span className="count">{memo.replies_count}</span>
</div> </div>
<Comments comments={comments} user={current_user} <Comments comments={comments} user={_current_user}
replyComment={this.replyComment} replyComment={this.replyComment}
deleteComment={this.deleteComment} deleteComment={this.deleteComment}
commentPraise={this.commentPraise} commentPraise={this.commentPraise}

@ -42,7 +42,7 @@ class MemoDetailMDEditor extends Component {
window.__tt = 400; window.__tt = 400;
setTimeout(() => { setTimeout(() => {
var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => { var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => {
commentMDEditor.focus() // commentMDEditor.focus()
this.isMDInited = true this.isMDInited = true
this.initDrag() this.initDrag()

@ -15,6 +15,7 @@ import Upload from 'rc-upload';
import axios from 'axios' import axios from 'axios'
import 'antd/lib/select/style/index.css' import 'antd/lib/select/style/index.css'
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor'
import { getUrl } from 'educoder' import { getUrl } from 'educoder'
const Option = Select.Option; const Option = Select.Option;
@ -130,6 +131,7 @@ const languageSeparator = '/'
class MemoNew extends Component { class MemoNew extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.mdRef = React.createRef();
// https://testbdweb.trustie.net/uploads.js?attachment_id=1&filename=jqui.js // https://testbdweb.trustie.net/uploads.js?attachment_id=1&filename=jqui.js
// https://ant.design/components/upload-cn/ // https://ant.design/components/upload-cn/
@ -179,7 +181,7 @@ class MemoNew extends Component {
} }
let mdVal; let mdVal;
try { try {
mdVal = this.taskpass_editormd.getValue() mdVal = this.mdRef.current.getValue()
} catch (e) { } catch (e) {
showSnackbar('编辑器还未加载完毕,请稍后') showSnackbar('编辑器还未加载完毕,请稍后')
@ -205,6 +207,7 @@ class MemoNew extends Component {
// collect attachments // collect attachments
const $ = window.$; const $ = window.$;
const attachmentsMap = {}; const attachmentsMap = {};
const attachmentIds = []
$('#attachments_fields .attachment').each(( index, item ) => { $('#attachments_fields .attachment').each(( index, item ) => {
const filename = $(item).find('.upload_filename').val(); const filename = $(item).find('.upload_filename').val();
// $($('#attachments_fields .attachment')[0]).find('input:nth-child(6)').val() // $($('#attachments_fields .attachment')[0]).find('input:nth-child(6)').val()
@ -215,13 +218,14 @@ class MemoNew extends Component {
token, token,
attachment_id attachment_id
} }
attachmentIds.push(attachment_id)
}) })
if (currentMemoId) { if (currentMemoId) {
this.updateMemo(attachmentsMap) this.updateMemo(attachmentIds)
} else { } else {
this.newMemo(attachmentsMap) this.newMemo(attachmentIds)
} }
} }
onCancel() { onCancel() {
@ -235,23 +239,23 @@ class MemoNew extends Component {
} }
updateMemo(attachmentsMap) { updateMemo(attachmentsMap) {
const { memoSubject, memoRepertoire, memoLanguage, memoType, currentMemoId, content } = this.state; const { memoSubject, memoRepertoire, memoLanguage, memoType, currentMemoId, content } = this.state;
const mdVal = this.taskpass_editormd.getValue() const mdVal = this.mdRef.current.getValue()
console.log('isContentEdit: ', mdVal === content); console.log('isContentEdit: ', mdVal === content);
const newMemoUrl = `/api/v1/memos/${currentMemoId}/update` const newMemoUrl = `/memos/${currentMemoId}.json`
axios.post(newMemoUrl, { axios.put(newMemoUrl, {
content_changed: this.contentChanged, content_changed: this.contentChanged,
tags: memoLanguage, tags: memoLanguage,
memo:{ // memo:{
subject: memoSubject , subject: memoSubject ,
content: mdVal, content: mdVal,
forum_id: memoType, forum_id: memoType,
repertoire_name: memoRepertoire, repertoire_name: memoRepertoire,
// language: memoLanguage.join(languageSeparator), // language: memoLanguage.join(languageSeparator),
// //
}, // },
attachments: attachmentsMap attachments: attachmentsMap
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { status, message, memo_id } = response.data; const { status, message, memo_id } = response.data;
@ -267,21 +271,21 @@ class MemoNew extends Component {
} }
newMemo(attachmentsMap) { newMemo(attachmentsMap) {
const { memoSubject, memoRepertoire, memoLanguage, memoType } = this.state; const { memoSubject, memoRepertoire, memoLanguage, memoType } = this.state;
const mdVal = this.taskpass_editormd.getValue() const mdVal = this.mdRef.current.getValue()
const newMemoUrl = `/api/v1/memos/create` const newMemoUrl = `/memos.json`
axios.post(newMemoUrl, { axios.post(newMemoUrl, {
tags: memoLanguage, tags: memoLanguage,
memo:{ // memo:{
subject: memoSubject , subject: memoSubject ,
content: mdVal, content: mdVal,
forum_id: memoType, forum_id: memoType,
repertoire_name: memoRepertoire, // repertoire_name: memoRepertoire,
}, // },
attachments: attachmentsMap attachments: attachmentsMap
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { status, message, memo_id } = response.data; const { status, message, memo_id } = response.data;
@ -296,9 +300,9 @@ class MemoNew extends Component {
}) })
} }
componentDidMount() { componentDidMount() {
const newMemoUrl = `/api/v1/memos/new` const newMemoUrl = `/memos/new.json`
axios.get(newMemoUrl,{ axios.get(newMemoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
@ -319,9 +323,9 @@ class MemoNew extends Component {
// repertoiresTagMap // repertoiresTagMap
}) })
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
// 初始化 csrf meta // 初始化 csrf meta
const $ = window.$ const $ = window.$
@ -336,18 +340,20 @@ class MemoNew extends Component {
const { match } = this.props const { match } = this.props
const memoId = match.params.memoId; const memoId = match.params.memoId;
if (memoId) { if (memoId) {
const memoUrl = `/api/v1/memos/${match.params.memoId}/edit`; const memoUrl = `/memos/${match.params.memoId}/edit.json`;
axios.get(memoUrl,{ axios.get(memoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const tag_list = response.data.tag_list const tag_list = response.data.tag_list
if (tag_list) { if (tag_list) {
// this.setState({...response.data}) // this.setState({...response.data})
const { content, forum_id, id, tag, repertoire_name, subject, const { content, forum_id, id, repertoire_name, subject,
current_user, tag_list, attachments_url } = response.data; current_user, tag_list, attachments_url, memo_tags } = response.data;
this.initMD(content); this.initMD(content);
// this.onRepertoiresChange(repertoire_name) // this.onRepertoiresChange(repertoire_name)
// tag -> memo_tags
const tag = memo_tags;
let memoLanguage = [] let memoLanguage = []
if (tag) { if (tag) {
memoLanguage = tag.map((item, index) => { memoLanguage = tag.map((item, index) => {
@ -355,7 +361,7 @@ class MemoNew extends Component {
}) })
} }
this.setState({ this.setState({
currentMemoId: id, currentMemoId: memoId,
memoSubject: subject, memoSubject: subject,
memoType: forum_id, memoType: forum_id,
memoRepertoire: repertoire_name, memoRepertoire: repertoire_name,
@ -377,7 +383,7 @@ class MemoNew extends Component {
window.$("html,body").animate({"scrollTop":0}) window.$("html,body").animate({"scrollTop":0})
this.props.initForumState({ this.props.initForumState({
current_user, // current_user,
tag_list tag_list
}) })
} }
@ -394,6 +400,8 @@ class MemoNew extends Component {
} }
initMD(initValue) { initMD(initValue) {
return;
this.contentChanged = false; this.contentChanged = false;
const placeholder = ""; const placeholder = "";
// amp; // amp;
@ -566,9 +574,12 @@ class MemoNew extends Component {
<div className="df"> <div className="df">
<span className="mr30 color-orange pt10">*</span> <span className="mr30 color-orange pt10">*</span>
<div className="flex1 mr20"> <div className="flex1 mr20">
<div className="flex1 break_word show_content_grey new_li" id="memoMD"> <TPMMDEditor ref={this.mdRef} placeholder={''} watch={false}
mdID={'memoMD'} initValue={this.state.content} className="memoMD">
</TPMMDEditor>
{/* <div className="flex1 break_word show_content_grey new_li" id="memoMD">
<textarea style={{'display':'none'}}></textarea> <textarea style={{'display':'none'}}></textarea>
</div> </div> */}
<p id="e_tip_memoNew" className="edu-txt-right color-grey-cd font-12"></p> <p id="e_tip_memoNew" className="edu-txt-right color-grey-cd font-12"></p>
<p id="e_tips_memoNew" className="edu-txt-right color-grey-cd font-12"></p> <p id="e_tips_memoNew" className="edu-txt-right color-grey-cd font-12"></p>
</div> </div>

@ -8,6 +8,9 @@
min-height: 400px; min-height: 400px;
position: relative; position: relative;
} }
#forum_index_list .forum_table .forum_table_item {
background: #fff;
}
.noMemosTip { .noMemosTip {
position: absolute; position: absolute;
right: 10px; right: 10px;

@ -29,7 +29,7 @@ class PostItem extends Component {
<img alt="用户头像" className="bor-radius-all mt3" height="50" src={getImageUrl(`images/`+memo.image_url)} width="50" /> <img alt="用户头像" className="bor-radius-all mt3" height="50" src={getImageUrl(`images/`+memo.image_url)} width="50" />
</a> </a>
<div className="fl pr" style={{flex: 1}}> <div className="fl pr" style={{flex: 1}}>
<p className="font-16 clearfix" > <p className="font-16 clearfix" style={{ lineHeight: 2 }}>
{/* target="_blank" */} {/* target="_blank" */}
<a href={`/forums/${memo.id}`} target="_blank" title={memo.subject} <a href={`/forums/${memo.id}`} target="_blank" title={memo.subject}
className="clearfix task-hide item_name fl" style={{maxWidth: '750px'}} > className="clearfix task-hide item_name fl" style={{maxWidth: '750px'}} >
@ -46,16 +46,16 @@ class PostItem extends Component {
</p> </p>
<div className="clearfix mt5 color-grey-9"> <div className="clearfix mt5 color-grey-9">
<span className="fl">{memo.username}</span> <span className="fl">{memo.user_name}</span>
{/*todo{memo.username} {/*todo{memo.username}
memo.language && memo.language != 'other' && <span className="fl language-cir-orange mr10 mt3 ml6">{memo.language}</span> memo.language && memo.language != 'other' && <span className="fl language-cir-orange mr10 mt3 ml6">{memo.language}</span>
*/} */}
<span className="fl ml50">{moment(memo.updated_at).fromNow()}</span> {/* <span className="fl ml50">{moment(memo.updated_at).fromNow()}</span> */}
{memo.tag && memo.tag.length ? <span className="fl ml50">来自 {memo.tag.join('/')}</span> : ''} {memo.tag && memo.tag.length ? <span className="fl ml50">来自 {memo.tag.join('/')}</span> : ''}
{/*<span className="fl language-cir-orange mr10 mt3">C++</span>*/} {/*<span className="fl language-cir-orange mr10 mt3">C++</span>*/}
<p className="font-12 fr mr8 color-grey-6"> <p className="font-12 fr mr8 color-grey-6" style={{ marginTop: '4px' }}>
{/* data-tip-down="回复数" <i className="fa fa-comments-o mr5"></i>{memo.replies_count} {/* data-tip-down="回复数" <i className="fa fa-comments-o mr5"></i>{memo.replies_count}
<i className="fa fa-thumbs-o-up mr5"></i>{memo.praise_count}*/} <i className="fa fa-thumbs-o-up mr5"></i>{memo.praise_count}*/}
{memo.replies_count ? {memo.replies_count ?

@ -136,7 +136,7 @@ return function wrap(WrappedComponent) {
const params = { const params = {
// replies_count最热 created_at 最新 // replies_count最热 created_at 最新
// s_order: 'replies_count', // s_order: 'replies_count',
page: currentPage - 1, page: currentPage,
// forum: // forum_id // forum: // forum_id
// user_id // user_id
@ -165,7 +165,7 @@ return function wrap(WrappedComponent) {
let paramsUrl = queryString.stringify(params) let paramsUrl = queryString.stringify(params)
const memosUrl = '/api/v1/memos?' + paramsUrl // /${challenge.identifier}/star const memosUrl = '/memos.json?' + paramsUrl // /${challenge.identifier}/star
this.setState({ this.setState({
currentPage, currentPage,
@ -174,7 +174,7 @@ return function wrap(WrappedComponent) {
}) })
// 获取memo list // 获取memo list
axios.get(memosUrl,{ axios.get(memosUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const memo_count = response.data.memo_count const memo_count = response.data.memo_count
@ -186,9 +186,9 @@ return function wrap(WrappedComponent) {
this.fetchMemos(maxPage); this.fetchMemos(maxPage);
return; return;
} }
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
this.props.initForumState(response.data) this.props.initForumState(response.data)
this.setState({ this.setState({
p_forum_id: params.forum, p_forum_id: params.forum,
@ -242,16 +242,18 @@ return function wrap(WrappedComponent) {
params.forum_id = this.state.p_forum_id; params.forum_id = this.state.p_forum_id;
} }
let paramsUrl = urlStringify(params) let paramsUrl = urlStringify(params)
const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`; const set_top_or_down_Url = `/memos/${memo.id}/sticky_or_cancel.json?${paramsUrl}`;
// 获取memo list // 获取memo list
axios.get(set_top_or_down_Url, { axios.post(set_top_or_down_Url, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
if (status === 0) { if (status === 0) {
const { memo_list } = response.data; this.fetchMemos(1, '')
this.props.initForumState({ memo_list })
// const { memo_list } = response.data;
// this.props.initForumState({ memo_list })
// 刷新列表 // 刷新列表
// TODO 服务端直接返回第一页列表 // TODO 服务端直接返回第一页列表
// this.props.history.replace('/') // this.props.history.replace('/')
@ -265,10 +267,10 @@ return function wrap(WrappedComponent) {
this.setTop(memo); this.setTop(memo);
} }
onMemoDelete(memo) { onMemoDelete(memo) {
const deleteUrl = `/api/v1/memos/${memo.id}`; const deleteUrl = `/memos/${memo.id}.json`;
// 获取memo list // 获取memo list
axios.delete(deleteUrl, { axios.delete(deleteUrl, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status

@ -33,7 +33,7 @@ class RecommendShixun extends Component {
</a> </a>
<div className="ml10 flex1"> <div className="ml10 flex1">
<a href={`/shixuns/${_shixun.identifier}/challenges`} target="_blank" data-tip-down={_shixun.name} <a href={`/shixuns/${_shixun.identifier}/challenges`} target="_blank" data-tip-down={_shixun.name}
className="color-grey-6 task-hide mb12 recomment-name" style={{maxWidth:'147px'}}> className="color-grey-6 task-hide mb10 recomment-name" style={{maxWidth:'147px'}}>
{_shixun.name} {_shixun.name}
</a> </a>
<p className="color-grey-9">{_shixun.myshixuns_count} 人学习</p> <p className="color-grey-9">{_shixun.myshixuns_count} 人学习</p>
@ -50,7 +50,7 @@ class RecommendShixun extends Component {
// 参考 TPMShixunDiscuss.js 推荐实训, 页面路径http://localhost:3007/shixuns/uznmbg54/shixun_discuss // 参考 TPMShixunDiscuss.js 推荐实训, 页面路径http://localhost:3007/shixuns/uznmbg54/shixun_discuss
return ( return (
<div className="padding10"> <div className="padding10">
<p className="mb20 font-16 clearfix">推荐实训</p> <p className="mb20 font-16 clearfix" style={{ lineHeight: 2 }}>推荐实训</p>
<div className="recommend-list"> <div className="recommend-list">
{this.showRecommandShixun()} {this.showRecommandShixun()}
</div> </div>

@ -21,27 +21,52 @@ class UserSection extends Component {
const { author_info } = this.props const { author_info } = this.props
/*http://localhost:3000/api/v1/users/155/watch?object_id=156&object_type=user*/ /*http://localhost:3000/api/v1/users/155/watch?object_id=156&object_type=user*/
const focusUrl = `/api/v1/users/${author_info.user_id}/${this.props.author_info.watched ? 'unwatch' : 'watch'}?object_id=${author_info.user_id}&object_type=user` // const focusUrl = `/api/v1/users/${author_info.user_id}/${this.props.author_info.watched ? 'unwatch' : 'watch'}?object_id=${author_info.user_id}&object_type=user`
axios.get(focusUrl,{ // axios.get(focusUrl,{
}) // })
.then((response) => { // .then((response) => {
const status = response.data.status; // const status = response.data.status;
console.log(status); // console.log(status);
if(status == 1){ // if(status == 1){
const new_author_info = Object.assign({}, this.props.author_info) // const new_author_info = Object.assign({}, this.props.author_info)
new_author_info.watched = !new_author_info.watched // new_author_info.watched = !new_author_info.watched
this.props.initForumState({author_info: new_author_info}) // this.props.initForumState({author_info: new_author_info})
} // }
}).catch((error) => { // }).catch((error) => {
console.log(error) // console.log(error)
}) // })
let url=`/users/${author_info.user_id}/watch.json`;
// 取消关注
if(author_info.watched){
axios.delete(url).then((result)=>{
if(result){
const new_author_info = Object.assign({}, this.props.author_info)
new_author_info.watched = !new_author_info.watched
this.props.initForumState({author_info: new_author_info})
}
}).catch((error)=>{
console.log(error)
})
}else{
// 关注
axios.post(url).then((result)=>{
if(result){
const new_author_info = Object.assign({}, this.props.author_info)
new_author_info.watched = !new_author_info.watched
this.props.initForumState({author_info: new_author_info})
}
}).catch((error)=>{
console.log(error);
})
}
} }
render() { render() {
const { match, history, author_info , current_user } = this.props const { match, history, author_info , current_user } = this.props
if (!author_info) { if (!author_info || !current_user) {
return <div className="edu-back-white" id="forum_index_list"></div> return <div className="edu-back-white" id="forum_index_list"></div>
} }
return ( return (
@ -52,7 +77,7 @@ class UserSection extends Component {
{ author_info.user_id !== current_user.user_id && { author_info.user_id !== current_user.user_id &&
<p className="clearfix mt30"> <p className="clearfix mt30">
<a href="javascript:void(0)" className="fl font-16 mr10 user_default_btn edu-blueback-btn" onClick={()=>{this.AboutFocus()}}>{ author_info.watched == true ? "取消关注" : "关注" }</a> <a href="javascript:void(0)" className="fl font-16 mr10 user_default_btn edu-blueback-btn" onClick={()=>{this.AboutFocus()}}>{ author_info.watched == true ? "取消关注" : "关注" }</a>
<a href={`/message/${current_user.login}/message_detail?target_ids=${author_info.user_id}`} className="fr font-16 user_default_btn user_private_btn" target="_blank">私信</a> <a href={`/messages/${current_user.login}/message_detail?target_ids=${author_info.user_id}`} className="fr font-16 user_default_btn user_private_btn" target="_blank">私信</a>
</p> } </p> }
</div> </div>
); );

@ -11,7 +11,7 @@
height:48px; height:48px;
width: 48px; width: 48px;
float: left; float: left;
margin-top: 7px; margin-top: 4px;
} }
.shixunReply{ .shixunReply{
max-width: 604px; max-width: 604px;

@ -83,7 +83,7 @@ class MemoShixun extends Component {
} }
const stringifid = queryString.stringify(paramsObject); const stringifid = queryString.stringify(paramsObject);
const url = `/api/v1/discusses?${stringifid}` // /${challenge.identifier}/star const url = `/discusses/forum_discusses.json?${stringifid}` // /${challenge.identifier}/star
// 获取memo list // 获取memo list
this.setState({ this.setState({
@ -91,13 +91,13 @@ class MemoShixun extends Component {
loadingMemos: true loadingMemos: true
}) })
axios.get(url,{ axios.get(url,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
if (response.data) { if (response.data) {
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
this.props.initForumState(response.data) this.props.initForumState(response.data)
// const { hot_tags } = response.data; // const { hot_tags } = response.data;

@ -39,7 +39,7 @@ class ShiXunPostItem extends Component
width="48px" height="48px" className="radius"/> width="48px" height="48px" className="radius"/>
</a> </a>
<div className="flex1 ml10 pr20"> <div className="flex1 ml10 pr20">
<div className="clearfix"> <div className="clearfix" style={{ height: '32px' }}>
<p className="shixunReply task-hide font-16 fl"> <p className="shixunReply task-hide font-16 fl">
<Link to={`${memo.tpm_url}`} title={memo.subject} target="_blank">{memo.subject}</Link> <Link to={`${memo.tpm_url}`} title={memo.subject} target="_blank">{memo.subject}</Link>
</p> </p>

@ -20,6 +20,10 @@
.ant-modal-header{ .ant-modal-header{
border-radius: 0px !important; border-radius: 0px !important;
} }
.ridinglist-subs{
border-bottom: 1px solid #F5F5F5;
padding: 25px 0px;
}
.search-new{ .search-new{
width: 100% !important; width: 100% !important;
margin-bottom: 0px !important; margin-bottom: 0px !important;

@ -48,6 +48,7 @@ class MessagChat extends Component{
// console.log(this.props); // console.log(this.props);
// console.log(this.props.match.params.userid); // console.log(this.props.match.params.userid);
this.scrollToBottom(); this.scrollToBottom();
this.props.triggerRef(this)
} }
componentDidUpdate() { componentDidUpdate() {
@ -109,6 +110,7 @@ class MessagChat extends Component{
// } // }
}; };
shuaxingetChatList=(page,listl,target_ids,bool)=>{ shuaxingetChatList=(page,listl,target_ids,bool)=>{
this.setState({ this.setState({
isSpin:true, isSpin:true,
@ -384,7 +386,9 @@ class MessagChat extends Component{
// console.log(i); // console.log(i);
this.props.Modifyur(i); this.props.Modifyur(i);
}; };
getdatas2=()=>{
}
// 点击了用户 // 点击了用户
Clickedontheuser=(user)=>{ Clickedontheuser=(user)=>{
// debugger // debugger
@ -398,7 +402,7 @@ class MessagChat extends Component{
myuserl:user, myuserl:user,
}) })
this.props.history.replace(`/message/${this.props.current_user.user_id}/message_detail?target_ids=${user.id}`); this.props.history.replace(`/messages/${this.props.current_user.login}/message_detail?target_ids=${user.id}`);
// this.getdatatwo(this.state.page); // this.getdatatwo(this.state.page);
this.getChatListtwo(1,this.state.mypagey,user.id); this.getChatListtwo(1,this.state.mypagey,user.id);
@ -652,7 +656,7 @@ class MessagChat extends Component{
</p> </p>
<p className="color-grey-6 lineh-20 justify break_word task-hide-2" style={{wordBreak:"break-word"}} id="MakedownHTML" dangerouslySetInnerHTML={{__html:item.content}}> <p className="color-grey-6 lineh-20 justify break_word task-hide-2 markdown-body" style={{wordBreak:"break-word"}} id="MakedownHTML" dangerouslySetInnerHTML={{__html:item.content}}>
</p> </p>
</div> </div>

@ -30,6 +30,7 @@ class MessagSub extends Component{
}catch (e) { }catch (e) {
} }
this.props.triggerRef(this)
} }
//塞选页数 //塞选页数
@ -70,6 +71,36 @@ class MessagSub extends Component{
isSpin:false, isSpin:false,
}) })
}) })
};
getdatas=()=>{
this.setState({
isSpin:true,
})
let{typeysl,page,limit}=this.state;
let url = `/users/tidings.json`;
axios.get((url),{params:{
type:typeysl,
page:page,
per_page:limit,
}}).then((result) => {
if (result) {
// if (result.data.status === 0) {
this.setState({
page: page,
count: result.data.count,
typeysl: typeysl,
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);
this.setState({
isSpin:false,
})
})
} }
componentWillUnmount(){ componentWillUnmount(){
@ -78,6 +109,343 @@ class MessagSub extends Component{
return; return;
} }
} }
gettourl=(item)=>{
switch (item.container_type) {
case "ApplyUserAuthentication" :
if(item.tiding_type==="Apply"){
if(item.auth_type===1){
//系统管理页面
return window.open("/managements/identity_authentication");
}
if(item.auth_type===2){
//系统管理页面
return window.open("/managements/professional_authentication")
}
}
if(item.tiding_type ==="System"){
// 账号管理页-认证信息
return window.open("/account/certification")
}
case "CancelUserAuthentication" :
// 账号管理页-认证信息
return window.open("/account/certification")
case "CancelUserProCertification" :
// 账号管理页-认证信息
return window.open("/account/certification")
case "ApplyAddDepartment" :
if(item.tiding_type==="Apply"){
//部门审批
return window.open("/managements/depart")
}
if(item.tiding_type==="System"){
// 账号管理页/account/profile
return window.open("/account/profile")
}
case "ApplyAddSchools" :
if(item.tiding_type==="Apply"){
// 单位审批
return window.open(" /managements/unit")
}
if(item.tiding_type==="System"){
// 账号管理页
return window.open("/account/profile")
}
case "ApplyAction" :
switch (item.parent_container_type) {
case "ApplyShixun" :
if(item.tiding_type==="Apply"){
return window.open("/managements/shixun_authorization")
}
if(item.tiding_type==="System"){
// 实训详情页 :identifier = identifier
return window.open(`/shixuns/${item.identifier}/challenges`)
}
case "ApplySubject" :
if(item.tiding_type==="Apply"){
// 实训课程发布
return window.open("/managements/subject_authorization")
}
if(item.tiding_type==="System"){
// 实践课程详情页 :parent_container_id = parent_container_id
return window.open(`/paths/${item.parent_container_id}`)
}
case "TrialAuthorization" :
if(item.tiding_type==="Apply"){
// 试用授权页面
return window.open("/managements/trial_authorization")
}
if(item.tiding_type==="System"){
// 账号管理页
return window.open("/account/profile")
}
}
case 'JoinCourse' :
// 课堂详情页 :id =
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case 'StudentJoinCourse':
// 课堂详情页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case 'DealCourse':
// 课堂详情页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case 'TeacherJoinCourse':
// 课堂详情页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case 'Course' :
// 课堂详情页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case 'ArchiveCourse' :
// 课堂详情页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}`)
case "Shixun" :
return window.open(`/shixuns/${item.identifier}/challenges`)
case "Subject" :
// 实践课程详情页 :id = container_id
return window.open(`/paths/${item.container_id}`)
case "JournalsForMessage" :
switch (item.parent_container_type) {
case "Principal" :
// 反馈页 :id = parent_container_id
// 不用跳了
return '';
case "HomeworkCommon" :
//学生作业页 homework = parent_container_id
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
case "GraduationTopic" :
// 毕业目标页 parent_container_id
return window.open(`/courses/${item.belong_container_id}/graduation_topics/${item.parent_container_id}/detail`)
case "StudentWorksScore" :
//学生作业页
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
}
case "Memo" :
// 交流问答页 :id = parent_container_id
return window.open(`/forums/${item.parent_container_id}`)
case "Watcher" :
// 用户个人中心页 :id = item.trigger_user.login
return window.open(`/users/${item.trigger_user.login}/courses`)
case "PraiseTread" :
// 这块太复杂 不好处理
return '';
case "Grade" :
//个人中心页 :id = item.trigger_user.login
// return window.open(`/users/${item.trigger_user.login}/courses`;
return "";
case "JoinProject" :
//项目详情-申请加入项目审核页 :id = container_id
return window.open(`/projects/${item.container_id}`)
case 'ReporterJoinProject':
//项目详情页 :id = container_id
return window.open(`/projects/${item.container_id}`)
case 'DealProject':
//项目详情页 :id = container_id
return window.open(`/projects/${item.container_id}`)
case 'ManagerJoinProject':
//项目详情页 :id = container_id
return window.open(`/projects/${item.container_id}`)
case "Poll":
switch (item.parent_container_type) {
case "CommitPoll" :
// 课堂id belong_container_id
//课堂-学生已提交问卷列表 :id = container_id
return window.open(` /courses/${item.belong_container_id}/polls/${item.container_id}`)
default :
// 课堂-问卷列表 :id = container_id
return window.open(` /courses/${item.belong_container_id}/polls/${item.container_id}`)
}
case "Exercise" :
switch (item.parent_container_type) {
case "CommitExercise":
// 课堂-学生试卷详情 :id = container_id :user_id = trigger_user.id
return window.open(` /courses/${item.belong_container_id}/exercises/${item.container_id}/student_exercise_list?tab=0`)
case "ExerciseScore":
// 课堂-学生试卷详情 :id = container_id :user_id = trigger_user.id
return window.open(` /courses/${item.belong_container_id}/exercises/${item.container_id}/student_exercise_list?tab=0`)
default :
// 课堂-试卷列表详情 :id = container_id
return window.open(`/courses/${item.belong_container_id}/exercises/${item.container_id}`)
}
case 'StudentGraduationTopic' :
//课堂-毕业选题详情 :id = parent_container_id
return window.open(`/courses/${item.belong_container_id}/graduation_topics/${item.parent_container_id}/detail`)
case 'DealStudentTopicSelect' :
//课堂-毕业选题详情 :id = parent_container_id
return window.open(`/courses/${item.belong_container_id}/graduation_topics/${item.parent_container_id}/detail`)
case 'GraduationTask' :
//课堂-毕业任务页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/graduation_tasks/${item.container_id}`)
case "GraduationWork" :
//课堂-毕业xx页 :id = container_id
return window.open(`/courses/${item.belong_container_id}/graduation_tasks/${item.container_id}`)
case "GraduationWorkScore" :
// 课堂-毕业xx页 :id = parent_container_id
return window.open(`/courses/${item.belong_container_id}/graduation_tasks/${item.parent_container_id}`)
case "HomeworkCommon" :
switch (item.parent_container_type) {
case "AnonymousCommentFail" :
// 课堂-作业列表 homework = container_id
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
case "HomeworkPublish" :
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
case "AnonymousAppeal" :
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
default :
// 课堂-作业列表 homework = container_id
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
}
case "StudentWork" :
//课堂-作业 :id = container_id
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.container_id}/list?tab=0`)
}
case "StudentWorksScore" :
//课堂-作业 :id = parent_container_id
if(item.homework_type===1){
//普通作业
return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
case "StudentWorksScoresAppeal" :
if(item.homework_type===1){
//普通作业
return window.open(`courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===3){
//分组作业
return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/list`)
}
if(item.homework_type===4){
//实训作业
return window.open(`/courses/${item.belong_container_id}/shixun_homeworks/${item.parent_container_id}/list?tab=0`)
}
case "ChallengeWorkScore" :
return '';
case "SendMessage" :
// /managements/mirror_repository
return window.open(`/managements/mirror_repository`)
case "Journal" :
//项目Issue页 :id = parent_container_id
return window.open(`/projects/${item.parent_container_id}/issues?remote=true`)
case "Issue" :
//项目Issue页 :id = container_id
return window.open(`/projects/${item.container_id}/issues?remote=true`)
case "PullRequest" :
// 项目pull request页 :id = parent_container_id
return window.open(`/projects/${item.parent_container_id}/pull_requests`)
case "Department" :
//账号管理页
return window.open(`/account/profile`)
case "Library" :
if (item.tiding_type === 'Apply') {
// /managements/library_applies
return window.open(`/managements/library_applies`)
}
if(item.tiding_type === 'System'){
//教学案例详情 :id = container_id
return window.open(`/moop_cases/${item.container_id}`)
}
case "ProjectPackage" :
if(item.tiding_type==="Destroyed_end"){
return ;
}else {
if (item.tiding_type === 'Apply') {
///managements/project_package_applies
return window.open(`/managements/project_package_applies`)
}
// if(item.tiding_type === 'System'){
//众包详情 :id = container_id
return window.open(`/crowdsourcing/${item.container_id}`)
// }
}
default :
return window.open("/")
}
}
render() { render() {
let{page,limit,typeysl,count,isSpin,data}=this.state; let{page,limit,typeysl,count,isSpin,data}=this.state;
// console.log("6868686868"); // console.log("6868686868");
@ -117,10 +485,30 @@ class MessagSub extends Component{
<p className="edu-nodata-p mb20">暂无数据哦~</p> <p className="edu-nodata-p mb20">暂无数据哦~</p>
</div> </div>
:data.map((item,key)=>{ :data.map((item,key)=>{
console.log(data) // console.log(data)
// ridinglist-subs
var boolps=true;
if(item.container_type==="PraiseTread"||item.container_type==="Grade"||item.container_type==="ChallengeWorkScore"){
boolps=false;
}
if(item.container_type==="JournalsForMessage"){
if(item.parent_container_type==="Principal"){
boolps=false;
}
}
// if(item.container_type==="HomeworkCommon"){
// if(item.parent_container_type==="AnonymousAppeal"){
// boolps=false;
// }
// }
if(item.container_type==="ProjectPackage"){
if(item.tiding_type==="Destroyed_end"){
boolps=false;
}
}
return( return(
<div className="pl25 ridinglist edu-back-white" key={key}> <div className="pl25 ridinglist edu-back-white" key={key}>
<div className="ridinglist-sub clearfix df tiding_item"> <div className={boolps===true?"ridinglist-sub clearfix df tiding_item":"ridinglist-subs clearfix df tiding_item"} onClick={()=>this.gettourl(item)}>
<img onMouseDown={()=>this.myCome(item)} src={getImageUrl("images/"+item.trigger_user.image_url)} className="radius mr10 fl myimgw48 myimgh48"/> <img onMouseDown={()=>this.myCome(item)} src={getImageUrl("images/"+item.trigger_user.image_url)} className="radius mr10 fl myimgw48 myimgh48"/>
<div className="fl flex1"> <div className="fl flex1">
<p> <p>
@ -136,12 +524,15 @@ class MessagSub extends Component{
):""} ):""}
</p> </p>
<p className="color-grey-6 break_word_firefox" style={{wordBreak: "break-word"}}> <style>
{ {
item.content `.yslspansk span{
color: #FF9966!important;
}
`
} }
</p> </style>
<p className="color-grey-6 break_word_firefox yslspansk markdown-body" style={{wordBreak: "break-word"}} dangerouslySetInnerHTML={{__html:item.content}}></p>
</div> </div>
<span className={item.new_tiding===true?"new-point fr mr40 mt22":""}></span> <span className={item.new_tiding===true?"new-point fr mr40 mt22":""}></span>

@ -31,6 +31,7 @@ class MessagePrivate extends Component{
}catch (e) { }catch (e) {
} }
this.props.triggerRef(this)
// console.log("MessagePrivate"); // console.log("MessagePrivate");
// console.log(this.props); // console.log(this.props);
// console.log(this.props.match.params.userid); // console.log(this.props.match.params.userid);
@ -80,6 +81,40 @@ class MessagePrivate extends Component{
}) })
}) })
}; };
getdatas2=()=>{
this.setState({
isSpin:true,
});
let{limit,page}=this.state;
let url = `/users/${this.props.match&&this.props.match.params.userid}/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);
// console.log("调用了消失的方法");
// console.log("5454545454");
// 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);
this.setState({
isSpin:false,
})
})
};
paginationonChanges=(pageNumber)=>{ paginationonChanges=(pageNumber)=>{
this.setState({ this.setState({
@ -144,7 +179,7 @@ class MessagePrivate extends Component{
<span className="color-grey-c mr20">[{item.message_count}{"条"}]</span> <span className="color-grey-c mr20">[{item.message_count}{"条"}]</span>
<span className="color-grey-c">{moment(item.send_time).fromNow()}</span> <span className="color-grey-c">{moment(item.send_time).fromNow()}</span>
</p> </p>
<span className="color-grey-6 break_word_firefox " dangerouslySetInnerHTML={{__html:item.content}}></span> <span className="color-grey-6 break_word_firefox markdown-body" dangerouslySetInnerHTML={{__html:item.content}}></span>
</div> </div>
{item.unread === true ?<span className="new-point fr mt22"></span>:""} {item.unread === true ?<span className="new-point fr mt22"></span>:""}

@ -43,9 +43,11 @@ class Messagerouting extends Component{
// // courstype=courstype[3]; // // courstype=courstype[3];
// // console.log("45"); // // console.log("45");
// console.log(courstype); // console.log(courstype);
// console.log("Messagerouting46");
// console.log(this.props.current_user);
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
// console.log("11111111111"); // console.log("11111111111");
// console.log(prevProps); // console.log(prevProps);
@ -53,7 +55,9 @@ class Messagerouting extends Component{
// console.log(this.props); // console.log(this.props);
// console.log("33333333333"); // console.log("33333333333");
if(prevProps.current_user !== this.props.current_user){ if(prevProps.current_user !== this.props.current_user){
this.Messageprivatemessageunreadmessage(this.props.current_user.user_id); this.Messageprivatemessageunreadmessage(this.props.current_user.login);
// console.log("Messagerouting59");
// console.log(this.props.current_user);
} }
} }
//消息未读 //消息未读
@ -74,17 +78,21 @@ class Messagerouting extends Component{
}) })
}; };
SwitchonClick=(value)=>{ SwitchonClick=(value,child)=>{
this.setState({ this.setState({
routing:value, routing:value,
}); });
this.Messageprivatemessageunreadmessage(this.props.current_user.user_id); this.Messageprivatemessageunreadmessage(this.props.current_user.login);
if(value===1){ if(value===1){
this.props.history.replace(`/message/${this.props.current_user.user_id}/user_tidings`); this.props.history.replace(`/messages/${this.props.current_user.login}/user_tidings`);
this.homeworkendss1(child);
} }
if(value===2){ if(value===2){
this.props.history.replace(`/message/${this.props.current_user.user_id}/private_messages`);; this.props.history.replace(`/messages/${this.props.current_user.login}/private_messages`);
this.homeworkendss2(child);
} }
}; };
@ -109,10 +117,10 @@ class Messagerouting extends Component{
routing:i, routing:i,
}); });
if(i===1){ if(i===1){
this.props.history.replace(`/message/${this.props.current_user.user_id}/user_tidings`); this.props.history.replace(`/messages/${this.props.current_user.login}/user_tidings`);
} }
if(i===2){ if(i===2){
this.props.history.replace(`/message/${this.props.current_user.user_id}/private_messages`); this.props.history.replace(`/messages/${this.props.current_user.login}/private_messages`);
} }
}else { }else {
@ -120,7 +128,7 @@ class Messagerouting extends Component{
routing:i, routing:i,
}); });
console.log("22222222222"); console.log("22222222222");
this.props.history.replace(`/message/${this.props.current_user.user_id}/message_detail?target_ids=${id}`); this.props.history.replace(`/messages/${this.props.current_user.login}/message_detail?target_ids=${id}`);
} }
}; };
@ -145,6 +153,31 @@ class Messagerouting extends Component{
routing:3, routing:3,
}); });
} }
};
bindRef = ref => { this.child = ref };
homeworkendss1(child){
// console.log(child);
// // console.log(this.refs.childModel);
// console.log(child);
try {
child.getdatas();
}catch (e) {
}
//
}
homeworkendss2(child){
// console.log(child);
// // console.log(this.refs.childModel);
// console.log(child);
try {
child.getdatas2();
}catch (e) {
}
//
} }
render() { render() {
let{routing,unread_message_count,unread_tiding_count} =this.state; let{routing,unread_message_count,unread_tiding_count} =this.state;
@ -171,12 +204,12 @@ class Messagerouting extends Component{
{/*路由跳转*/} {/*路由跳转*/}
<ul className="edu-back-white"> <ul className="edu-back-white">
<li className={routing ===1?"nav pr active":"nav pr"}> <li className={routing ===1?"nav pr active":"nav pr"}>
<a onClick={(value)=>this.SwitchonClick(1)}>消息</a> <a onClick={(value,child)=>this.SwitchonClick(1,this.child)}>消息</a>
{unread_tiding_count>0?<span className="new-info">{unread_message_count}</span>:""} {unread_message_count===0?"":unread_message_count>0?<span className="new-info">{unread_message_count}</span>:""}
</li> </li>
<li className={routing ===2?"nav pr active":routing ===3?"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> <a onClick={(value,child)=>this.SwitchonClick(2,this.child)}>私信</a>
{unread_tiding_count>0?<span className="new-info">{unread_tiding_count}</span>:""} {unread_tiding_count===0?"":unread_tiding_count>0?<span className="new-info">{unread_tiding_count}</span>:""}
</li> </li>
</ul> </ul>
</div> </div>
@ -195,21 +228,21 @@ class Messagerouting extends Component{
<Switch> <Switch>
{/*/!*消息自路由*! name 是 /message/info/:userid/*/} {/*/!*消息自路由*! name 是 /message/info/:userid/*/}
<Route path="/message/:userid/user_tidings" <Route path="/messages/:userid/user_tidings"
render={ render={
(props) => (<MessagSub {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagSub>) (props) => (<MessagSub triggerRef={this.bindRef} {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagSub>)
} }
></Route> ></Route>
{/*/!*私信*! name 是letter/*/} {/*/!*私信*! name 是letter/*/}
<Route path="/message/:userid/private_messages" <Route path="/messages/:userid/private_messages"
render={ render={
(props) => (<MessagePrivate {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i,item)=>this.Modifyur(i,item)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagePrivate> ) (props) => (<MessagePrivate triggerRef={this.bindRef} {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i,item)=>this.Modifyur(i,item)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagePrivate> )
} }
></Route> ></Route>
{/*/!*私信聊天页面*! letters/*/} {/*/!*私信聊天页面*! letters/*/}
<Route path="/message/:userid/message_detail" <Route path="/messages/:userid/message_detail"
render={ render={
(props) => (<MessagChat {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagChat>) (props) => (<MessagChat triggerRef={this.bindRef} {...this.state} {...this.props} {...props} Message2={()=>this.Message2()} Modifyur={(i)=>this.Modifyur(i)} Mtab={(i)=>this.myxiaoxisixintab(i)}></MessagChat>)
} }
></Route> ></Route>

@ -18,7 +18,7 @@ class DownloadMessage extends Component {
setDownload=()=>{ setDownload=()=>{
this.modalCancel(); this.modalCancel();
window.open(`/message/${this.props.user.login}/message_detail?target_ids=1`) window.open(`/messages/${this.props.user.login}/message_detail?target_ids=1`)
} }
modalCancel = () => { modalCancel = () => {
this.setState({ this.setState({

@ -11,7 +11,7 @@ class DownloadMessageysl extends Component {
setDownload=()=>{ setDownload=()=>{
this.props.modalCancel(); this.props.modalCancel();
window.open(`/message/${this.props.user.login}/message_detail?target_ids=1`) window.open(`/messages/${this.props.user.login}/message_detail?target_ids=1`)
} }
render() { render() {

@ -297,8 +297,8 @@ class PackageIndexNEITaskDetails extends Component {
onMouseOver={this.setover} onMouseOver={this.setover}
onMouseOut={this.setout} onMouseOut={this.setout}
> >
{overtype===false?<a className="ContacttheTA fl" target="_blank" href={`/message/${this.props.current_user&&this.props.current_user.user_id}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" class="mr5" src={require('./newsone.png')} />联系TA</a>: {overtype===false?<a className="ContacttheTA fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" class="mr5" src={require('./newsone.png')} />联系TA</a>:
<a className="ContacttheTAs fl" target="_blank" href={`/message/${this.props.current_user&&this.props.current_user.user_id}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" className="mr5" <a className="ContacttheTAs fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" className="mr5"
src={require('./newstwo.png')}/>联系TA</a>} src={require('./newstwo.png')}/>联系TA</a>}
</div>} </div>}
</div> </div>
@ -411,7 +411,7 @@ class PackageIndexNEITaskDetails extends Component {
{item.status==="bidding_won"?<img src={gouxuan} className="yslgouxuanimg"/>:""} {item.status==="bidding_won"?<img src={gouxuan} className="yslgouxuanimg"/>:""}
<a href={`/users/${item.login}`}><img className="div1imgs" src={getImageUrl("images/"+item.image_url)}/></a> <a href={`/users/${item.login}`}><img className="div1imgs" src={getImageUrl("images/"+item.image_url)}/></a>
<div className="textall mt10" title={item.name}> <p className="ptext">{item.name}</p></div> <div className="textall mt10" title={item.name}> <p className="ptext">{item.name}</p></div>
{this.props.current_user&&this.props.current_user.login!=item.login?<a className="ContacttheTAs fl none" target="_blank" href={`/message/${this.props.current_user&&this.props.current_user.user_id}/message_detail?target_ids=${item.id}`}> {this.props.current_user&&this.props.current_user.login!=item.login?<a className="ContacttheTAs fl none" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${item.id}`}>
<img alt="头像" className="mr5" src={require('./newstwo.png')}/>联系TA <img alt="头像" className="mr5" src={require('./newstwo.png')}/>联系TA
</a>:""} </a>:""}
</div> </div>

@ -934,7 +934,7 @@ submittojoinclass=(value)=>{
<div className="fl mr30 edu-menu-panel headIcon"> <div className="fl mr30 edu-menu-panel headIcon">
{ user===undefined?"":user.login===""?"": <a { user===undefined?"":user.login===""?"": <a
href={`/message/${user.user_id}/user_tidings`} href={`/messages/${user.login}/user_tidings`}
style={{position:'relative'}} style={{position:'relative'}}
> >
<i className="iconfont icon-xiaoxilingdang color-white"></i> <i className="iconfont icon-xiaoxilingdang color-white"></i>

@ -200,6 +200,10 @@ body>.-task-title {
.HeaderSearch{ .HeaderSearch{
width: 325px; width: 325px;
/*right: 20px;*/
}
.HeaderSearch .ant-input-search{
right: 20px;
} }
.mainheighs{ .mainheighs{
height: 100%; height: 100%;

@ -83,7 +83,7 @@ class AccountCertification extends Component {
<div className="flexTable"> <div className="flexTable">
<div className="flexRow lineh-20 mb20"> <div className="flexRow lineh-20 mb20">
<div className="name">实名认证</div> <div className="name">实名认证</div>
<div className="description">有些课程需要实名认证才能加入哟还能获得500金币的奖励~ </div> <div className="description">实名认证可以增强你在平台的江湖地位还可以获得500金币的奖励~ </div>
<div className="status"> <div className="status">
{ {
basicInfo && basicInfo.authentication =="uncertified" ? basicInfo && basicInfo.authentication =="uncertified" ?
@ -96,7 +96,10 @@ class AccountCertification extends Component {
<div className="flexRow lineh-20"> <div className="flexRow lineh-20">
<div className="name">职业认证</div> <div className="name">职业认证</div>
<div className="description">教师认证完毕之后可创建课堂发布实训免金币查看所有实训答案.. </div>
{basicInfo && (basicInfo.identity == "teacher"
? <div className="description">教师通过认证可以克隆实训免金币查看实训答案和隐藏测试集... </div>
: <div className="description">通过认证可以获得500金币的奖励~ </div>)}
<div className="status"> <div className="status">
{ {
basicInfo && basicInfo.professional_certification =="uncertified" ? basicInfo && basicInfo.professional_certification =="uncertified" ?

@ -357,7 +357,7 @@ class Infos extends Component{
: :
<div className="inline"> <div className="inline">
<a href="javascript:void(0);" onClick={this.followPerson} className="user_default_btn user_watch_btn user_private_btn fl mr20">{followed ? "取消关注":"关注"}</a> <a href="javascript:void(0);" onClick={this.followPerson} className="user_default_btn user_watch_btn user_private_btn fl mr20">{followed ? "取消关注":"关注"}</a>
<a href={`${this.props.Headertop && this.props.Headertop.old_url}/message/${login}/message_detail?target_ids=${id}`} className="user_default_btn user_private_btn fl">私信</a> <a href={`${this.props.Headertop && this.props.Headertop.old_url}/messages/${login}/message_detail?target_ids=${id}`} className="user_default_btn user_private_btn fl">私信</a>
</div> </div>
} }
</div> </div>

@ -132,18 +132,19 @@ class InfosPackage extends Component{
delectproject=(id)=>{ delectproject=(id)=>{
let {cate,status}=this.state; let {category,status}=this.state;
debugger
let url=`/project_packages/${id}.json` let url=`/project_packages/${id}.json`
axios.delete(url).then((response) => { axios.delete(url).then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.getCourses(cate,status,1); this.getCourses(category,status,1);
} }
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
this.cancelProject; this.cancelProject();
} }
render(){ render(){
let{ let{

@ -150,9 +150,9 @@ class SearchPage extends Component{
<div className="tabtitle"> <div className="tabtitle">
<div className="tabtitles2"> <div className="tabtitles2">
<Menu mode="horizontal" className="tabtitless" selectedKeys={tab} onClick={this.changeTab}> <Menu mode="horizontal" className="tabtitless" selectedKeys={tab} onClick={this.changeTab}>
<Menu.Item className={"tabtitle1"} key="0">开发社区</Menu.Item> <Menu.Item className={"tabtitle1"} key="1">实践课程</Menu.Item>
<Menu.Item className={"tabtitle2"} key="1">实践课程</Menu.Item> <Menu.Item className={"tabtitle2"} key="2">翻转课堂</Menu.Item>
<Menu.Item className={"tabtitle2"} key="2">翻转课堂</Menu.Item> <Menu.Item className={"tabtitle2"} key="0">开发社区</Menu.Item>
<Menu.Item className={"tabtitle2"} key="3">交流问答</Menu.Item> <Menu.Item className={"tabtitle2"} key="3">交流问答</Menu.Item>
</Menu> </Menu>
</div> </div>

Loading…
Cancel
Save