点赞功能修改

This commit is contained in:
txz 2016-04-07 15:26:23 +08:00
parent 2fe32fda61
commit 938bf48d08
2 changed files with 13 additions and 13 deletions

View File

@ -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_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 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>
</div>
</div>

View File

@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
var _openid = '';
if(debug===true){
_openid = "2";
_openid = "1";
}
var getOpenId = function() {
@ -93,14 +93,14 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){
$scope.loadActData = loadActData;
$scope.addPraise = function(id, type){
console.log(type);
common.addCommonPraise(id, type);
$scope.addPraise = function(act){
console.log(act);
common.addCommonPraise(act);
}
$scope.decreasePraise = function(act){
console.log(act);
common.decreaseCommonPraise(act,'activities');
common.decreaseCommonPraise(act);
}
});
@ -139,14 +139,14 @@ app.factory('common', function($http, auth, $routeParams){
})
};
var addCommonPraise = function(id, type){
var addCommonPraise = function(act){
act.activity_praise_count += 1;
act.has_praise = true;
$http({
method: 'POST',
url: apiUrl + "praise/" +id,
data:{openid:auth.openid(),type:type}
url: apiUrl + "praise/" + act.act_id,
data:{openid:auth.openid(),type:act.act_type}
}).then(function successCallback(response) {
console.log("点赞成功");
}, function errorCallback(response) {
@ -154,14 +154,14 @@ app.factory('common', function($http, auth, $routeParams){
};
var decreaseCommonPraise = function(id, type){
var decreaseCommonPraise = function(act){
act.activity_praise_count -= 1;
act.has_praise = false;
$http({
method: 'POST',
url: apiUrl + "praise/" +id,
data:{openid:auth.openid(),type:type}
url: apiUrl + "praise/" + act.act_id,
data:{openid:auth.openid(),type:act.act_type}
}).then(function successCallback(response) {
console.log("取消赞成功");
}, function errorCallback(response) {