博客详情动态加入二级回复的展开功能一级一级回复的更多功能。

This commit is contained in:
yuanke 2016-07-21 14:03:04 +08:00
parent ff42de619b
commit 7cd505ea4b
10 changed files with 141 additions and 43 deletions

View File

@ -75,14 +75,27 @@ module Mobile
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end
expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的底楼层
if (opt[:type] == 1 && !opt[:bottom])
opt[:bottom] = true
parents_reply = []
parents_reply = c.parent.nil? ? [] : parents_reply << c.parent #get_reply_parents_no_root(parents_reply, c)[0]
parents_reply
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
@ -90,26 +103,34 @@ module Mobile
expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的顶楼层
if (opt[:type] == 1 && !opt[:top])
opt[:top] = true
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
tStart = opt[:page]*2
tEnd = (opt[:page]+1)*2 - 1
parents_reply = parents_reply.reverse[tStart,tEnd]
parents_reply
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
else
[]
end
end
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end
end
end
end

View File

@ -221,8 +221,8 @@ class WechatsController < ActionController::Base
raise CoursesService::JoinCourseError.message(status[:state])
end
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
content: "课程名称#{course.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
return request.reply.news(news) do |article, n, index| # article is return object
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"

View File

@ -71,8 +71,8 @@ class SyllabusesService
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count
if count == 0
ws = WechatService.new
title = "恭喜您创建班级成功"
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情"
title = "恭喜您创建班级成功"
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情"
end
end

View File

@ -42,11 +42,61 @@
</div>
<div class="post-dynamic-time fr f13">{{journal.lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12" ng-bind-html="journal.content|safeHtml"></div>
<div class="cl"></div>
<!--<div class="post-reply-content c-grey2 mt12" ng-bind-html="journal.content|safeHtml"></div>-->
<div ng-show="journal.parents_count > 0" class="mult-reply-container mt10">
<!--<div ng-repeat="reply_top in journal.parents_reply_top" >-->
<div class="mult-reply-container mt2">
<ul ng-if="journal.parents_reply_top[1]" ng-include="'comment_reply'" ng-init="i=1;journal=journal"></ul>
<div class="post-avatar fl mr10"><img ng-src="{{journal.parents_reply_top[0].user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{journal.parents_reply_top[0].user.realname}}
<img ng-if="journal.parents_reply_top[0].user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="journal.parents_reply_top[0].user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{journal.parents_reply_top[0].lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="journal.parents_reply_top[0].content|safeHtml"></div>
<div class="cl"></div>
</div>
<!--</div>-->
<!--['weixin-tab', {'class-tab-active': currentTab == $index+1}]-->
<!--一层end-->
<!--<div class="mt10">-->
<!--<div class="post-avatar fl mr10"><img src="images/pic01.jpg" ng-src="/images/avatars/User/0" class="border-radius img-circle" height="30" width="30"></div>-->
<!--<div class="post-dynamic-author hidden fl ng-binding">yixin<img src="images/female.png" class="ml5" width="14"></div>-->
<!--<div class="post-dynamic-time fr f13">5分钟前</div>-->
<!--<div class="cl"></div>-->
<!--<div class="post-reply-content c-grey2 mt12 border-bottom-none">烤活牛你见过似的,美国那边吃人你怎么不信?</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--二层end-->
<div ng-click="showMoreReply(1,journal)" ng-show="journal.parents_reply_top.length + journal.parents_reply_bottom.length < journal.parents_count" class="mult-reply-hide"><span class="mult-reply-arrow" >&darr; </span><span class="mult-reply-arrow" style="display:none;" > &uarr;</span>点击展开更多楼层</div>
<div class="mt10" ng-repeat="reply_bottom in journal.parents_reply_bottom">
<div class="post-avatar fl mr10"><img ng-src="{{reply_bottom.user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{reply_bottom.user.realname}}
<img ng-if="reply_bottom.user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="reply_bottom.user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{reply_bottom.lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="reply_bottom.content|safeHtml"></div>
<div class="cl"></div>
</div>
</div>
<div class="post-reply-content">
<div class="mult-reply-content">
<div class="mt10" ng-bind-html="journal.content|safeHtml"></div>
</div>
<div class="cl"></div>
</div>
</div>
</div>
<div ng-if="has_more">
<div id="more_reply" class="more-events mt10" ng-click="showMoreReply(0,blog);">更多</div>
</div>
</div>
<div ng-if="!blog.locked" id="post_input_1" class="post-input-wrap post-box-shadow">
@ -63,4 +113,20 @@
</div>
</div>
</div>
</div>
<script id="comment_reply" type="text/ng-template">
<div class="mult-reply-container mt2">
<ul ng-if="journal.parents_reply_top[i+1]" ng-include="'comment_reply'" ng-init="i=i+1;journal=journal"></ul>
<div class="post-avatar fl mr10"><img ng-src="{{journal.parents_reply_top[i].user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{journal.parents_reply_top[i].user.realname}}
<img ng-if="journal.parents_reply_top[i].user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="journal.parents_reply_top[i].user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{journal.parents_reply_top[i].lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="journal.parents_reply_top[i].content|safeHtml"></div>
<div class="cl"></div>
</div>
</script>

View File

@ -3,9 +3,9 @@
<div class="blue-title">管理课程</div>
<form novalidate name="classForm">
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input ng-change="syllabus.change = true" ng-class="['new-class-input ml25', {'c-grey':syllabus.change} ]" ng-model="syllabus.tmptitle" required placeholder="请输入课程名" /></div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input ng-change="syllabus.change = true" ng-class="['new-class-input ml25', {'c-grey':syllabus.change} ]" ng-model="syllabus.tmptitle" required placeholder="请输入课程名,如:软件工程" /></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses" ng-show="course.can_setting"><span class="fl ml15 c-grey3">班级</span><input ng-change="course.change = true" required ng-class="['new-class-input ml25', {'c-grey':course.change} ]" ng-model="course.tmpname" placeholder="请输入班级名" /><a ng-click="deleteClass($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses" ng-show="course.can_setting"><span class="fl ml15 c-grey3">班级</span><input ng-change="course.change = true" required ng-class="['new-class-input ml25', {'c-grey':course.change} ]" ng-model="course.tmpname" placeholder="请输入班级名计算机学院A班" /><a ng-click="deleteClass($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
</form>

View File

@ -3,9 +3,9 @@
<div class="blue-title">新建课程</div>
<form novalidate name="classForm">
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入课程名" /></div>
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入课程名,如:软件工程" /></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses"><span class="fl ml15 c-grey3">班级</span><input required class="new-class-input ml25" ng-model="course.name" placeholder="请输入班级名" /><a ng-click="deleteClass($index)" ng-show="!$first" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses"><span class="fl ml15 c-grey3">班级</span><input required class="new-class-input ml25" ng-model="course.name" placeholder="请输入班级名计算机学院A班" /><a ng-click="deleteClass($index)" ng-show="!$first" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
</form>

View File

@ -19,6 +19,6 @@
<!--<li ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>-->
<!--</ul>-->
<div class="btn2 bg-blue" ng-click="sendToCourses()">发送</div>
<div ng-show="syllabuses.length>0" class="btn2 bg-blue" ng-click="sendToCourses()">发送</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div>

View File

@ -9,12 +9,15 @@ app.controller('BlogController',
replyType: 'BlogComment',
loadCallback: function(data){
console.log(data.data);
//回复级别 0 一级回复 1 二级回复
replytype = data.type;
page = data.page;
if (replytype == 0){
if (page == 0){
$scope.blog = data.data;
$scope.page = 0;
}
else{
$scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children);
@ -23,13 +26,14 @@ app.controller('BlogController',
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
for (var i in $scope.blog.blog_comment_children) {
var comment = $scope.blog.blog_comment_children[i];
if(comment.id == comment_id){
// comment.parents_reply_top = comment.parents_reply_top.concat(data.data.parents_reply_top);
comment.parents_reply_top = data.data.parents_reply_top.concat(comment.parents_reply_top);
}
}
}
},
replyCallback: function(){

View File

@ -254,8 +254,15 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au
decreaseCommonPraise(act);
};
args.scope.morereply = function(data,replytype,page){
loadCommonData(data.id, args.type,replytype,page).then(function successCallback(response) {
args.scope.showMoreReply = function(replytype,data){
if(!data.page){
data.page = 1;
}
else{
data.page = data.page + 1;
}
loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) {
args.loadCallback(response.data);
}, function errorCallback(response) {
});

View File

@ -225,7 +225,7 @@ a.underline {text-decoration:underline;}
.forget-psw {position:fixed; bottom:10px;}
/*二级回复*/
.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999; margin-top:-1px;}
.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999;}
.mult-reply-content{ color:#707070; font-size:13px;}
.mult-reply-hide{ text-align:center; display:block; font-size:14px; color:#aaa; border-bottom:1px solid #F3DDB3; padding:8px 0;}
.mult-reply-arrow{ color:#aaa; margin-right:10px; font-size:14px; font-weight:bold;}