diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 5b970e0ba..39b6a486a 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -6,7 +6,7 @@ module Mobile resources :blog_comments do desc "get special topic" - get ':id' do + post ':id' do user = current_user #0一级回复的更多 1 二级回复的更多 @@ -15,6 +15,8 @@ module Mobile blog = BlogComment.find params[:id] present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 4a6417cb4..36b558652 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -7,11 +7,17 @@ module Mobile include IssuesHelper desc "get special issuse" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 issue = Issue.find params[:id] - present :data, issue, with: Mobile::Entities::Issue,user: user + present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 5f2d01185..6ac484513 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -6,11 +6,18 @@ module Mobile resources :journal_for_messages do desc "get special journal" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 + jour = JournalsForMessage.find params[:id] - present :data, jour, with: Mobile::Entities::Jours,user: user + present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index bab82de8d..ceda5058f 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -6,11 +6,17 @@ module Mobile resources :messages do desc "get special topic" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 message = Message.find params[:id] - present :data, message, with: Mobile::Entities::Message,user: user + present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index d42177783..6e012ca4b 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -6,11 +6,17 @@ module Mobile resources :newss do desc "get special news" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 news = News.find params[:id] - present :data, news, with: Mobile::Entities::News,user: user + present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index c8377aa0d..db1e7e269 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -6,11 +6,17 @@ module Mobile resources :whomeworks do desc "get one homework" - get ':id' do + post ':id' do authenticate! user = current_user + + #0一级回复的更多 1 二级回复的更多 + type = params[:type] || 0 + page = params[:page] || 0 homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework,user: user + present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page + present :type, type + present :page, page present :status, 0 end end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index bdeff7ae9..2856354a1 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -20,17 +20,17 @@ module Mobile ac.act unless ac.nil? || ac.act.nil? end when :reply_count - # if ac.act_type == "HomeworkCommon" - # ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count - # elsif ac.act_type == "News" - # ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count - # elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" - # ac.nil? || ac.act.nil? ? 0 : ac.act.children.count - # elsif ac.act_type == "Issue" - # ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count - # end - all_comments = [] - ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count + if ac.act_type == "HomeworkCommon" + ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count + elsif ac.act_type == "News" + ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count + elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" + all_comments = [] + ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count + elsif ac.act_type == "Issue" + ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count + end + when :subject if ac.act_type == "HomeworkCommon" ac.act.name unless ac.nil? || ac.act.nil? diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js index 48bd2863a..dc9f4bf39 100644 --- a/public/javascripts/wechat/controllers/blog.js +++ b/public/javascripts/wechat/controllers/blog.js @@ -7,17 +7,29 @@ app.controller('BlogController', scope: $scope, type: 'blog_comments', replyType: 'BlogComment', - loadCallback: function(data,replytype,page){ + loadCallback: function(data){ console.log(data.data); + replytype = data.type; + page = data.page; - if (replytype == 0 && page == 0 ) { - $scope.blog = data.data; + if (replytype == 0){ + if (page == 0){ + $scope.blog = data.data; + } + else{ + $scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children); + } + $scope.has_more = $scope.blog.blog_comment_children.length < $scope.blog.comment_count; + console.log($scope.has_more); } else{ + + + } }, replyCallback: function(){ diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index 3e5b4c4f3..dcd78740f 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -121,10 +121,18 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au }); }; - var loadCommonData = function(id, type){ +// var loadCommonData = function(id, type,replytype,page){ +// return $http({ +// method: 'GET', +// url: apiUrl+ type + "/" + id+"?token="+auth.token(), +// }) +// }; + + var loadCommonData = function(id, type,replytype,page){ return $http({ - method: 'GET', - url: apiUrl+ type + "/" + id+"?token="+auth.token() + method: 'POST', + url: apiUrl+ type + "/" + id, + data:{token:auth.token(),type:replytype,page:page} }) }; @@ -160,7 +168,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au args.scope.formData = {comment: ''}; var loadData = function(id,replytype,page){ loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { - args.loadCallback(response.data,replytype,page); + args.loadCallback(response.data); }, function errorCallback(response) { }); }; @@ -245,6 +253,14 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au act.has_praise = false; decreaseCommonPraise(act); }; + + args.scope.morereply = function(data,replytype,page){ + loadCommonData(data.id, args.type,replytype,page).then(function successCallback(response) { + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + } return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};