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 (dnew 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 (startdatenew 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; }); } }])