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 63c9c0833..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}})
@@ -58,19 +60,19 @@
-
+
- +
- 点击展开 + 点击展开 {{act.latest_update}}
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -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 @@
- +
@@ -139,17 +142,9 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
- 点击展开 -
- -
-
-
-
回复 ()
-
赞 ()
@@ -161,7 +156,7 @@
- +
@@ -173,8 +168,8 @@
-
- +
+
@@ -184,7 +179,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -197,7 +192,7 @@
- +
@@ -208,7 +203,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index dd40df5ab..5c1d6bf22 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 diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 33bcf9471..13ae823c3 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..3881d96f1 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -5,7 +5,7 @@
- +
@@ -24,7 +24,7 @@
-
{{comments.comments}}
+
{{comments.created_on}}
回复
@@ -36,7 +36,7 @@
- +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index dcac4d64d..072678ba1 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -5,7 +5,7 @@
- +
@@ -38,7 +38,7 @@
- +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 791db4e49..ea3fd06be 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -5,11 +5,12 @@
- +
-
{{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/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index e0ef85ecd..857498f0a 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -3,7 +3,7 @@
- +
@@ -22,7 +22,7 @@
-
+
{{journal.lasted_comment}}
回复
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 45c84c822..d868e0d03 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 4368adbdf..f288a4b65 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 = "2"; + _openid = "1"; } var getOpenId = function() { @@ -62,12 +62,11 @@ 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; } console.log("ActivityController load"); - $scope.activities = rms.get("activities") || []; $scope.page = 1; @@ -91,20 +90,99 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } ); + $scope.addPraise = function(act){ + act.activity_praise_count += 1; + act.has_praise = true; + + //$http + + } $scope.loadActData = loadActData; + +}); + +app.factory('common', function($http, auth){ + var addCommonReply = function(id, type, data, cb){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: type, + content: data.comment, + openid: auth.openid() + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+id, + data: userInfo + }).then(function successCallback(response) { + alert("提交成功"); + 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('IssueController', function($scope, $http, $routeParams, auth){ +app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ $scope.formData = {comment: ''}; var loadData = function(id){ $http({ method: 'GET', - url: apiUrl+ "issues/"+id, + url: apiUrl+ "whomeworks/"+id, }).then(function successCallback(response) { console.log(response.data); - $scope.issue = response.data.data; + $scope.homework = response.data.data; }, function errorCallback(response) { }); @@ -113,7 +191,7 @@ app.controller('IssueController', 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){ @@ -121,7 +199,7 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ } var userInfo = { - type: "Issue", + type: "HomeworkCommon", content: data.comment, openid: auth.openid(), }; @@ -139,25 +217,69 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ } }); -app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ +app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){ $scope.formData = {comment: ''}; var loadData = function(id){ $http({ method: 'GET', - url: apiUrl+ "whomeworks/"+id, + url: apiUrl+ "newss/"+id, }).then(function successCallback(response) { console.log(response.data); - $scope.homework = response.data.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("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); } +}); + +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){ + $scope.addDiscussionReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -165,7 +287,7 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth) } var userInfo = { - type: "HomeworkCommon", + type: "Message", content: data.comment, openid: auth.openid(), }; @@ -183,25 +305,67 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth) } }); -app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){ +app.controller('JournalsController', function($scope, $http, $routeParams, auth){ $scope.formData = {comment: ''}; var loadData = function(id){ $http({ method: 'GET', - url: apiUrl+ "newss/"+id, + url: apiUrl+ "journal_for_messages/"+id, }).then(function successCallback(response) { console.log(response.data); - $scope.news = response.data.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.addIssueReply = function(data){ + $scope.addBlogReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -209,7 +373,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a } var userInfo = { - type: "News", + type: "BlogComment", content: data.comment, openid: auth.openid(), }; @@ -243,6 +407,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' @@ -251,6 +419,18 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'course_notice.html', controller: 'CourseNoticeController' }) + .when('/course_discussion/:id', { + templateUrl: 'course_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' });