点赞的js
This commit is contained in:
parent
5987659145
commit
2fe32fda61
|
@ -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?
|
||||
|
|
|
@ -118,8 +118,8 @@
|
|||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2"><a href="javascript:void(0);" ng-href="#/issues/{{act.act_id}}" class="c-grey"> 回复 ({{act.reply_count}})</a></div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="!act.has_praise" ng-click="addPraise(act);">赞 ({{act.activity_praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="act.has_praise" ng-click="decreasePraise(act);">已赞 ({{act.activity_praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="!act.has_praise" ng-click="addPraise(act.act_id,act.act_type);">赞 ({{act.activity_praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="act.has_praise" ng-click="decreasePraise(act.act_id,act.act_type);">已赞 ({{act.activity_praise_count}})</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue