This commit is contained in:
guange 2016-06-07 16:59:26 +08:00
parent 81e35de2b6
commit b01a671fb4
1 changed files with 15 additions and 40 deletions

View File

@ -75,38 +75,10 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
console.log("ActivityController load");
$scope.page = 0;
var current_page = rms.get('current_page');
if(typeof current_page !== 'undefined'){
$scope.page = current_page;
}
$scope.activities = rms.get("activities") || [];
var savePageConfig = function(){
rms.save('current_page', $scope.current_page);
rms.save('has_more', $scope.has_more);
rms.save('activities', $scope.activities);
}
var loadPageConfig = function(){
var has_more = rms.get('has_more');
var activities = rms.get('activities');
if(typeof has_more !== 'undefined'){
$scope.has_more = has_more;
}
}
var loadActData = function(page){
if (page > 0 && $scope.activities.length >0){ //应该是返回过来的
loadPageConfig();
var yOffset = rms.get("yoffset");
$location.hash(yOffset);
return;
}
$scope.page = page;
$http({
@ -126,19 +98,22 @@ app.controller('ActivityController',function($anchorScroll, $location,$scope, $h
console.log(response.data);
rms.save('current_page', $scope.page);
rms.save('has_more', $scope.has_more);
rms.save('activities', $scope.activities);
}, function errorCallback(response) {
});
};
auth.getOpenId().then(
function successCallback(response){
loadActData($scope.page);
}, function errorCallback(response) {
alert("获取openid出错:"+response);
}
);
if($scope.activities.length<=0){
auth.getOpenId().then(
function successCallback(response){
loadActData($scope.page);
}, function errorCallback(response) {
alert("获取openid出错:"+response);
}
);
}
$scope.loadActData = loadActData;
@ -529,7 +504,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou
var rootPath = '/assets/wechat/'
$locationProvider.html5Mode(true);
$routeProvider
.when('/activities', {
.when('/', {
templateUrl: rootPath + 'activities.html',
controller: 'ActivityController'
})
@ -562,7 +537,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($rou
controller: 'BlogController'
})
.otherwise({
redirectTo: '/activities'
redirectTo: '/'
});
//监听异步请求,实现加载中显隐标记