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/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); }); } }); $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(); } }])