2016-06-14 14:24:39 +08:00
|
|
|
|
2016-06-14 16:03:10 +08:00
|
|
|
app.controller('ActivityController',
|
2016-06-20 14:39:20 +08:00
|
|
|
['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common','alertService',
|
|
|
|
function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common, alertService){
|
2016-06-14 14:24:39 +08:00
|
|
|
$scope.replaceUrl = function(url){
|
|
|
|
return url;
|
|
|
|
};
|
|
|
|
|
2016-06-20 14:39:20 +08:00
|
|
|
$scope.alertService = alertService.create();
|
2016-06-14 14:24:39 +08:00
|
|
|
console.log("ActivityController load");
|
|
|
|
|
|
|
|
$scope.page = rms.get('page') || 0;
|
|
|
|
$scope.activities = rms.get("activities") || [];
|
|
|
|
$scope.has_more = rms.get("has_more");
|
|
|
|
|
|
|
|
$scope.loadActData = function(page){
|
|
|
|
|
|
|
|
$scope.page = page;
|
|
|
|
$http({
|
|
|
|
method: 'POST',
|
|
|
|
url: apiUrl+ "activities",
|
2016-06-20 14:39:20 +08:00
|
|
|
data: {token: auth.token(), page: page}
|
2016-06-14 14:24:39 +08:00
|
|
|
}).then(function successCallback(response) {
|
|
|
|
if(response.data.page >0) {
|
|
|
|
$scope.activities = $scope.activities.concat(response.data.data);
|
|
|
|
} else {
|
|
|
|
$scope.activities = response.data.data;
|
|
|
|
}
|
|
|
|
|
|
|
|
rms.save("activities", $scope.activities);
|
|
|
|
$scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
|
|
|
|
rms.save('has_more', $scope.has_more);
|
|
|
|
rms.save('page', response.data.page);
|
|
|
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
|
|
|
}, function errorCallback(response) {
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
if($scope.activities.length<=0){
|
2016-06-22 12:11:34 +08:00
|
|
|
$scope.loadActData(0);
|
2016-06-14 14:24:39 +08:00
|
|
|
} else {
|
|
|
|
$timeout(function(){
|
|
|
|
window.scrollTo(0, rms.get("yoffset"));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//跳到详情页
|
|
|
|
$scope.goDetail = function(type, act_id,id){
|
|
|
|
rms.save("yoffset", window.document.body.scrollTop);
|
|
|
|
$location.path('/'+type+'/'+act_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.addPraise = function(act){
|
|
|
|
common.addCommonPraise(act);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.decreasePraise = function(act){
|
|
|
|
common.decreaseCommonPraise(act);
|
|
|
|
};
|
2016-06-14 16:03:10 +08:00
|
|
|
}]);
|