代码优化
This commit is contained in:
parent
8e1473a484
commit
6d8ffabb39
|
@ -117,7 +117,7 @@
|
|||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-href="#/issues/{{act.act_id}}" class="c-grey"> 回复 ({{act.reply_count}})</a></div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="!act.has_praise" ng-click="addPraise(act);">一赞 ({{act.activity_praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="!act.has_praise" ng-click="addPraise(act);">已赞 ({{act.activity_praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="act.has_praise">赞 ({{act.activity_praise_count}})</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
|
|||
var _openid = '';
|
||||
|
||||
if(debug===true){
|
||||
_openid = "1";
|
||||
_openid = "2";
|
||||
}
|
||||
|
||||
var getOpenId = function() {
|
||||
|
@ -135,7 +135,7 @@ app.factory('common', function($http, auth){
|
|||
var loadCommonData = function(id, type){
|
||||
return $http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ type + "/"+id
|
||||
url: apiUrl+ type + "/" + id
|
||||
})
|
||||
};
|
||||
|
||||
|
@ -155,238 +155,126 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co
|
|||
$scope.issue = response.data.data;
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
$scope.addIssueReply = function(data){
|
||||
console.log("add issue reply");
|
||||
console.log(data.comment);
|
||||
common.addCommonReply($routeParams.id, 'Issue', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.controller('HomeworkController', function($scope, $http, $routeParams, auth){
|
||||
app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){
|
||||
$scope.formData = {comment: ''};
|
||||
|
||||
var loadData = function(id){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ "whomeworks/"+id,
|
||||
}).then(function successCallback(response) {
|
||||
common.loadCommonData(id, 'whomeworks').then(function successCallback(response) {
|
||||
console.log(response.data);
|
||||
$scope.homework = response.data.data;
|
||||
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
|
||||
$scope.addHomeworkReply = function(data){
|
||||
console.log(data.comment);
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
return;
|
||||
}
|
||||
|
||||
var userInfo = {
|
||||
type: "HomeworkCommon",
|
||||
content: data.comment,
|
||||
openid: auth.openid(),
|
||||
};
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "new_comment/"+$routeParams.id,
|
||||
data: userInfo,
|
||||
}).then(function successCallback(response) {
|
||||
alert("提交成功");
|
||||
common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){
|
||||
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){
|
||||
$scope.formData = {comment: ''};
|
||||
|
||||
var loadData = function(id){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ "newss/"+id,
|
||||
}).then(function successCallback(response) {
|
||||
common.loadCommonData(id, 'newss').then(function successCallback(response) {
|
||||
console.log(response.data);
|
||||
$scope.news = response.data.data;
|
||||
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
|
||||
$scope.addNoticeReply = function(data){
|
||||
console.log(data.comment);
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
return;
|
||||
}
|
||||
|
||||
var userInfo = {
|
||||
type: "News",
|
||||
content: data.comment,
|
||||
openid: auth.openid(),
|
||||
};
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "new_comment/"+$routeParams.id,
|
||||
data: userInfo,
|
||||
}).then(function successCallback(response) {
|
||||
alert("提交成功");
|
||||
common.addCommonReply($routeParams.id, 'News', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.controller('CourseDiscussionController', function($scope, $http, $routeParams, auth){
|
||||
app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){
|
||||
$scope.formData = {comment: ''};
|
||||
|
||||
var loadData = function(id){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ "messages/"+id,
|
||||
}).then(function successCallback(response) {
|
||||
common.loadCommonData(id, 'messages').then(function successCallback(response) {
|
||||
console.log(response.data);
|
||||
$scope.discussion = response.data.data;
|
||||
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
|
||||
$scope.addDiscussionReply = function(data){
|
||||
console.log(data.comment);
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
return;
|
||||
}
|
||||
|
||||
var userInfo = {
|
||||
type: "Message",
|
||||
content: data.comment,
|
||||
openid: auth.openid(),
|
||||
};
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "new_comment/"+$routeParams.id,
|
||||
data: userInfo,
|
||||
}).then(function successCallback(response) {
|
||||
alert("提交成功");
|
||||
common.addCommonReply($routeParams.id, 'Message', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.controller('JournalsController', function($scope, $http, $routeParams, auth){
|
||||
app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){
|
||||
$scope.formData = {comment: ''};
|
||||
|
||||
var loadData = function(id){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ "journal_for_messages/"+id,
|
||||
}).then(function successCallback(response) {
|
||||
common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) {
|
||||
console.log(response.data);
|
||||
$scope.message = response.data.data;
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
|
||||
$scope.addJournalReply = function(data){
|
||||
console.log(data.comment);
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
return;
|
||||
}
|
||||
|
||||
var userInfo = {
|
||||
type: "JournalsForMessage",
|
||||
content: data.comment,
|
||||
openid: auth.openid(),
|
||||
};
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "new_comment/"+$routeParams.id,
|
||||
data: userInfo,
|
||||
}).then(function successCallback(response) {
|
||||
alert("提交成功");
|
||||
common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.controller('BlogController', function($scope, $http, $routeParams, auth){
|
||||
app.controller('BlogController', function($scope, $http, $routeParams, auth, common){
|
||||
$scope.formData = {comment: ''};
|
||||
|
||||
var loadData = function(id){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: apiUrl+ "blog_comments/"+id,
|
||||
}).then(function successCallback(response) {
|
||||
common.loadCommonData(id, 'blog_comments').then(function successCallback(response) {
|
||||
console.log(response.data);
|
||||
$scope.blog = response.data.data;
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
loadData($routeParams.id);
|
||||
|
||||
|
||||
$scope.addBlogReply = function(data){
|
||||
console.log(data.comment);
|
||||
|
||||
if(!data.comment || data.comment.length<=0){
|
||||
return;
|
||||
}
|
||||
|
||||
var userInfo = {
|
||||
type: "BlogComment",
|
||||
content: data.comment,
|
||||
openid: auth.openid(),
|
||||
};
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: apiUrl+ "new_comment/"+$routeParams.id,
|
||||
data: userInfo,
|
||||
}).then(function successCallback(response) {
|
||||
alert("提交成功");
|
||||
common.addCommonReply($routeParams.id, 'BlogComment', data, function(){
|
||||
$scope.formData = {comment: ''};
|
||||
loadData($routeParams.id);
|
||||
}, function errorCallback(response) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -409,7 +297,7 @@ app.config(['$routeProvider',function ($routeProvider) {
|
|||
})
|
||||
.when('/project_discussion/:id', {
|
||||
templateUrl: 'project_discussion.html',
|
||||
controller: 'CourseDiscussionController'
|
||||
controller: 'DiscussionController'
|
||||
})
|
||||
.when('/homework/:id', {
|
||||
templateUrl: 'homework_detail.html',
|
||||
|
@ -421,7 +309,7 @@ app.config(['$routeProvider',function ($routeProvider) {
|
|||
})
|
||||
.when('/course_discussion/:id', {
|
||||
templateUrl: 'course_discussion.html',
|
||||
controller: 'CourseDiscussionController'
|
||||
controller: 'DiscussionController'
|
||||
})
|
||||
.when('/journal_for_message/:id', {
|
||||
templateUrl: 'jour_message_detail.html',
|
||||
|
|
Loading…
Reference in New Issue