From 1967b89ff05e79d9d4a845a9cde1af1ec7d7122b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 6 Jan 2017 17:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=9A=84@=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=9C=A8=E7=8F=AD=E7=BA=A7=E5=92=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=89=80=E6=9C=89=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=9A=84=E5=9B=9E=E5=A4=8D=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E3=80=82issue:=2011026?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 48 +++++++------ public/assets/wechat/course_discussion.html | 46 ++++++------ public/assets/wechat/homework_detail.html | 63 ++++++++-------- public/assets/wechat/issue_detail.html | 71 ++++++++----------- public/assets/wechat/jour_message_detail.html | 45 ++++++------ public/assets/wechat/project_discussion.html | 48 +++++++------ public/assets/wechat/templates/at.html | 11 +++ public/javascripts/wechat/controllers/blog.js | 11 +-- .../wechat/controllers/discussion.js | 16 +++-- .../wechat/controllers/homework.js | 11 +-- .../javascripts/wechat/controllers/issue.js | 66 ++--------------- .../wechat/controllers/journals.js | 11 +-- .../wechat/directives/at_directive.js | 5 ++ public/javascripts/wechat/others/factory.js | 62 +++++++++++++++- 14 files changed, 270 insertions(+), 244 deletions(-) create mode 100644 public/assets/wechat/templates/at.html create mode 100644 public/javascripts/wechat/directives/at_directive.js diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 91a5fff59..f036beb11 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -9,40 +9,40 @@ -
+
-
+
-
{{blog.title}}
-
博客{{blog.created_at}}
+
{{object.title}}
+
博客{{object.created_at}}
-
+
-
-
{{blog.praise_count}}
-
{{blog.praise_count}}
+
+
{{object.praise_count}}
+
{{object.praise_count}}
-
-
+
+
-
+
回复
- +
@@ -88,17 +88,17 @@
-
更多
+
更多
-
+
- - - + + +
@@ -106,4 +106,6 @@
-
\ No newline at end of file +
+ +
\ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 7a818bb79..92fc0d5df 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -9,39 +9,39 @@
-
+
私有内容,请谨慎传播
-
+
-
{{discussion.subject}}
-
{{discussion.syllabus_title}}·{{discussion.course_project_name}} - 班级讨论区{{discussion.created_on}}
-
+
{{object.subject}}
+
{{object.syllabus_title}}·{{object.course_project_name}} - 班级讨论区{{object.created_on}}
+
-
-
{{discussion.praise_count}}
-
{{discussion.praise_count}}
+
+
{{object.praise_count}}
+
{{object.praise_count}}
-
-
+
+
-
+
- +
@@ -85,17 +85,17 @@
-
更多
+
更多
-
+
- - - + + +
@@ -103,3 +103,5 @@
+ +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index e8e56126d..d3ed103ca 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -9,48 +9,48 @@
-
+
私有内容,请谨慎传播
-
+
-
{{homework.name}}
-
{{homework.syllabus_title}}·{{homework.course_name}} - 普通作业编程作业分组作业{{homework.publish_time}}
-
- 迟交扣分:{{homework.late_penalty}}分 - 匿评开启时间:{{homework.evaluation_start}}
- 缺评扣分:{{homework.absence_penalty}}分/作品 - 匿评关闭时间:{{homework.evaluation_end}} +
{{object.name}}
+
{{object.syllabus_title}}·{{object.course_name}} - 普通作业编程作业分组作业{{object.publish_time}}
+
+ 迟交扣分:{{object.late_penalty}}分 + 匿评开启时间:{{object.evaluation_start}}
+ 缺评扣分:{{object.absence_penalty}}分/作品 + 匿评关闭时间:{{object.evaluation_end}}
-
作品提交数:{{homework.homework_commit_count}}
+
作品提交数:{{object.homework_commit_count}}
-
#{{homework.last_commit_info.lasttime}} {{homework.last_commit_info.lastname}} 提交了作品
-
#{{homework.last_score_info.lasttime}} {{homework.last_score_info.lastname}} 评阅了作品
+
#{{object.last_commit_info.lasttime}} {{object.last_commit_info.lastname}} 提交了作品
+
#{{object.last_score_info.lasttime}} {{object.last_score_info.lastname}} 评阅了作品
-
-
{{homework.praise_count}}
-
{{homework.praise_count}}
+
+
{{object.praise_count}}
+
{{object.praise_count}}
-
-
+
+
-
+
- +
@@ -94,17 +94,18 @@
-
更多
+
更多
-
+
- - - + + + +
@@ -112,4 +113,6 @@
-
\ No newline at end of file +
+ +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 9b378c72c..b2df7077f 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -9,28 +9,28 @@
-
+
私有内容,请谨慎传播
-
+
-
{{issue.subject}}
-
{{issue.project_name}} - 项目问题{{issue.created_on}}
+
{{object.subject}}
+
{{object.project_name}} - 项目问题{{object.created_on}}
-
+
@@ -39,19 +39,19 @@
- 状   态:{{issue.issue_status}} - 优先级:{{issue.issue_priority}}
- 指派给:{{issue.issue_assigned_to}} - 完成度:{{issue.done_ratio}}% + 状   态:{{object.issue_status}} + 优先级:{{object.issue_priority}}
+ 指派给:{{object.issue_assigned_to}} + 完成度:{{object.done_ratio}}%
-
-
{{issue.praise_count}}
-
{{issue.praise_count}}
+
+
{{object.praise_count}}
+
{{object.praise_count}}
@@ -73,8 +73,8 @@
-
-
+
+
-
+
- +
@@ -118,17 +118,17 @@
-
更多
+
更多
-
+
- - - + + +
@@ -138,19 +138,6 @@
+
+ -
-
-
-
- -
-
    -
  • {{person.name}}

    ({{person.login}})

  • -
  • {{person.name}}

    ({{person.login}})

  • -
  • {{person.name}}

    ({{person.login}})

  • -
  • {{person.name}}

    ({{person.login}})

  • -
  • {{person.name}}

    ({{person.login}})

  • -
-
-
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 736ad419b..f9be57f29 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -8,40 +8,40 @@
-
+
私有内容,请谨慎传播
-
+
-
留言{{message.created_on}}
+
留言{{object.created_on}}
-
+
-
-
{{message.praise_count}}
-
{{message.praise_count}}
+
+
{{object.praise_count}}
+
{{object.praise_count}}
-
-
+
+
-
+
- +
@@ -84,17 +84,17 @@
-
更多
+
更多
-
+
- - - + + +
@@ -102,4 +102,5 @@
-
\ No newline at end of file +
+
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 7fca33657..4812f750d 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -9,40 +9,40 @@
-
+
私有内容,请谨慎传播
-
+
-
{{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}}
-
-
+
+
-
+
- +
@@ -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}; }]);