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){