app.config([ '$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider.state('baseInfo', { abstract:true, url : "/baseInfo", templateUrl : "./std_base_info.html", controller : 'StdBaseInfoCtrl' }).state('baseInfo.basic', { url : "/basic", templateUrl : "./std_base_info_basic.html", controller : 'StdBaseInfoBasicCtrl' }).state('baseInfo.contact', { url : "/contact", templateUrl : "./std_base_info_contact.html", controller : 'StdBaseInfoContactCtrl' }).state('baseInfo.experience', { url : "/experience", templateUrl : "./std_base_info_experience.html", controller : 'StdBaseInfoExperienceCtrl' }).state('baseInfo.pic', { url : "/pic", templateUrl : "./std_base_info_pic.html", controller : 'StdBaseInfoPicCtrl' }).state('basicInfoConfirm', { url : "/basicInfoConfirm", templateUrl : "./std_basic_info_confirm.html", controller : 'StdBasicInfoConfirmCtrl' }).state('graduateSchool', { url : "/graduateSchool", templateUrl : "./std_graduate_school.html", controller : 'StdGraduateSchoolCtrl' }).state('major_bss', { url : "/major_bss", templateUrl : "./std_apply_major.html", controller : 'StdApplyMajorCtrl' }).state('confirm', { url : "/confirm", templateUrl : "./std_info_confirm.html", controller : 'StdInfoConfirmCtrl' }).state('modifyPassword', { url : "/modifyPassword", templateUrl : "./std_modify_password.html", controller : 'StdModifyPasswordCtrl' }).state('disableUser', { url : "/disableUser", templateUrl : "./std_disable_user.html", controller : 'StdDisableUserCtrl' }).state('luqu_bss', { url : "/luqu_bss", templateUrl : "./std_luqu_bss.html", controller : 'StdLuquBssCtrl' }).state('niluqu_query', { url : "/niluqu_query", templateUrl : "./std_niluqu_query.html", controller : 'StdNiluquQueryCtrl' }).state('niluqu_confirm', { url : "/niluqu_confirm", templateUrl : "./std_niluqu_confirm.html", controller : 'StdNiluquConfirmCtrl' }).state('baseInfoModify', { url : "/baseInfoModify", templateUrl : "./std_base_info_modify.html", controller : 'StdBaseInfoModifyApplyCtrl' }).state('mianshi', { url : "/mianshi", templateUrl : "./std_face_score.html", controller: 'StdFaceScoreCtrl' }).state('faceScoreFuhe', { url : "/faceScoreFuhe", templateUrl : "./std_face_score_fuhe.html", controller : 'StdFaceScoreFuheCtrl' }).state('faceScoreFuheResult', { url : "/faceScoreFuheResult", templateUrl : "./std_face_score_fuhe_result.html", controller : 'StdFaceScoreFuheResultCtrl' }).state('scoreFuhe', { url : "/scoreFuhe", templateUrl : "./std_score_modify.html", controller : 'StdScoreFuheCtrl' }).state('scoreFuheResult', { url : "/scoreFuheResult", templateUrl : "./std_score_modify_list.html", controller : 'StdScoreModifyListCtrl' }).state('ticket_bss', { url : "/ticket_bss", templateUrl : "./ticket_bss.html", controller : 'TicketBssCtrl' }).state('examNotice', { url : "/examNotice", templateUrl : "./std_exam_notice.html", controller : 'StdExamNoticeCtrl' }).state('examTimeNotice', { url : "/examTimeNotice", templateUrl : "./std_exam_time_notice.html", controller : 'StdExamTimeNoticeCtrl' }) }]); app.controller('AppCtrl', function($rootScope, $scope, $http, $timeout, $state, myConfig, $cookieStore, $window, Upload, toaster, $q) { $rootScope.session = $cookieStore.get('aeeaps-sesssion'); $rootScope.host_url = myConfig.url; $rootScope.frameParams = {}; $rootScope.frameParams.yes = 1; $rootScope.frameParams.no = 2; $rootScope.appTitle="北京外国语大学保送生报名系统"; var p_modules = $http({ url : myConfig.url + '/acquire/modules?session=' + $rootScope.session, method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.modules = data.result.modules; $rootScope.bkType = data.result.bkType; if($rootScope.modules.length > 0){ $state.go($rootScope.modules[0]) } }else{ $rootScope.dialogMsg(data.errorMsg, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_user = $http({ url : myConfig.url + '/user/info?session=' + $rootScope.session, method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.loginUser = data.result; }else{ $rootScope.dialogMsg(data.errorMsg, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_confirm = $http({ url : myConfig.url + '/acquire/confirmStatus?session=' + $rootScope.session, method : 'GET' }).success(function(data) { if(data.code == 0){ if(data.result && data.result.finish_time){ $rootScope.stdConfirmed = true; } }else{ $rootScope.dialogMsg(data.errorMsg, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_examNoticeConfirm = $http({ url : myConfig.url + '/acquire/getExamNoticeConfirm?session=' + $rootScope.session, method : 'GET' }).success(function(data) { if(data.code == 0){ if(data.code == 0){ $scope.examNoticeConfirm = data.result; if($scope.examNoticeConfirm.confirm_time){ $rootScope.stdExamNoticeConfirmed = true; }else{ $rootScope.stdExamNoticeConfirmed = false; } } }else{ $rootScope.dialogMsg(data.errorMsg, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_province = $http({ url : myConfig.url + '/frame/province', method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.provinceAll = data.result; }else{ $rootScope.dialogMsg(data.message, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_area = $http({ url : myConfig.url + '/frame/area_all', method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.areaAll = data.result; }else{ $rootScope.dialogMsg(data.message, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_city = $http({ url : myConfig.url + '/frame/city_all', method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.cityAll = data.result; }else{ $rootScope.dialogMsg(data.message, function(){ window.location = "index.html"; }) } }).error(function() { }); var p_minzu = $http({ url : myConfig.url + '/frame/params/minzu', method : 'GET' }).success(function(data) { if(data.code == 0){ $rootScope.minzuList = data.result; } }).error(function() { }); $scope.myPromise = $q.all([p_minzu, p_province, p_area, p_city, p_confirm, p_user, p_modules]); $rootScope.goNext = function(url, isFormChanged) { if(isFormChanged){ $rootScope.dialogMsg('您已修改表单内容,请确认是否保存表单'); }else{ $state.go(url); } return false; } $rootScope.goUrl = function(url, ctrl) { $state.go(url); return false; } $rootScope.logout = function() { $http({ url : $rootScope.host_url + '/user/logout?session=' + $rootScope.session, method : 'POST' }).success(function(data) { }); window.location = 'index.html'; } $rootScope.help = function() { $window.open('help.html'); // window.location = 'help.html'; } $rootScope.guide = function() { $window.open('input_desc.html'); } $rootScope.errorMsg = function(msg) { var d = dialog({ title : '错误提示', content : msg, ok : function() { }, okValue : '确定', width : 350 }); d.showModal(); } $rootScope.dialogMsg = function(msg, fn) { var vFn = fn == undefined ? (function() { }) : fn var d = dialog({ title : '操作提示', content : msg, ok : vFn, okValue : '确定', width : 320 }); d.showModal(); } $rootScope.viewFile = function(file){ $window.open($rootScope.host_url + '/' + file.path); } $rootScope.viewFileByPath = function(filePath){ $window.open($rootScope.host_url + '/' + filePath); } // upload on file select or drop $rootScope.upload = function (file, invalidFiles, item, form) { if(invalidFiles && invalidFiles.length > 0){ if(invalidFiles[0].$error == 'maxSize'){ toaster.pop('error', '文件大小超过2M'); }else{ toaster.pop('error', '上传失败,请重试'); } } if(!file) return; Upload.upload({ url: $rootScope.host_url + '/upload?session=' + $rootScope.session, data: {file: file} }).then(function (resp) { var path = resp.data.result.path; if(!item.files){ item.files = []; } item.files.push(resp.data.result); item.updateFile = true; form.$setDirty(); toaster.pop('warning', "上传成功,请点击保存按钮。"); }, function (resp) { }, function (evt) { }); }; $rootScope.upload = function (file, invalidFiles, item, form, dir) { if(invalidFiles && invalidFiles.length > 0){ if(invalidFiles[0].$error == 'maxSize'){ toaster.pop('error', '文件大小超过2M'); }else{ toaster.pop('error', '上传失败,请重试'); } } if(!file) return; Upload.upload({ url: $rootScope.host_url + '/upload?session=' + $rootScope.session, data: {file: file, dir: dir} }).then(function (resp) { var path = resp.data.result.path; if(!item.files){ item.files = []; } item.files.push(resp.data.result); item.updateFile = true; form.$setDirty(); toaster.pop('warning', "上传成功,请点击保存按钮。"); }, function (resp) { }, function (evt) { }); }; $rootScope.removeFile = function(item, index, form){ item.updateFile = true; item.files.splice(index, 1); toaster.pop('warning', "删除成功,请点击保存按钮。"); form.$setDirty(); } $rootScope.checkValue = function(field, value, min, max){ if(value < min){ $rootScope.errorMsg(field + "输入值小于最小值:" + min); } if(value > max){ $rootScope.errorMsg(field + "输入值大于最大值:" + max); } } $rootScope.preprocessHtml = function(html){ return html.replace(/%/g, '%%'); } $rootScope.revertHtml = function(html){ return html.replace(/%%/g, '%'); } } );