From cdb77828497c06c5dd9e927330c42ec6c83c8052 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 22 Jul 2016 15:37:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=99=A4=E4=BA=86issue=20=E5=92=8Cnews?= =?UTF-8?q?=E9=83=BD=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=BA=8C=E7=BA=A7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/whomeworks.rb | 10 +- app/api/mobile/entities/blog_comment.rb | 7 +- app/api/mobile/entities/issue.rb | 10 +- app/api/mobile/entities/jours.rb | 95 ++++++++++++++++++- app/api/mobile/entities/message.rb | 76 ++++++++++++++- app/api/mobile/entities/news.rb | 4 +- app/api/mobile/entities/whomework.rb | 17 +++- app/controllers/courses_controller.rb | 7 +- public/assets/wechat/blog_detail.html | 33 +------ public/assets/wechat/course_notice.html | 4 +- public/assets/wechat/homework_detail.html | 51 ++++++++-- public/assets/wechat/issue_detail.html | 4 +- public/assets/wechat/jour_message_detail.html | 48 ++++++++-- public/assets/wechat/project_discussion.html | 47 ++++++++- .../wechat/templates/comment_reply.html | 13 +++ public/javascripts/wechat/controllers/blog.js | 8 +- .../wechat/controllers/discussion.js | 28 +++++- .../wechat/controllers/homework.js | 29 +++++- .../wechat/controllers/journals.js | 29 +++++- .../wechat/directives/comment_reply.js | 9 ++ public/javascripts/wechat/others/factory.js | 31 +++++- 21 files changed, 471 insertions(+), 89 deletions(-) create mode 100644 public/assets/wechat/templates/comment_reply.html create mode 100644 public/javascripts/wechat/directives/comment_reply.js diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index db1e7e269..9d03eed9f 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -13,8 +13,14 @@ module Mobile #0一级回复的更多 1 二级回复的更多 type = params[:type] || 0 page = params[:page] || 0 - homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page + + if type == 0 + homework = HomeworkCommon.find params[:id] + present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework" + else + jour = JournalsForMessage.find params[:id] + present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework" + end present :type, type present :page, page present :status, 0 diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 3f58e901f..726949bb5 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -51,9 +51,8 @@ module Mobile blog_comment_expose :id blog_comment_expose :locked blog_comment_expose :praise_count - expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| + expose :all_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) - ##自己的父回复为空 才有子回复 if !opt[:children] if c.parent.nil? && opt[:type] == 0 opt[:children] = true @@ -86,7 +85,7 @@ module Mobile #取二级回复的底楼层 parents_reply = [] parents_reply = get_reply_parents_no_root(parents_reply, c) - if parents_reply.count > 0 && !opt[:bottom] + if parents_reply.count > 0 && parents_reply.count != 2 && !opt[:bottom] if opt[:type] == 1 # opt[:bottom] = true # parents_reply[opt[:page]..opt[:page]] @@ -105,7 +104,7 @@ module Mobile #取二级回复的顶楼层 parents_reply = [] parents_reply = get_reply_parents_no_root(parents_reply, c) - if parents_reply.count > 0 && !opt[:top] + if parents_reply.count >= 2 && !opt[:top] if opt[:type] == 1 opt[:bottom] = true tStart = (opt[:page]-1)*5+2 diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index b99ea03a5..dc4fd0567 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -22,10 +22,10 @@ module Mobile (get_user(issue.assigned_to_id)).login when :issue_status IssueStatus.find(issue.status_id).name - when :journals_count - # issue.journals.where("notes is not null and notes != ''").count - all_comments = [] - get_all_children(all_comments, f).count + when :comment_count + issue.journals.where("notes is not null and notes != ''").count + # all_comments = [] + # get_all_children(all_comments, f).count when :project_name issue.project.name when :praise_count @@ -49,7 +49,7 @@ module Mobile issue_expose :issue_priority issue_expose :issue_assigned_to issue_expose :issue_status - issue_expose :journals_count + issue_expose :comment_count issue_expose :project_name issue_expose :praise_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index f98d7a9ed..0e4c699c2 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -17,7 +17,7 @@ module Mobile case field when :lasted_comment time_from_now f.created_on - when :reply_count + when :comment_count # f.children.count all_comments = [] get_all_children(all_comments, f).count @@ -27,6 +27,8 @@ module Mobile 'JournalsForMessage' when :act_id f.id + when :content + f.notes end end end @@ -42,10 +44,10 @@ module Mobile end jours_expose :created_on jours_expose :lasted_comment - jours_expose :notes + jours_expose :content jours_expose :m_reply_id jours_expose :m_parent_id - jours_expose :reply_count + jours_expose :comment_count jours_expose :praise_count expose :course,using:Mobile::Entities::Course do |f,opt| if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" @@ -55,9 +57,20 @@ module Mobile expose :reply_user,using: Mobile::Entities::User do |f, opt| f.at_user end - expose :child_reply,using: Mobile::Entities::Jours do |f, opt| + expose :all_children,using: Mobile::Entities::Jours do |f, opt| if f.is_a?(::JournalsForMessage) - f.children.reverse + # f.children.reverse + if !opt[:children] && opt[:comment_type].nil? + if f.parent.nil? && opt[:type] == 0 + opt[:children] = true + all_comments = [] + tStart = opt[:page]*5 + tEnd = (opt[:page]+1)*5 - 1 + + all_comments = get_all_children(all_comments, f)[tStart..tEnd] + all_comments + end + end end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| @@ -67,6 +80,78 @@ module Mobile has_praise = obj.empty? ? false : true has_praise end + + expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options| + parents_reply = [] + + if options[:comment_type].nil? + parents_reply = get_reply_parents_no_root(parents_reply, instance) + elsif options[:comment_type] == "homework" + parents_reply = get_reply_parents(parents_reply, instance) + end + parents_reply.count + end + + expose :parents_reply_bottom, using:Mobile::Entities::Jours do |f,opt| + if f.is_a? (::JournalsForMessage) + #取二级回复的底楼层 + parents_reply = [] + if opt[:comment_type].nil? + parents_reply = get_reply_parents_no_root(parents_reply, f) + elsif opt[:comment_type] == "homework" + parents_reply = get_reply_parents(parents_reply, f) + end + if parents_reply.count > 0 && parents_reply.count != 2 && !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 + + expose :parents_reply_top, using:Mobile::Entities::Jours do |f,opt| + if f.is_a? (::JournalsForMessage) + #取二级回复的顶楼层 + parents_reply = [] + + if opt[:comment_type].nil? + parents_reply = get_reply_parents_no_root(parents_reply, f) + elsif opt[:comment_type] == "homework" + parents_reply = get_reply_parents(parents_reply, f) + end + if parents_reply.count >= 2 && !opt[:top] + if opt[:type] == 1 + opt[:bottom] = true + tStart = (opt[:page]-1)*5+2 + tEnd = (opt[:page])*5+2 - 1 + + if tEnd >= parents_reply.count - 1 + tEnd = parents_reply.count - 2 + end + + 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 + end end end diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index d58192378..c2744f63a 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -30,7 +30,7 @@ module Mobile 'Message' when :act_id u.id - when :replies_count + when :comment_count all_comments = [] get_all_children(all_comments, u).count end @@ -51,15 +51,26 @@ module Mobile message_expose :board_id message_expose :subject message_expose :content - message_expose :replies_count + message_expose :comment_count message_expose :praise_count message_expose :created_on message_expose :locked message_expose :id message_expose :lasted_comment - expose :message_children,using:Mobile::Entities::Message do |c,opt| + expose :all_children,using:Mobile::Entities::Message do |c,opt| if c.is_a? (::Message) - c.children.reverse + # c.children.reverse + if !opt[:children] + if c.parent.nil? && opt[:type] == 0 + opt[:children] = true + all_comments = [] + tStart = opt[:page]*5 + tEnd = (opt[:page]+1)*5 - 1 + + all_comments = get_all_children(all_comments, c)[tStart..tEnd] + all_comments + end + end end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| @@ -69,6 +80,63 @@ module Mobile has_praise = obj.empty? ? false : true 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::Message do |c,opt| + if c.is_a? (::Message) + #取二级回复的底楼层 + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, c) + if parents_reply.count > 0 && parents_reply.count != 2 && !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 + + expose :parents_reply_top, using:Mobile::Entities::Message do |c,opt| + if c.is_a? (::Message) + #取二级回复的顶楼层 + parents_reply = [] + parents_reply = get_reply_parents_no_root(parents_reply, c) + if parents_reply.count >= 2 && !opt[:top] + if opt[:type] == 1 + opt[:bottom] = true + tStart = (opt[:page]-1)*5+2 + tEnd = (opt[:page])*5+2 - 1 + + if tEnd >= parents_reply.count - 1 + tEnd = parents_reply.count - 2 + end + + 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 end end end \ No newline at end of file diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index ff1452b1c..d69232c44 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -24,7 +24,7 @@ module Mobile 'News' when :act_id f.id - when :comments_count + when :comment_count all_comments = [] get_all_children(all_comments, f).count end @@ -70,7 +70,7 @@ module Mobile #发布时间 news_expose :created_on #评论数量 - news_expose :comments_count + news_expose :comment_count news_expose :praise_count #课程名字 news_expose :course_name diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 8985f3d60..7178ff67d 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -26,7 +26,7 @@ module Mobile wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) when :praise_count get_activity_praise_num(wh) - when :whomework_journal_count + when :comment_count wh.journals_for_messages.count when :course_name wh.course.name @@ -58,6 +58,7 @@ module Mobile expose :anonymous_comment expose :quotes expose :is_open + expose :id whomework_expose :act_type whomework_expose :act_id whomework_expose :course_name @@ -66,11 +67,19 @@ module Mobile whomework_expose :evaluation_start whomework_expose :evaluation_end whomework_expose :praise_count - whomework_expose :whomework_journal_count - expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| + whomework_expose :comment_count + expose :all_children, using: Mobile::Entities::Jours do |f, opt| #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) if f.is_a?(::HomeworkCommon) - f.journals_for_messages.reverse + # f.journals_for_messages.reverse + if !opt[:children] && opt[:type] == 0 + opt[:children] = true + tStart = opt[:page]*5 + tEnd = (opt[:page]+1)*5 - 1 + + all_comments = f.journals_for_messages.reorder("created_on desc") + all_comments[tStart..tEnd] + end end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 665273ae0..28366b109 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -634,8 +634,11 @@ class CoursesController < ApplicationController end if @course #发送微信消息 - ss = SyllabusesService.new - ss.send_wechat_create_class_notice User.current,@course + count = ShieldWechatMessage.where("container_type='User' and container_id=#{User.current.id} and shield_type='Course' and shield_id=#{@course.id}").count + if count == 0 + ss = SyllabusesService.new + ss.send_wechat_create_class_notice User.current,@course + end respond_to do |format| flash[:notice] = l(:notice_successful_create) format.html {redirect_to course_url(@course)} diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index d18575b94..075c752ef 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -31,8 +31,8 @@
-
-
+
+
-
-
+
+
{{journal.lasted_comment}}
-
+ +
+
    + +
    点击展开更多楼层
    +
    +
    + +
    {{reply_bottom.lasted_comment}}
    +
    +
    +
    +
    +
    + +
    - +
    +
    更多
    +
    @@ -65,4 +86,20 @@
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 953fec3c7..f33f6c0f6 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -28,8 +28,8 @@
    {{issue.praise_count}}
    - 回复 - {{issue.journals_count}} + 回复 + {{issue.comment_count}}
    diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index cdeeaa30b..288a78688 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -22,15 +22,15 @@
    {{message.praise_count}}
    - 回复 - {{message.reply_count}} + 回复 + {{message.comment_count}}
    -
    +
    {{journal.lasted_comment}}
    -
    + +
    +
      +
      点击展开更多楼层
      +
      +
      + +
      {{reply_bottom.lasted_comment}}
      +
      +
      +
      +
      +
      + +
      - +
      +
      更多
      +
      @@ -61,4 +81,20 @@
      - \ No newline at end of file + + + \ No newline at end of file diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 3c2ef5d3e..97a8c3f77 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -23,15 +23,15 @@
      {{discussion.praise_count}}
      - 回复 - {{discussion.replies_count}} + 回复 + {{discussion.comment_count}}
      -
      -
      +
      +
      {{journal.lasted_comment}}
      + +
      +
        +
        点击展开更多楼层
        +
        +
        + +
        {{reply_bottom.lasted_comment}}
        +
        +
        +
        +
        +
        +
        +
        +
        更多
        +
        @@ -59,4 +80,20 @@
        - \ No newline at end of file + + + \ No newline at end of file diff --git a/public/assets/wechat/templates/comment_reply.html b/public/assets/wechat/templates/comment_reply.html new file mode 100644 index 000000000..6aeb3a4bd --- /dev/null +++ b/public/assets/wechat/templates/comment_reply.html @@ -0,0 +1,13 @@ +
        + +
        + +
        {{journal.parents_reply_top[i].lasted_comment}}
        +
        +
        +
        +
        diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index 40902fa12..5fb61151d 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -20,15 +20,15 @@ app.controller('BlogController', $scope.page = 0; } else{ - $scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children); + $scope.blog.all_children = $scope.blog.all_children.concat(data.data.all_children); } - $scope.has_more = $scope.blog.blog_comment_children.length < $scope.blog.comment_count; + $scope.has_more = $scope.blog.all_children.length < $scope.blog.comment_count; 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]; + for (var i in $scope.blog.all_children) { + var comment = $scope.blog.all_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); diff --git a/public/javascripts/wechat/controllers/discussion.js b/public/javascripts/wechat/controllers/discussion.js index 7e0811a0d..60bfb3ee3 100644 --- a/public/javascripts/wechat/controllers/discussion.js +++ b/public/javascripts/wechat/controllers/discussion.js @@ -6,7 +6,33 @@ app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth type: 'messages', replyType: 'Message', loadCallback: function(data){ - $scope.discussion = data.data; + console.log(data.data); + + //回复级别 0 一级回复 1 二级回复 + replytype = data.type; + page = data.page; + + if (replytype == 0){ + if (page == 0){ + $scope.discussion = data.data; + $scope.page = 0; + } + else{ + $scope.discussion.all_children = $scope.discussion.all_children.concat(data.data.all_children); + } + $scope.has_more = $scope.discussion.all_children.length < $scope.discussion.comment_count; + console.log($scope.has_more); + } + else{ + comment_id = data.data.id; + for (var i in $scope.discussion.all_children) { + var comment = $scope.discussion.all_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/controllers/homework.js b/public/javascripts/wechat/controllers/homework.js index 58f70db5a..2898fc27f 100644 --- a/public/javascripts/wechat/controllers/homework.js +++ b/public/javascripts/wechat/controllers/homework.js @@ -6,8 +6,33 @@ app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', type: 'whomeworks', replyType: 'HomeworkCommon', loadCallback: function(data){ - console.log(data); - $scope.homework = data.data; + console.log(data.data); + + //回复级别 0 一级回复 1 二级回复 + replytype = data.type; + page = data.page; + + if (replytype == 0){ + if (page == 0){ + $scope.homework = data.data; + $scope.page = 0; + } + else{ + $scope.homework.all_children = $scope.homework.all_children.concat(data.data.all_children); + } + $scope.has_more = $scope.homework.all_children.length < $scope.homework.comment_count; + console.log($scope.has_more); + } + else{ + comment_id = data.data.id; + for (var i in $scope.homework.all_children) { + var comment = $scope.homework.all_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/controllers/journals.js b/public/javascripts/wechat/controllers/journals.js index 76b4f8cf6..23f3b908b 100644 --- a/public/javascripts/wechat/controllers/journals.js +++ b/public/javascripts/wechat/controllers/journals.js @@ -5,7 +5,34 @@ app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', type: 'journal_for_messages', replyType: 'JournalsForMessage', loadCallback: function(data){ - $scope.message = data.data; + console.log(data.data); + + //回复级别 0 一级回复 1 二级回复 + replytype = data.type; + page = data.page; + + if (replytype == 0){ + if (page == 0){ + $scope.message = data.data; + $scope.page = 0; + } + else{ + $scope.message.all_children = $scope.message.all_children.concat(data.data.all_children); + } + $scope.has_more = $scope.message.all_children.length < $scope.message.comment_count; + console.log($scope.has_more); + } + else{ + comment_id = data.data.id; + for (var i in $scope.message.all_children) { + var comment = $scope.message.all_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/directives/comment_reply.js b/public/javascripts/wechat/directives/comment_reply.js new file mode 100644 index 000000000..05b8b55b6 --- /dev/null +++ b/public/javascripts/wechat/directives/comment_reply.js @@ -0,0 +1,9 @@ +app.directive('commentReply', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/comment_reply.html', + scope: { + i: "=", + journal: "=" + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index a329c2906..c9bdf4458 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -89,7 +89,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, auth, $routeParams,rms){ +app.factory('common', ['$http', 'auth', '$routeParams','rms','config', function($http, auth, $routeParams,rms,config){ var addCommonReply = function(id, type, data, cb){ if(!data.comment || data.comment.length<=0){ @@ -117,6 +117,33 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au if(typeof cb === 'function'){ cb(); } + + //保证内外回复数一致 + activities = rms.get("activities") || []; + course_activities = rms.get("course_activities") || []; + project_activities = rms.get("project_activities") || []; + for(var i in activities){ + if(activities[i].act_id == id){ + activities[i].reply_count += 1; + break; + } + } + for(var i in course_activities){ + if(course_activities[i].act_id == id){ + course_activities[i].reply_count += 1; + break; + } + } + for(var i in project_activities){ + if(project_activities[i].act_id == id){ + project_activities[i].reply_count += 1; + break; + } + } + rms.save("activities",activities); + rms.save("course_activities",course_activities); + rms.save("project_activities",project_activities); + }, function errorCallback(response) { }); }; @@ -268,6 +295,8 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au }); }; + args.scope.commentreply_path = config.rootPath+ 'templates/comment_reply.html'; + } return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; From 37a6adf4283984bff3c25b040d024b0f8353452e Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 22 Jul 2016 16:42:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=9F=E4=B8=80=E5=86=99=E5=88=B0comment?= =?UTF-8?q?=5Freply=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 20 ++----------- public/assets/wechat/course_discussion.html | 30 ++++++++++++++++--- public/assets/wechat/homework_detail.html | 22 ++------------ public/assets/wechat/jour_message_detail.html | 20 ++----------- public/assets/wechat/project_discussion.html | 20 ++----------- .../wechat/templates/comment_reply.html | 21 ++++++++++++- 6 files changed, 55 insertions(+), 78 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 075c752ef..721c3d38e 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -44,7 +44,7 @@
        - +
        点击展开更多楼层
        @@ -86,20 +86,4 @@
        - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 7d358fb25..f04d78926 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -23,14 +23,14 @@
        {{discussion.praise_count}}
        - 回复 - {{discussion.replies_count}} + 回复 + {{discussion.comment_count}}
        -
        -
        +
        +
        {{journal.lasted_comment}}
        + +
        + + +
        点击展开更多楼层
        +
        +
        + +
        {{reply_bottom.lasted_comment}}
        +
        +
        +
        +
        +
        +
        +
        +
        更多
        +
        diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 67d7dd959..788d0c1b2 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -46,8 +46,8 @@
        -
          - + +
          点击展开更多楼层
          @@ -86,20 +86,4 @@
          -
          - - \ No newline at end of file +
          \ No newline at end of file diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 288a78688..aeea03dad 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -42,7 +42,7 @@
          - +
          点击展开更多楼层
          @@ -81,20 +81,4 @@
          - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 97a8c3f77..1603afa8c 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -43,7 +43,7 @@
          - +
          点击展开更多楼层
          @@ -80,20 +80,4 @@
          - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/wechat/templates/comment_reply.html b/public/assets/wechat/templates/comment_reply.html index 6aeb3a4bd..ffa656aab 100644 --- a/public/assets/wechat/templates/comment_reply.html +++ b/public/assets/wechat/templates/comment_reply.html @@ -1,4 +1,6 @@ -
          +
          + +
          + + +