不刷新返回
This commit is contained in:
parent
37975552c9
commit
1251e31061
|
@ -74,21 +74,11 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
|
|||
|
||||
console.log("ActivityController load");
|
||||
|
||||
$scope.page = 0;
|
||||
$scope.page = rms.get('page') || 0;
|
||||
$scope.activities = rms.get("activities") || [];
|
||||
$scope.has_more = rms.get("has_more");
|
||||
|
||||
if($scope.activities.length>0){
|
||||
|
||||
$timeout(function () {
|
||||
window.scroll(0,rms.get("yoffset"));
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var loadActData = function(page){
|
||||
$scope.loadActData = function(page){
|
||||
|
||||
$scope.page = page;
|
||||
$http({
|
||||
|
@ -96,20 +86,16 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
|
|||
url: apiUrl+ "activities",
|
||||
data: {openid: auth.openid(), page: page}
|
||||
}).then(function successCallback(response) {
|
||||
$scope.current_page = 0;
|
||||
console.log($scope.current_page);
|
||||
console.log(response.data.page);
|
||||
if($scope.current_page < response.data.page) {
|
||||
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);
|
||||
|
||||
|
@ -118,20 +104,14 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
|
|||
};
|
||||
|
||||
if($scope.activities.length<=0){
|
||||
|
||||
auth.getOpenId().then(
|
||||
function successCallback(response){
|
||||
loadActData($scope.page);
|
||||
$scope.loadActData(0);
|
||||
}, function errorCallback(response) {
|
||||
alert("获取openid出错:"+response);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$scope.loadActData = loadActData;
|
||||
};
|
||||
|
||||
//跳到详情页
|
||||
$scope.goDetail = function(type, act_id,id){
|
||||
|
@ -146,9 +126,6 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
|
|||
$scope.decreasePraise = function(act){
|
||||
common.decreaseCommonPraise(act);
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.factory('common', function($http, auth, $routeParams){
|
||||
|
@ -517,9 +494,9 @@ app.directive('loadingSpinner', function ($http) {
|
|||
|
||||
app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) {
|
||||
var rootPath = '/assets/wechat/'
|
||||
$locationProvider.html5Mode(true);
|
||||
//$locationProvider.html5Mode(true);
|
||||
$routeProvider
|
||||
.when('/', {
|
||||
.when('/activites', {
|
||||
templateUrl: rootPath + 'activities.html',
|
||||
controller: 'ActivityController'
|
||||
})
|
||||
|
@ -552,7 +529,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou
|
|||
controller: 'BlogController'
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/'
|
||||
redirectTo: '/activites'
|
||||
});
|
||||
|
||||
//监听异步请求,实现加载中显隐标记
|
||||
|
|
Loading…
Reference in New Issue