-
+
{{message.created_on}}
@@ -22,7 +22,7 @@
{{journal.user.realname}}
-
+
{{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'
});