2016-06-14 14:24:39 +08:00
|
|
|
|
2016-06-14 16:03:10 +08:00
|
|
|
app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
|
2016-06-20 14:39:20 +08:00
|
|
|
common.init({
|
|
|
|
id: $routeParams.id,
|
|
|
|
scope: $scope,
|
|
|
|
type: 'whomeworks',
|
|
|
|
replyType: 'HomeworkCommon',
|
2016-08-09 17:01:06 +08:00
|
|
|
urlName: 'homework',
|
2016-06-20 14:39:20 +08:00
|
|
|
loadCallback: function(data){
|
2016-07-22 15:37:25 +08:00
|
|
|
console.log(data.data);
|
|
|
|
|
|
|
|
//回复级别 0 一级回复 1 二级回复
|
|
|
|
replytype = data.type;
|
|
|
|
page = data.page;
|
|
|
|
|
2016-08-04 10:00:55 +08:00
|
|
|
if (replytype == 0){
|
2016-07-22 15:37:25 +08:00
|
|
|
if (page == 0){
|
|
|
|
$scope.homework = data.data;
|
|
|
|
$scope.page = 0;
|
2016-08-11 14:09:41 +08:00
|
|
|
$scope.is_public = data.is_public;
|
2016-07-22 15:37:25 +08:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-20 14:39:20 +08:00
|
|
|
},
|
|
|
|
replyCallback: function(){
|
2016-06-14 14:24:39 +08:00
|
|
|
}
|
2016-06-20 14:39:20 +08:00
|
|
|
});
|
2016-06-14 14:24:39 +08:00
|
|
|
|
2016-06-14 16:03:10 +08:00
|
|
|
}]);
|