wait.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. app.controller('ExamWaitCtrl', [ '$rootScope', '$scope', '$stateParams','$interval', function($rootScope, $scope, $stateParams, $interval) {
  2. $scope.flag = true;
  3. $scope.msg = '';
  4. $scope.query = function (){
  5. $rootScope.ajaxRequest({
  6. url : '../exam/online/checkin/query.htm',
  7. data : {
  8. agent_id : $stateParams.agent_id,
  9. aspect_id : $stateParams.aspect_id,
  10. std_id: $rootScope.ArtStdReg.std_id
  11. }
  12. }, function(response) {
  13. $scope.checkEntity = response.entity;
  14. if($scope.checkEntity && $scope.checkEntity.is_success != undefined) {
  15. if($scope.checkEntity.is_success == 0) {
  16. $scope.flag = true;
  17. $scope.msg = '';
  18. $rootScope.goLocation('exam/checkin/'+$stateParams.agent_id+"/"+$stateParams.aspect_id);
  19. //$rootScope.goLocation('exam/voide/' + $stateParams.enrol_id+'/false');
  20. } else if($scope.checkEntity.is_success == -1) {
  21. $scope.flag = false;
  22. $scope.msg = $scope.checkEntity.err_msg;
  23. }
  24. }
  25. });
  26. }
  27. $scope.query();
  28. var timer = setInterval(function() {
  29. $scope.$apply(function() {
  30. $scope.query();
  31. });
  32. }, 5000);
  33. $scope.$on('$destroy', function() {
  34. if (timer) {
  35. clearInterval(timer);
  36. timer = null;
  37. }
  38. });
  39. }])