私有内容,请谨慎传播
-
+
- {{discussion.user.real_name}}
-
-
+ {{object.user.real_name}}
+
+
-
{{discussion.subject}}
-
{{discussion.course_project_name}} - 项目讨论区 {{discussion.created_on}}
+
{{object.subject}}
+
{{object.course_project_name}} - 项目讨论区 {{object.created_on}}
-
+
-
赞
-
{{discussion.praise_count}}
-
{{discussion.praise_count}}
+
赞
+
{{object.praise_count}}
+
{{object.praise_count}}
-
-
+
+
@@ -71,13 +71,13 @@
{{journal.praise_count}}
{{journal.praise_count}}
-
+
-
+
提交
提交
@@ -85,20 +85,22 @@
-
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/public/assets/wechat/templates/at.html b/public/assets/wechat/templates/at.html
new file mode 100644
index 000000000..5d26b73a6
--- /dev/null
+++ b/public/assets/wechat/templates/at.html
@@ -0,0 +1,11 @@
+
+
+
+
选择您要@的人
+ 取消
+
+
+ {{person.name}}
({{person.login}})
+
+
+
diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js
index d14156b1a..6bfbfd70b 100644
--- a/public/javascripts/wechat/controllers/blog.js
+++ b/public/javascripts/wechat/controllers/blog.js
@@ -5,6 +5,7 @@ app.controller('BlogController',
common.init({
id: $routeParams.id,
scope: $scope,
+ at_enabled: true,
type: 'blog_comments',
replyType: 'BlogComment',
urlName: 'blog_comment',
@@ -22,19 +23,19 @@ app.controller('BlogController',
if (replytype == 0){
if (page == 0){
- $scope.blog = data.data;
+ $scope.object = data.data;
$scope.page = 0;
}
else{
- $scope.blog.all_children = $scope.blog.all_children.concat(data.data.all_children);
+ $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
}
- $scope.has_more = $scope.blog.all_children.length < $scope.blog.comment_count;
+ $scope.has_more = $scope.object.all_children.length < $scope.object.comment_count;
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
- for (var i in $scope.blog.all_children) {
- var comment = $scope.blog.all_children[i];
+ for (var i in $scope.object.all_children) {
+ var comment = $scope.object.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);
diff --git a/public/javascripts/wechat/controllers/discussion.js b/public/javascripts/wechat/controllers/discussion.js
index 5f6c098e7..bdc7a21e9 100644
--- a/public/javascripts/wechat/controllers/discussion.js
+++ b/public/javascripts/wechat/controllers/discussion.js
@@ -1,8 +1,11 @@
app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){
+ var vm = $scope;
+
common.init({
id: $routeParams.id,
scope: $scope,
+ at_enabled: true,
type: 'messages',
replyType: 'Message',
urlName: 'discussion',
@@ -20,20 +23,20 @@ app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth
if (replytype == 0){
if (page == 0){
- $scope.discussion = data.data;
+ $scope.object = data.data;
$scope.page = 0;
$scope.is_public = data.is_public;
}
else{
- $scope.discussion.all_children = $scope.discussion.all_children.concat(data.data.all_children);
+ $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
}
- $scope.has_more = $scope.discussion.all_children.length < $scope.discussion.comment_count;
+ $scope.has_more = $scope.object.all_children.length < $scope.object.comment_count;
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
- for (var i in $scope.discussion.all_children) {
- var comment = $scope.discussion.all_children[i];
+ for (var i in $scope.object.all_children) {
+ var comment = $scope.object.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);
@@ -42,6 +45,9 @@ app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth
}
},
replyCallback: function(){
+ },
+ beforeReplay: function(data){
+ return vm.parseAtPersons(data);
}
});
}]);
\ No newline at end of file
diff --git a/public/javascripts/wechat/controllers/homework.js b/public/javascripts/wechat/controllers/homework.js
index 381d04810..faaab3be8 100644
--- a/public/javascripts/wechat/controllers/homework.js
+++ b/public/javascripts/wechat/controllers/homework.js
@@ -3,6 +3,7 @@ app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth',
common.init({
id: $routeParams.id,
scope: $scope,
+ at_enabled: true,
type: 'whomeworks',
replyType: 'HomeworkCommon',
urlName: 'homework',
@@ -20,20 +21,20 @@ app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth',
if (replytype == 0){
if (page == 0){
- $scope.homework = data.data;
+ $scope.object = data.data;
$scope.page = 0;
$scope.is_public = data.is_public;
}
else{
- $scope.homework.all_children = $scope.homework.all_children.concat(data.data.all_children);
+ $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
}
- $scope.has_more = $scope.homework.all_children.length < $scope.homework.comment_count;
+ $scope.has_more = $scope.object.all_children.length < $scope.object.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];
+ for (var i in $scope.object.all_children) {
+ var comment = $scope.object.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);
diff --git a/public/javascripts/wechat/controllers/issue.js b/public/javascripts/wechat/controllers/issue.js
index 917de2990..f95eaa5d4 100644
--- a/public/javascripts/wechat/controllers/issue.js
+++ b/public/javascripts/wechat/controllers/issue.js
@@ -3,60 +3,11 @@ app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'c
var vm = $scope;
vm.previewImgUrls = [];
- vm.showAtDialog = false;
-
- var parseAtPersons = function (comment) {
- var selectedPersons = [];
- var ss = comment.match(/@(.+?)\s+/g);
-
- for(var i in ss){
- var personName = ss[i].substr(1, ss[i].length-2);
- console.log(personName);
-
- for(var j in vm.at_persons){
- var person = vm.at_persons[j];
- if(person.name == personName){
- selectedPersons.push(person);
- }
- }
- }
-
- for(var i in selectedPersons){
- var person = selectedPersons[i];
- comment = comment.replace('@'+person.name+' ',
- '
@'+person.name+'('+person.login+')'+' '
- );
- }
- return comment;
- };
-
- vm.onPostChange = function (newValue, oldValue) {
- if(newValue.length > oldValue.length && newValue.match(/@$/)=='@'){
- console.log('@ fire');
- vm.showAtDialog = true;
- if(!vm.at_persons){
- $http.get('/at/'+$routeParams.id+'.json?type=Issue').then(function (response) {
- vm.at_persons = response.data;
- });
- }
- }
- console.log(vm.issue.comment);
- };
-
- vm.selectAtPerson = function (index) {
- var person = vm.at_persons[index];
- vm.showAtDialog = false;
- vm.issue.comment += person.name + ' ';
- };
-
- vm.cancelAt = function(){
- vm.showAtDialog = false;
- }
common.init({
id: $routeParams.id,
scope: $scope,
+ at_enabled: true,
type: 'issues',
replyType: 'Issue',
urlName: 'issues',
@@ -90,21 +41,21 @@ app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'c
if (replytype == 0){
if (page == 0){
- $scope.issue = data.data;
+ $scope.object = data.data;
$scope.page = 0;
$scope.is_public = data.is_public;
- $scope.previewImgUrls = parseImgAttachment($scope.issue.attachments);
+ $scope.previewImgUrls = parseImgAttachment($scope.object.attachments);
}
else{
- $scope.issue.all_children = $scope.issue.all_children.concat(data.data.all_children);
+ $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
}
- $scope.has_more = $scope.issue.all_children.length < $scope.issue.comment_count;
+ $scope.has_more = $scope.object.all_children.length < $scope.object.comment_count;
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
- for (var i in $scope.issue.all_children) {
- var comment = $scope.issue.all_children[i];
+ for (var i in $scope.object.all_children) {
+ var comment = $scope.object.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);
@@ -113,9 +64,6 @@ app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'c
}
},
replyCallback: function(){
- },
- beforeReplay: function(data){
- return parseAtPersons(data);
}
});
diff --git a/public/javascripts/wechat/controllers/journals.js b/public/javascripts/wechat/controllers/journals.js
index a768fe5fb..a890a60de 100644
--- a/public/javascripts/wechat/controllers/journals.js
+++ b/public/javascripts/wechat/controllers/journals.js
@@ -2,6 +2,7 @@ app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth',
common.init({
id: $routeParams.id,
scope: $scope,
+ at_enabled: true,
type: 'journal_for_messages',
replyType: 'JournalsForMessage',
urlName: 'journal_for_message',
@@ -19,20 +20,20 @@ app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth',
if (replytype == 0){
if (page == 0){
- $scope.message = data.data;
+ $scope.object = data.data;
$scope.page = 0;
$scope.is_public = data.is_public;
}
else{
- $scope.message.all_children = $scope.message.all_children.concat(data.data.all_children);
+ $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
}
- $scope.has_more = $scope.message.all_children.length < $scope.message.comment_count;
+ $scope.has_more = $scope.object.all_children.length < $scope.object.comment_count;
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
- for (var i in $scope.message.all_children) {
- var comment = $scope.message.all_children[i];
+ for (var i in $scope.object.all_children) {
+ var comment = $scope.object.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);
diff --git a/public/javascripts/wechat/directives/at_directive.js b/public/javascripts/wechat/directives/at_directive.js
new file mode 100644
index 000000000..9cb094f36
--- /dev/null
+++ b/public/javascripts/wechat/directives/at_directive.js
@@ -0,0 +1,5 @@
+app.directive('atDirective', ['$http', 'config', function ($http, config) {
+ return {
+ templateUrl: config.rootPath+ 'templates/at.html',
+ };
+}]);
diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js
index daf8a45f8..5d4800ac3 100644
--- a/public/javascripts/wechat/others/factory.js
+++ b/public/javascripts/wechat/others/factory.js
@@ -218,7 +218,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
};
var init = function(args){
- args.scope.replytip = "输入回复内容~";
+ args.scope.replytip = "输入回复内容,您可以@别人啦~";
// args.scope.formData = {comment: ''};
var loadData = function(id,replytype,page){
loadCommonData(id, args.type,replytype,page).then(function successCallback(response) {
@@ -301,10 +301,14 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
};
loadData(args.id,0,0);
+
+ if(args.at_enabled === true){
+ enableAt(args.scope, args.replyType);
+ }
+
args.scope.addReply = function(data,reply_type){
console.log(data.comment);
-
- addCommonReply(data.act_id, args.replyType, data,args, reply_type, args.beforeReplay, function(subscribe){
+ addCommonReply(data.act_id, args.replyType, data,args, reply_type, args.at_enabled === true ? args.scope.parseAtPersons : args.beforeReplay, function(subscribe){
// args.scope.formData = {comment: ''};
if(subscribe == 0){
$location.path("/login_tip");
@@ -486,5 +490,57 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
});
};
+
+ var enableAt = function(vm, atType){
+ vm.showAtDialog = false;
+
+ vm.parseAtPersons = function (comment) {
+ var selectedPersons = [];
+ var ss = comment.match(/@(.+?)\s+/g);
+
+ for(var i in ss){
+ var personName = ss[i].substr(1, ss[i].length-2);
+
+ for(var j in vm.at_persons){
+ var person = vm.at_persons[j];
+ if(person.name == personName){
+ selectedPersons.push(person);
+ }
+ }
+ }
+
+ for(var i in selectedPersons){
+ var person = selectedPersons[i];
+ comment = comment.replace('@'+person.name+' ',
+ '
@'+person.name+'('+person.login+')'+' '
+ );
+ }
+ return comment;
+ };
+
+ vm.onPostChange = function (newValue, oldValue) {
+ if(newValue.length > oldValue.length && newValue.match(/@$/)=='@'){
+ console.log('@ fire');
+ vm.showAtDialog = true;
+ if(!vm.at_persons){
+ $http.get('/at/'+$routeParams.id+'.json?type='+atType).then(function (response) {
+ vm.at_persons = response.data;
+ });
+ }
+ }
+ };
+
+ vm.selectAtPerson = function (index) {
+ var person = vm.at_persons[index];
+ vm.showAtDialog = false;
+ vm.object.comment += person.name + ' ';
+ };
+
+ vm.cancelAt = function(){
+ vm.showAtDialog = false;
+ }
+ };
+
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin};
}]);