socialforge/public/javascripts/wechat/controllers/blog.js

42 lines
1.7 KiB
JavaScript
Raw Normal View History

app.controller('BlogController',
['$scope', '$http', '$routeParams', 'auth', 'common',
function($scope, $http, $routeParams, auth, common){
2016-06-14 14:24:39 +08:00
common.init({
id: $routeParams.id,
scope: $scope,
type: 'blog_comments',
replyType: 'BlogComment',
2016-07-20 13:34:58 +08:00
loadCallback: function(data){
2016-07-20 10:09:27 +08:00
console.log(data.data);
//回复级别 0 一级回复 1 二级回复
2016-07-20 13:34:58 +08:00
replytype = data.type;
page = data.page;
2016-07-20 10:09:27 +08:00
2016-07-20 13:34:58 +08:00
if (replytype == 0){
if (page == 0){
$scope.blog = data.data;
$scope.page = 0;
2016-07-20 13:34:58 +08:00
}
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);
2016-07-20 10:09:27 +08:00
}
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);
}
}
2016-07-20 10:09:27 +08:00
}
},
replyCallback: function(){
}
2016-06-14 14:24:39 +08:00
});
}]);