From 7cd505ea4bed9102f42fd9563d601591f8167b1f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Jul 2016 14:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E8=AF=A6=E6=83=85=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=8A=A0=E5=85=A5=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E5=B1=95=E5=BC=80=E5=8A=9F=E8=83=BD=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=9B=9E=E5=A4=8D=E7=9A=84=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/blog_comment.rb | 61 ++++++++++----- app/controllers/wechats_controller.rb | 4 +- app/services/syllabuses_service.rb | 4 +- public/assets/wechat/blog_detail.html | 74 ++++++++++++++++++- public/assets/wechat/edit_class.html | 4 +- public/assets/wechat/new_class.html | 4 +- public/assets/wechat/send_class_list.html | 2 +- public/javascripts/wechat/controllers/blog.js | 18 +++-- public/javascripts/wechat/others/factory.js | 11 ++- public/stylesheets/weui/weixin.css | 2 +- 10 files changed, 141 insertions(+), 43 deletions(-) diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index cd7902097..3f58e901f 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index c72e04e14..e596042d9 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -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" diff --git a/app/services/syllabuses_service.rb b/app/services/syllabuses_service.rb index d5dec9f88..fcb70653b 100644 --- a/app/services/syllabuses_service.rb +++ b/app/services/syllabuses_service.rb @@ -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 diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index aabea2532..d18575b94 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -42,11 +42,61 @@
{{journal.lasted_comment}}
-
-
+ +
+ +
+ +
+ +
{{journal.parents_reply_top[0].lasted_comment}}
+
+
+
+
+ + + + + + + + + + + + + +
点击展开更多楼层
+ +
+
+ +
{{reply_bottom.lasted_comment}}
+
+
+
+
+
+
+
+
+
+
+
- +
+
更多
+
@@ -63,4 +113,20 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/public/assets/wechat/edit_class.html b/public/assets/wechat/edit_class.html index d6bc7e03c..62022566b 100644 --- a/public/assets/wechat/edit_class.html +++ b/public/assets/wechat/edit_class.html @@ -3,9 +3,9 @@
管理课程
-
课程
+
课程
-
班级删除
+
班级删除
+新增班级
完成
diff --git a/public/assets/wechat/new_class.html b/public/assets/wechat/new_class.html index 039d19d75..5ce75d358 100644 --- a/public/assets/wechat/new_class.html +++ b/public/assets/wechat/new_class.html @@ -3,9 +3,9 @@
新建课程
-
课程
+
课程
-
班级删除
+
班级删除
+新增班级
完成
diff --git a/public/assets/wechat/send_class_list.html b/public/assets/wechat/send_class_list.html index b66b5008d..68a9d1ae5 100644 --- a/public/assets/wechat/send_class_list.html +++ b/public/assets/wechat/send_class_list.html @@ -19,6 +19,6 @@ -
发送
+
发送
diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index dc9f4bf39..40902fa12 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -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(){ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index dcd78740f..a329c2906 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -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) { }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ed3af75ae..cdac0d1a3 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -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;} \ No newline at end of file