checkin.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. app.controller('ExamCheckinCtrl', [ '$rootScope', '$scope', '$stateParams','$interval', function($rootScope, $scope, $stateParams, $interval) {
  2. $scope.waitNum=-1;
  3. $scope.inRoomFlag = true;
  4. $scope.openroom = function (){
  5. $rootScope.ajaxRequest({
  6. url : '../exam/online/meeting/url.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. // alert(response.entity);
  14. window.location = response.entity;
  15. });
  16. }
  17. $scope.inroom = function(){
  18. $rootScope.ajaxRequest({
  19. url : '../exam/online/wait/num.htm',
  20. data : {
  21. agent_id : $stateParams.agent_id,
  22. aspect_id : $stateParams.aspect_id,
  23. std_id: $rootScope.ArtStdReg.std_id
  24. }
  25. }, function(response) {
  26. $scope.waitNum=response.map.waitNum;
  27. // $scope.inRoomFlag = response.map.inRoomFlag;
  28. });
  29. }
  30. $scope.inroom();
  31. $scope.i=0;
  32. $scope.checkinroom = function(){
  33. if ($scope.waitNum > 10) {
  34. if($scope.i++>=15){
  35. $scope.i=0;
  36. $scope.inroom();
  37. }
  38. }
  39. else
  40. $scope.inroom();
  41. }
  42. var timer = setInterval(function() {
  43. $scope.$apply(function() {
  44. $scope.checkinroom();
  45. });
  46. }, 15000);
  47. $scope.$on('$destroy', function() {
  48. if (timer) {
  49. // clearInterval(timer);
  50. timer = null;
  51. }
  52. });
  53. }])