From 8e1473a484b3ebc4126fcdded70d148298b1d7ae Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 09:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=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){