微信动态详情回复显示修改

This commit is contained in:
yuanke 2016-07-20 13:34:58 +08:00
parent bf600e8f76
commit 67e87df4d5
9 changed files with 90 additions and 29 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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(){

View File

@ -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};