socialforge/public/javascripts/wechat/others/routes.js

67 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-06-17 18:18:03 +08:00
app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', function ($routeProvider, $httpProvider, $locationProvider, config) {
var rootPath = config.rootPath;
var resolve = {
delay: ['auth',function(auth){
return auth.get_bind();
}]
};
var makeRoute = function(path, ctrl){
return {
templateUrl: rootPath + path,
controller: ctrl,
resolve: resolve
}
}
2016-06-14 14:24:39 +08:00
//$locationProvider.html5Mode(true);
$routeProvider
2016-06-17 18:18:03 +08:00
.when('/login', {
templateUrl: rootPath + 'login.html',
controller: 'LoginController'
})
.when('/reg', {
templateUrl: rootPath + 'reg.html',
controller: 'RegController'
})
.when('/activites', makeRoute('activities.html', 'ActivityController'))
.when('/issues/:id', makeRoute('issue_detail.html', 'IssueController'))
.when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController'))
.when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController'))
.when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController'))
.when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController'))
.when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController'))
.when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController'))
2016-06-28 10:57:58 +08:00
.when('/class', makeRoute('class.html', 'ClassController'))
2016-06-27 17:24:06 +08:00
.when('/new_class', makeRoute('new_class.html', 'NewClassController'))
2016-06-27 11:09:25 +08:00
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
2016-06-27 17:24:06 +08:00
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
2016-06-24 09:01:12 +08:00
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
2016-06-14 14:24:39 +08:00
.otherwise({
redirectTo: '/activites'
});
//监听异步请求,实现加载中显隐标记
$httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) {
2016-06-14 14:24:39 +08:00
if ($rootScope.activeCalls == undefined) {
$rootScope.activeCalls = 0;
}
return {
request: function (config) {
$rootScope.activeCalls += 1;
return config;
},
requestError: function (rejection) {
$rootScope.activeCalls -= 1;
return rejection;
},
response: function (response) {
$rootScope.activeCalls -= 1;
return response;
},
responseError: function (rejection) {
$rootScope.activeCalls -= 1;
return rejection;
}
};
}]);
2016-06-14 14:24:39 +08:00
}]);