diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index 3ba6e5eb7..e5577eeb3 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -21,7 +21,7 @@ module Mobile praise_or_cancel(obj_type,obj_id,user,1) num = get_activity_praise_num(obj) else - pts.delete if !pts.nil? + pts.delete if !pts.empty? #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first ptc.praise_minus(1) if !ptc.nil? diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index c99c9ee09..716385537 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -118,8 +118,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 0a7e80d16..1e0e0f737 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -93,9 +93,9 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.loadActData = loadActData; - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act,'activities'); + $scope.addPraise = function(id, type){ + console.log(type); + common.addCommonPraise(id, type); } $scope.decreasePraise = function(act){ @@ -139,14 +139,14 @@ app.factory('common', function($http, auth, $routeParams){ }) }; - var addCommonPraise = function(act, type){ + var addCommonPraise = function(id, type){ act.activity_praise_count += 1; act.has_praise = true; $http({ method: 'POST', - url: apiUrl, - data:{openid:auth.openid(),type:type,id:$routeParams.id} + url: apiUrl + "praise/" +id, + data:{openid:auth.openid(),type:type} }).then(function successCallback(response) { console.log("点赞成功"); }, function errorCallback(response) { @@ -154,14 +154,14 @@ app.factory('common', function($http, auth, $routeParams){ }; - var decreaseCommonPraise = function(act, type){ + var decreaseCommonPraise = function(id, type){ act.activity_praise_count -= 1; act.has_praise = false; $http({ method: 'POST', - url: apiUrl , - data:{openid:auth.openid(),type:type,id:$routeParams.id} + url: apiUrl + "praise/" +id, + data:{openid:auth.openid(),type:type} }).then(function successCallback(response) { console.log("取消赞成功"); }, function errorCallback(response) {