我的动态中三类动态之间切换的效果
This commit is contained in:
parent
d49bc8b114
commit
b994e786ab
|
@ -10,30 +10,44 @@ module Mobile
|
|||
params do
|
||||
requires :page, type: Integer
|
||||
requires :token, type: String
|
||||
requires :container_type, type: String
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
|
||||
user = current_user
|
||||
|
||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
container_type = params[:container_type] ? params[:container_type] : "All"
|
||||
|
||||
if container_type == "All" || container_type == "Project"
|
||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
end
|
||||
|
||||
if container_type == "All" || container_type == "Course"
|
||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
end
|
||||
|
||||
page = params[:page] ? params[:page] : 0
|
||||
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
principal_types = "JournalsForMessage"
|
||||
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
||||
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
||||
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? " " :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
||||
blog_ids = "(" + watched_user_blog_ids + ")"
|
||||
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||
|
||||
if container_type == "Course"
|
||||
activities = UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
|
||||
elsif container_type == "Project"
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
|
||||
else
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||
end
|
||||
all_count = activities.count
|
||||
activities = activities.limit(10).offset(page * 10)
|
||||
count = activities.count
|
||||
|
@ -42,6 +56,7 @@ module Mobile
|
|||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
present :container_type, container_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,14 +6,19 @@
|
|||
|
||||
<div class="class-detail-name">我的动态</div>
|
||||
|
||||
<!--<div class="tab-wrap">-->
|
||||
<!--<a id="class_tab_1" href="javascript:void(0);" class="weixin-tab class-tab-active" ng-click="HoverLi(1)">所有动态<span id="tab_arrow_1" class="tab-active-arrow"></span></a>-->
|
||||
<!--<a id="class_tab_2" href="javascript:void(0);" class="weixin-tab" ng-click="HoverLi(2)">课程动态<span id="tab_arrow_2" class="tab-active-arrow undis"></span></a>-->
|
||||
<!--<a id="class_tab_3" href="javascript:void(0);" class="weixin-tab" ng-click="HoverLi(3)">项目动态<span id="tab_arrow_3" class="tab-active-arrow undis"></span></a>-->
|
||||
<!--</div>-->
|
||||
<div class="tab-wrap">
|
||||
<a id="class_tab_1" href="javascript:void(0);" class="weixin-tab class-tab-active" onclick="HoverLi(1);">所有动态<span id="tab_arrow_1" class="tab-active-arrow"></span></a>
|
||||
<a id="class_tab_2" href="javascript:void(0);" class="weixin-tab" onclick="HoverLi(2);">课程动态<span id="tab_arrow_2" class="tab-active-arrow undis"></span></a>
|
||||
<a id="class_tab_3" href="javascript:void(0);" class="weixin-tab" onclick="HoverLi(3);">项目动态<span id="tab_arrow_3" class="tab-active-arrow undis"></span></a>
|
||||
<a ng-click="tab($index+1)" ng-repeat="menu in menus" id="class_tab_1" href="javascript:void(0);" ng-class="['weixin-tab', {'class-tab-active': currentTab == $index+1}]">{{menu}}</a>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="act in activities">
|
||||
<div ng-if="act.container_type=='Course'">
|
||||
<div ng-class="{'undis': currentTab!=1}">
|
||||
<div ng-repeat="act in activities">
|
||||
|
||||
<div ng-if="act.container_type=='Course' ">
|
||||
<div ng-if="act.act_type=='HomeworkCommon'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
|
@ -140,7 +145,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.container_type=='Project'">
|
||||
<div ng-if="act.container_type=='Project' ">
|
||||
<div ng-if="act.act_type=='Issue'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
|
@ -230,7 +235,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.container_type=='Principal'">
|
||||
<div ng-if="act.container_type=='Principal' ">
|
||||
<div ng-if="act.act_type=='JournalsForMessage'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
|
@ -268,7 +273,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.act_type=='BlogComment'">
|
||||
<div ng-if="act.act_type=='BlogComment' ">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
|
@ -306,10 +311,242 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div ng-if="has_more">
|
||||
<div id="more_activities" class="more-events mt10" ng-click="loadActData(page+1);">更多</div>
|
||||
<div ng-if="has_more">
|
||||
<div id="more_activities" class="more-events mt10" ng-click="loadActData(1,page+1);">更多</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-class="{'undis': currentTab!=2}">
|
||||
<div ng-repeat="act in course_activities">
|
||||
<div ng-if="act.container_type=='Course' ">
|
||||
<div ng-if="act.act_type=='HomeworkCommon'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div dataID = "{{act.act_id}}" ng-click="goDetail('homework',act.act_id, act.id)" id="act_{{act.id}}">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-dynamic-author hidden fl">
|
||||
<span ng-if="act.author.realname != ' '">{{act.author.realname}}</span>
|
||||
<span ng-if="act.author.realname == ' '">{{act.author.nickname}}</span>
|
||||
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
|
||||
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
|
||||
</div>
|
||||
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【作业】{{act.subject|safeHtml}}</div>
|
||||
<div class="post-content c-grey3 mt10 mb10">
|
||||
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
|
||||
<span class="mr15 f13 c-grey2">迟交扣分:{{act.homework_common_detail.late_penalty}}分</span> <span ng-if="!act.homework_common_detail.anonymous_comment" class="f13 c-grey2">匿评开启时间:{{act.homework_common_detail.evaluation_start}}</span><br />
|
||||
<span ng-if="!act.homework_common_detail.anonymous_comment" class="mr15 f13 c-grey2">缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品</span> <span ng-if="!act.homework_common_detail.anonymous_comment" class="f13 c-grey2">匿评关闭时间:{{act.homework_common_detail.evaluation_end}}</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
|
||||
<div class="fr f13">
|
||||
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>
|
||||
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
</div>
|
||||
<div class="fr mr25 f13">
|
||||
<a ng-if="!act.reply_count" ng-click="goDetail('homework',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
|
||||
<a ng-if="act.reply_count" ng-click="goDetail('homework',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.act_type=='News'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div dataID = "{{act.act_id}}" ng-click="goDetail('course_notice',act.act_id, act.id)" id="act_{{act.id}}">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-dynamic-author hidden fl">
|
||||
<span ng-if="act.author.realname != ' '">{{act.author.realname}}</span>
|
||||
<span ng-if="act.author.realname == ' '">{{act.author.nickname}}</span>
|
||||
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
|
||||
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
|
||||
</div>
|
||||
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【通知】{{act.subject|safeHtml}}</div>
|
||||
<div class="post-content c-grey3 mt10 mb10">
|
||||
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
|
||||
<div class="fr f13">
|
||||
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>
|
||||
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
</div>
|
||||
<div class="fr mr25 f13">
|
||||
<a ng-if="!act.reply_count" ng-click="goDetail('course_notice',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
|
||||
<a ng-if="act.reply_count" ng-click="goDetail('course_notice',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.act_type=='Message'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div dataID = "{{act.act_id}}" ng-click="goDetail('course_discussion',act.act_id, act.id)" id="act_{{act.id}}">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-dynamic-author hidden fl">
|
||||
<span ng-if="act.author.realname != ' '">{{act.author.realname}}</span>
|
||||
<span ng-if="act.author.realname == ' '">{{act.author.nickname}}</span>
|
||||
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
|
||||
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
|
||||
</div>
|
||||
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【帖子】{{act.subject|safeHtml}}</div>
|
||||
<div class="post-content c-grey3 mt10 mb10">
|
||||
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
|
||||
</div>
|
||||
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
|
||||
<div class="fr f13">
|
||||
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>
|
||||
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
</div>
|
||||
<div class="fr mr25 f13">
|
||||
<a ng-if="!act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
|
||||
<a ng-if="act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-if="act.act_type=='Course'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f13 fb mr10">{{act.author.realname}}</span>创建了<span class="c-grey3 f13 fb ml10">{{act.course_project_name}} | 课程</span></div>
|
||||
<div class="post-title hidden"><span class="mr10">{{act.latest_update}}</span></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="course_has_more">
|
||||
<div id="more_course_activities" class="more-events mt10" ng-click="loadActData(2,course_page+1);">更多</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-class="{'undis': currentTab!=3}">
|
||||
<div ng-repeat="act in project_activities">
|
||||
<div ng-if="act.container_type=='Project' ">
|
||||
<div ng-if="act.act_type=='Issue'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div dataID = "{{act.act_id}}" ng-click="goDetail('issues',act.act_id, act.id)" id="act_{{act.id}}">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-dynamic-author hidden fl">
|
||||
<span ng-if="act.author.realname != ' '">{{act.author.realname}}</span>
|
||||
<span ng-if="act.author.realname == ' '">{{act.author.nickname}}</span>
|
||||
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
|
||||
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
|
||||
</div>
|
||||
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【帖子】{{act.subject|safeHtml}}</div>
|
||||
<div class="post-content c-grey3 mt10 mb10">
|
||||
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
|
||||
<span class="mr15 f13 c-grey2">状态:{{act.issue_detail.issue_status}}</span> <span class="mr15 f13 c-grey2">优先级:{{act.issue_detail.issue_priority}}</span> <br />
|
||||
<span class="mr15 f13 c-grey2">指派给:{{act.issue_detail.issue_assigned_to}}</span> <span class="mr15 f13 c-grey2">完成度:{{act.issue_detail.done_ratio}}%</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
|
||||
<div class="fr f13">
|
||||
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>
|
||||
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
</div>
|
||||
<div class="fr mr25 f13">
|
||||
<a ng-if="!act.reply_count" ng-click="goDetail('issues',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
|
||||
<a ng-if="act.reply_count" ng-click="goDetail('issues',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-if="act.act_type=='Message'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div dataID = "{{act.act_id}}" ng-click="goDetail('project_discussion',act.act_id, act.id)" id="act_{{act.id}}">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-dynamic-author hidden fl">
|
||||
<span ng-if="act.author.realname != ' '">{{act.author.realname}}</span>
|
||||
<span ng-if="act.author.realname == ' '">{{act.author.nickname}}</span>
|
||||
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
|
||||
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
|
||||
</div>
|
||||
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【帖子】{{act.subject|safeHtml}}</div>
|
||||
<div class="post-content c-grey3 mt10 mb10">
|
||||
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
|
||||
<div class="fr f13">
|
||||
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>赞</span></div>
|
||||
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
|
||||
</div>
|
||||
<div class="fr mr25 f13">
|
||||
<a ng-if="!act.reply_count" ng-click="goDetail('project_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
|
||||
<a ng-if="act.reply_count" ng-click="goDetail('project_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="act.act_type=='Project'">
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f13 fb mr10">{{act.author.realname}}</span>创建了<span class="c-grey3 f13 fb ml10">{{act.course_project_name}} | 项目</span></div>
|
||||
<div class="post-title hidden"><span class="mr10">{{act.latest_update}}</span></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-if="project_has_more">
|
||||
<div id="more_project_activities" class="more-events mt10" ng-click="loadActData(3,project_page+1);">更多</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible"></my-alert>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -6,6 +6,8 @@ app.controller('ActivityController',
|
|||
return url;
|
||||
};
|
||||
|
||||
$scope.menus = ['所有动态', '课程动态', '项目动态'];
|
||||
|
||||
$scope.alertService = alertService.create();
|
||||
console.log("ActivityController load");
|
||||
|
||||
|
@ -13,33 +15,119 @@ app.controller('ActivityController',
|
|||
$scope.activities = rms.get("activities") || [];
|
||||
$scope.has_more = rms.get("has_more");
|
||||
|
||||
$scope.loadActData = function(page){
|
||||
$scope.course_page = rms.get('course_page') || 0;
|
||||
$scope.course_activities = rms.get("course_activities") || [];
|
||||
$scope.course_has_more = rms.get("course_has_more");
|
||||
|
||||
$scope.project_page = rms.get('project_page') || 0;
|
||||
$scope.project_activities = rms.get("project_activities") || [];
|
||||
$scope.project_has_more = rms.get("project_has_more");
|
||||
|
||||
$scope.loadActData = function(index,page){
|
||||
container_type = "All";
|
||||
switch(index){
|
||||
case 1:
|
||||
container_type = "All";
|
||||
$scope.page = page;
|
||||
break;
|
||||
case 2:
|
||||
container_type = "Course";
|
||||
$scope.course_page = page;
|
||||
break;
|
||||
case 3:
|
||||
container_type = "Project";
|
||||
$scope.project_page = page;
|
||||
break;
|
||||
}
|
||||
|
||||
$scope.page = page;
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "activities",
|
||||
data: {token: auth.token(), page: page}
|
||||
data: {token: auth.token(), page: page, container_type: container_type}
|
||||
}).then(function successCallback(response) {
|
||||
if(response.data.page >0) {
|
||||
$scope.activities = $scope.activities.concat(response.data.data);
|
||||
switch(response.data.container_type){
|
||||
case "All":
|
||||
$scope.activities = $scope.activities.concat(response.data.data);
|
||||
break;
|
||||
case "Course":
|
||||
$scope.course_activities = $scope.course_activities.concat(response.data.data);
|
||||
break;
|
||||
case "Project":
|
||||
$scope.project_activities = $scope.project_activities.concat(response.data.data);
|
||||
break;
|
||||
case 3:
|
||||
}
|
||||
} else {
|
||||
$scope.activities = response.data.data;
|
||||
switch(response.data.container_type){
|
||||
case "All":
|
||||
$scope.activities = response.data.data;
|
||||
break;
|
||||
case "Course":
|
||||
$scope.course_activities = response.data.data;
|
||||
break;
|
||||
case "Project":
|
||||
$scope.project_activities = response.data.data;
|
||||
break;
|
||||
case 3:
|
||||
}
|
||||
}
|
||||
|
||||
rms.save("activities", $scope.activities);
|
||||
$scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
||||
rms.save('has_more', $scope.has_more);
|
||||
rms.save('page', response.data.page);
|
||||
|
||||
switch(response.data.container_type){
|
||||
case "All":
|
||||
rms.save("activities", $scope.activities);
|
||||
$scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
||||
rms.save('has_more', $scope.has_more);
|
||||
rms.save('page', response.data.page);
|
||||
break;
|
||||
case "Course":
|
||||
rms.save("course_activities", $scope.course_activities);
|
||||
$scope.course_has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
||||
rms.save('course_has_more', $scope.course_has_more);
|
||||
rms.save('course_page', response.data.page);
|
||||
break;
|
||||
case "Project":
|
||||
rms.save("project_activities", $scope.project_activities);
|
||||
$scope.project_has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
||||
rms.save('project_has_more', $scope.project_has_more);
|
||||
rms.save('project_page', response.data.page);
|
||||
break;
|
||||
case 3:
|
||||
}
|
||||
console.log(response.data);
|
||||
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
};
|
||||
|
||||
$scope.tab = function(index){
|
||||
$scope.currentTab = index;
|
||||
switch(index){
|
||||
//ALL
|
||||
case 1:
|
||||
if($scope.activities.length<=0){
|
||||
$scope.loadActData(index,0);
|
||||
}
|
||||
break;
|
||||
//Course
|
||||
case 2:
|
||||
if($scope.course_activities.length<=0){
|
||||
$scope.loadActData(index,0);
|
||||
}
|
||||
break;
|
||||
//Project
|
||||
case 3:
|
||||
if($scope.project_activities.length<=0){
|
||||
$scope.loadActData(index,0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.currentTab = 1;
|
||||
|
||||
if($scope.activities.length<=0){
|
||||
$scope.loadActData(0);
|
||||
$scope.loadActData(1,0);
|
||||
} else {
|
||||
$timeout(function(){
|
||||
window.scrollTo(0, rms.get("yoffset"));
|
||||
|
|
Loading…
Reference in New Issue