From a1a9dbd8a30a951eb39a7a12a11da1566cc490e0 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 15:34:54 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 +- public/assets/wechat/course_discussion.html | 32 ++++--- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/project_discussion.html | 87 +++++--------------- public/javascripts/wechat/app.js | 56 ++++++++++++- 5 files changed, 93 insertions(+), 88 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 63c9c0833..895b77999 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -70,7 +70,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -148,7 +148,7 @@
-
回复 ()
+
回复 ()
赞 ()
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 33bcf9471..9f98299ee 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -3,42 +3,40 @@
-
- - +
+ +
-
+
- + {{discussion.created_on}}
-
回复 ()
-
(())
+
回复 ({{discussion.replies_count}})
+
({{discussion.message_praise_count}})
- = 0; --j){ !> -
+
-
+
- -
-
+ +
+
{{journal.lasted_comment}}
回复
-
- - - + + +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 2e8caf15a..b8e468701 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -24,7 +24,7 @@
-
{{comments.comments}}
+
{{comments.created_on}}
回复
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 45c84c822..be9ee8328 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -1,89 +1,44 @@ - - - - 项目讨论区 - - - - - - - - - - -
- - - - - - - - - - - - - - - \ No newline at end of file +
\ No newline at end of file diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index b465dfcf6..05fc16c0a 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -6,7 +6,7 @@ app.factory('auth', function($http,$routeParams, $cookies){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function(cb) { @@ -177,7 +177,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -208,6 +208,50 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a } }); +app.controller('CourseDiscussionController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "messages/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.discussion = response.data.data; + + }, function errorCallback(response) { + }); + }; + + loadData($routeParams.id); + + + $scope.addIssueReply = 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("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + app.filter('safeHtml', function ($sce) { return function (input) { return $sce.trustAsHtml(input); @@ -232,6 +276,14 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'course_notice.html', controller: 'CourseNoticeController' }) + .when('/course_discussion/:id', { + templateUrl: 'course_discussion.html', + controller: 'CourseDiscussionController' + }) + .when('/project_discussion/:id', { + templateUrl: 'project_discussion.html', + controller: 'CourseDiscussionController' + }) .otherwise({ redirectTo: '/activities' }); From 2ede6e2b9d1663ceafe163e322789b129373fe7e Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 15:43:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 91 +++++++++------------------ 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index dd40df5ab..d9c4f5835 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -1,73 +1,44 @@ - - - - 博客 - - - - - - - - - - -
- - - - - - - - - - - - \ No newline at end of file +
\ No newline at end of file From 20bb8c1e09d4b1c50d3713e25c8b919f4e316662 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 16:23:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=95=99=E8=A8=80=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 +- public/assets/wechat/jour_message_detail.html | 2 +- public/javascripts/wechat/app.js | 96 ++++++++++++++++++- 3 files changed, 98 insertions(+), 4 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 895b77999..1ffc10941 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -184,7 +184,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -208,7 +208,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index e0ef85ecd..867616441 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -22,7 +22,7 @@
-
+
{{journal.lasted_comment}}
回复
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c69b119c1..04c0cb7af 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -271,6 +271,92 @@ app.controller('CourseDiscussionController', function($scope, $http, $routeParam } }); +app.controller('JournalsController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "journal_for_messages/"+id, + }).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("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + +app.controller('BlogController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "blog_comments/"+id, + }).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("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + app.filter('safeHtml', function ($sce) { return function (input) { return $sce.trustAsHtml(input); @@ -303,6 +389,14 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'project_discussion.html', controller: 'CourseDiscussionController' }) + .when('/journal_for_message/:id', { + templateUrl: 'jour_message_detail.html', + controller: 'JournalsController' + }) + .when('/blog_comment/:id', { + templateUrl: 'blog_detail.html', + controller: 'BlogController' + }) .otherwise({ redirectTo: '/activities' }); From 422621759e16789a135c72c2157699f9341ecca9 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 16:24:35 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E8=AF=A6=E6=83=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index be9ee8328..91aa983d2 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c69b119c1..f7c076852 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { From ec47fb1949c22ff41f18b36aae81becb7ca325e8 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 19:29:00 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 14 ++------ public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 5 +-- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 34 +++++++++++++++----- 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 1ffc10941..b22131604 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -58,7 +58,7 @@
-
+
@@ -139,17 +139,9 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
- 点击展开 -
- -
-
-
-
回复 ()
-
赞 ()
@@ -173,7 +165,7 @@
-
+
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 9f98299ee..980474dd7 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -36,7 +36,7 @@
- +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index b8e468701..4ad38b3da 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -36,7 +36,7 @@
- +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index dcac4d64d..7ae41b418 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -38,7 +38,7 @@
- +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 791db4e49..5b6590aa9 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -8,8 +8,9 @@
-
{{issue.description}}
- 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}%
+
+ 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
+ 指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}%
{{issue.created_on}} diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 91aa983d2..e8cfba46a 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -36,7 +36,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 7fb1fc6df..23b4c9943 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -62,7 +62,7 @@ app.factory('rms', function(){ }); app.controller('ActivityController',function($scope, $http, auth, rms){ - $scope.repaceUrl = function(url){ + $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; } @@ -93,6 +93,24 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ $scope.loadActData = loadActData; + + var descToggle = function(){ + $(".post-all-content").each(function(){ + var postHeight = $(this).height(); + if (postHeight > 90){ + $(this).parent().next().css("display","block"); + $(this).parent().next().toggle(function(){ + $(this).text("点击隐藏"); + $(this).prev().css("height",postHeight); + },function(){ + $(this).text("点击展开"); + $(this).prev().css("height",90); + }); + } + }); + } + + $scope.descToggle = descToggle; }); app.controller('IssueController', function($scope, $http, $routeParams, auth){ @@ -157,7 +175,7 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth) loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addHomeworkReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -201,7 +219,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addNoticeReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -245,7 +263,7 @@ app.controller('CourseDiscussionController', function($scope, $http, $routeParam loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addDiscussionReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -373,6 +391,10 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'issue_detail.html', controller: 'IssueController' }) + .when('/project_discussion/:id', { + templateUrl: 'project_discussion.html', + controller: 'CourseDiscussionController' + }) .when('/homework/:id', { templateUrl: 'homework_detail.html', controller: 'HomeworkController' @@ -385,10 +407,6 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'course_discussion.html', controller: 'CourseDiscussionController' }) - .when('/project_discussion/:id', { - templateUrl: 'project_discussion.html', - controller: 'CourseDiscussionController' - }) .when('/journal_for_message/:id', { templateUrl: 'jour_message_detail.html', controller: 'JournalsController' From 8e1473a484b3ebc4126fcdded70d148298b1d7ae Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 09:26:24 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- app/api/mobile/entities/activity.rb | 4 + public/assets/wechat/activities.html | 27 ++--- public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 2 +- public/assets/wechat/jour_message_detail.html | 2 +- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 102 ++++++++++-------- 11 files changed, 86 insertions(+), 63 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index c7f8509ae..8e4d69738 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -30,7 +30,7 @@ module Mobile all_count = activities.count activities = activities.limit(10).offset(page * 10) count = activities.count - present :data, activities, with: Mobile::Entities::Activity + present :data, activities, with: Mobile::Entities::Activity,user: user present :all_count, all_count present :count, count present :page, page diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 8c6b07281..945601bd6 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -130,6 +130,10 @@ module Mobile act_expose :latest_update #最新更新时间 act_expose :course_project_name #课程/项目名字 act_expose :activity_type_name #课程问答区/项目缺陷等 + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + false + end end end end \ No newline at end of file diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index b22131604..ae8fe8136 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -9,13 +9,14 @@
- +
迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
+ 点击展开 点击展开
{{act.latest_update}} @@ -36,7 +37,7 @@
- +
@@ -48,7 +49,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
一赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
@@ -60,12 +62,12 @@
- +
- 点击展开 + 点击展开 {{act.latest_update}}
@@ -83,7 +85,7 @@
- +
@@ -101,7 +103,7 @@
- +
@@ -115,7 +117,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
一赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
@@ -128,7 +131,7 @@
- +
@@ -153,7 +156,7 @@
- +
@@ -166,7 +169,7 @@
- +
@@ -189,7 +192,7 @@
- +
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index d9c4f5835..5c1d6bf22 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -5,7 +5,7 @@
- +
{{blog.content}}
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 980474dd7..13ae823c3 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 4ad38b3da..3881d96f1 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 7ae41b418..072678ba1 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 5b6590aa9..ea3fd06be 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 867616441..857498f0a 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -3,7 +3,7 @@
- +
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index e8cfba46a..d868e0d03 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 23b4c9943..c8edfaf84 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function() { @@ -67,7 +67,6 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } console.log("ActivityController load"); - $scope.activities = rms.get("activities") || []; $scope.page = 1; @@ -91,47 +90,20 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } ); + $scope.addPraise = function(act){ + act.activity_praise_count += 1; + act.has_praise = true; - $scope.loadActData = loadActData; - - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - $scope.descToggle = descToggle; -}); - -app.controller('IssueController', function($scope, $http, $routeParams, auth){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "issues/"+id, - }).then(function successCallback(response) { - console.log(response.data); - $scope.issue = response.data.data; + //$http - }, function errorCallback(response) { - }); } - loadData($routeParams.id); + $scope.loadActData = loadActData; +}); - $scope.addIssueReply = function(data){ +app.factory('common', function($http, auth){ + var addCommonReply = function(id, type, data, cb){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -139,22 +111,66 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ } var userInfo = { - type: "Issue", + type: type, content: data.comment, - openid: auth.openid(), + openid: auth.openid() }; $http({ method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, + url: apiUrl+ "new_comment/"+id, + data: userInfo }).then(function successCallback(response) { alert("提交成功"); - $scope.formData = {comment: ''}; - loadData($routeParams.id); + if(typeof cb === 'function'){ + cb(); + } + }, function errorCallback(response) { + }); + }; + + + + + var loadCommonData = function(id, type){ + return $http({ + method: 'GET', + url: apiUrl+ type + "/"+id + }) + }; + + return {addCommonReply: addCommonReply, loadCommonData: loadCommonData}; + + +}); + + + +app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + common.loadCommonData(id, 'issues').then(function successCallback(response) { + console.log(response.data); + $scope.issue = response.data.data; }, function errorCallback(response) { }); } + + loadData($routeParams.id); + + $scope.addIssueReply = function(data){ + console.log("add issue reply"); + common.addCommonReply($routeParams.id, 'Issue', data, function(){ + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }); + + }; + + + + }); app.controller('HomeworkController', function($scope, $http, $routeParams, auth){