123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- app.controller('ExamCtrl', [ '$rootScope', '$scope', '$stateParams','$interval', function($rootScope, $scope, $stateParams, $interval) {
- $scope.step = 1;
- $scope.lasttime=30;//倒计时
- $scope.buttontext='';
- $scope.aspectTopic={};
- $rootScope.ajaxRequest({
- url : '../enrol/log.htm',
- data : {
- logType:'WebPageExam'
- }
- }, function(response) {
- });
-
- $rootScope.ajaxRequest({
- url : '../enrol/std/enrol/find.htm',
- data : {
- enrol_id : $stateParams.enrol_id,
- aspect_batch : 1
- }
- }, function(response) {
- $scope.EnrolMap = response.map;
- if($scope.EnrolMap.Voide.viewnote=='true')
- $scope.lasttime=0;
-
- if ($stateParams.read=='true'){
- $scope.step=3;
- // $rootScope.ajaxRequest({
- // url : '../exam/topic/find.htm',
- // data : {
- // aspect_id : $scope.EnrolMap.StdEnrol.aspect_id
- // }
- // }, function(response) {
- // $scope.aspectTopic = response.map;
- // $interval.cancel($scope.timer);
- // });
- }
-
- $rootScope.ajaxRequest({
- url : '../enrol/std/video/qrcodeAjax.htm',
- data : {cert_id:$rootScope.ArtStdReg.cert_id, ly_group_id:$scope.EnrolMap.stdSubject.ly_group_id,enrol_id:$scope.EnrolMap.StdEnrol.enrol_id}
- }, function(response) {
- new QRCode(document.getElementById('qrcode'), response.entity);
- });
- });
-
- $scope.setStep=function(v){
- if($scope.lasttime<=1){
- $scope.step=v;
- if($scope.EnrolMap.Voide.viewnote=='false')
- $rootScope.ajaxRequest({
- url : '../exam/topic/viewnote.htm',
- }, function(response) {
- $scope.lasttime=0;
- });
- }
- }
-
- var fn = function (){
- if ($scope.lasttime>1){
- $scope.buttontext='阅读倒计时('+ --$scope.lasttime +'秒)';
- }else{
- $scope.buttontext='我已阅读考试须知';
- $rootScope.ajaxRequest({
- url : '../exam/topic/find.htm',
- data : {
- aspect_id : $scope.EnrolMap.StdEnrol.aspect_id
- }
- }, function(response) {
- $scope.aspectTopic = response.map;
- $interval.cancel($scope.timer);
- });
- }
- }
- $scope.timer =$interval(fn, 1000, $scope.lasttime);
-
- $scope.showTopic =false;
- $scope.getTopic=function(v){
- if ($scope.aspectTopic.exam_topic_date==null){
- if($scope.aspectTopic.exam_topic!=''){
- fn();
- $scope.showTopic =true;
- }
- return;
- }
- let d = new Date($scope.aspectTopic.exam_topic_date.replace(/\-/g, "/"));
- if (d<new Date()){
- if($scope.aspectTopic.exam_topic!=''){
- fn();
-
- $rootScope.ajaxRequest({
- url : '../enrol/log.htm',
- data : {
- logType:'WebPageGetTopic'
- }
- }, function(response) {
- });
- $scope.showTopic =true;
- }
- }else{
- if (d-new Date()<=60000&&$scope.aspectTopic.exam_topic=='')
- fn();
- $.alert('时间未到,请在'+$scope.aspectTopic.exam_topic_date+'后获取考题!');
- }
-
- }
-
- $scope.uploadFile = function(){
- var file = document.getElementById("fileUpload").files[0];
- var data = new FormData();
- data.append('file', file);
- data.append('enrol_id',$stateParams.enrol_id);
- data.append('photo_type','photo_file');
-
-
- if(file==null) return;
- $rootScope.ajaxRequest({
- url: '../enrol/exam/upload.htm',
- data:data,
- headers: {'Content-Type': undefined},
- transformRequest: angular.identity
- }, function(response) {
- $scope.aspectTopic.photo_file=response.entity;
- console.log($scope.aspectTopic.photo_file);
- });
-
-
- }
-
- $scope.uploadvoidestatus=false;
- var refreshUploadVoideStatus = function (){
- if ($scope.aspectTopic.voide_start_date==null)
- return;
- let startdate = new Date($scope.aspectTopic.voide_start_date.replace(/\-/g, "/"));
- let enddate = new Date($scope.aspectTopic.voide_end_date.replace(/\-/g, "/"));
- if (startdate<new Date()&&enddate>new Date()){
- $scope.uploadvoidestatus=true;
- }else{
- $scope.uploadvoidestatus=false;
- }
- };
- $interval(refreshUploadVoideStatus, 1000);
-
- $scope.uploadphotostatus=false;
- var refreshUploadPhotoStatus = function (){
- if($scope.aspectTopic.photo_start_date==null)
- return;
- let startdate = new Date($scope.aspectTopic.photo_start_date.replace(/\-/g, "/"));
- let enddate = new Date($scope.aspectTopic.photo_end_date.replace(/\-/g, "/"));
- if (startdate<new Date()&&enddate>new Date()){
- $scope.uploadphotostatus=true;
- }else{
- $scope.uploadphotostatus=false;
- }
- };
- $interval(refreshUploadPhotoStatus, 1000);
-
- $scope.showphoto=function (){
- var file = document.getElementById("fileUpload").files[0];
- console.log(file,'f');
- var url='';
- if (window.createObjectURL!=undefined) {
- url = window.createObjectURL(file) ;
- } else if (window.URL!=undefined) {
- url = window.URL.createObjectURL(file) ;
- } else if (window.webkitURL!=undefined) {
- url = window.webkitURL.createObjectURL(file) ;
- }
- // $scope.photo_url=url;
- console.log($scope.photo_url);
- }
-
- $scope.goUpload = function() {
- $rootScope.goLocation('exam/upload/' + $stateParams.enrol_id );
- }
-
- $scope.goDownload = function(url) {
- $('#down_url').attr('href', url);
- document.getElementById("down_url").click();
- }
-
- //开始考试
- $scope.startExam = function() {
- $rootScope.goLocation('exam/checkin/'+$scope.EnrolMap.StdEnrol.agent_id+"/"+$scope.EnrolMap.StdEnrol.aspect_id);
- }
-
- $scope.baodao = function() {
- if($scope.EnrolMap.StdEnrol.baodao!=null){
- $scope.step=3;
- return;
- }
-
- let startdate = new Date($scope.aspectTopic.exam_start_date.replace(/\-/g, "/"));
- if (startdate.getTime()-(1000*60*15)<(new Date().getTime())){
- if (startdate.getTime()+1000*60*15<(new Date().getTime())){
- console.log("时间已过");
- }else{
- console.log("时间范围里");
- $scope.step=3;
- }
- }else{
- $.alert("报到时间未到");
- }
- }
- $scope.chengnuo = function() {
- $rootScope.ajaxRequest({
- url: '../exam/savebaodao.htm',
- data:{enrol_id:$scope.EnrolMap.StdEnrol.enrol_id}
- }, function(response) {
- $scope.step=4;
- });
- }
-
- }])
|