std_disable_user.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. app.controller('StdDisableUserCtrl', function($rootScope, $scope, $http, $timeout, $state, myConfig, $cookieStore, $interval) {
  2. $scope.sendMessageTime = 0;
  3. $interval(function(){
  4. if($scope.sendMessageTime > 0){
  5. $scope.sendMessageTime--;
  6. }
  7. }, 1000);
  8. $scope.load = function(){
  9. $scope.myPromise = $http({
  10. url : myConfig.url + '/user/info?session=' + $rootScope.session,
  11. method : 'GET'
  12. }).success(function(data) {
  13. if(data.code == 0){
  14. $scope.login = data.result;
  15. $scope.login.mobile = $scope.login.login_name;
  16. }else{
  17. $rootScope.dialogMsg(data.errorMsg, function(){
  18. window.location = "index.html";
  19. })
  20. }
  21. }).error(function() {
  22. });
  23. }
  24. $scope.load();
  25. $scope.sendMessage = function(){
  26. $scope.sendMessageTime = 100;
  27. $scope.myPromise = $http({
  28. url : myConfig.url + '/user/checkSendSms',
  29. method : 'POST',
  30. data : angular.toJson($scope.login)
  31. }).success(function(data) {
  32. if(data.code == 0){
  33. if(data.result.checkResult){
  34. $scope.doSendSms();
  35. }else{
  36. $rootScope.dialogMsg("请勿频繁操作,请稍后重试", function(){});
  37. }
  38. }else{
  39. $rootScope.dialogMsg("请稍后重试", function(){});
  40. }
  41. }).error(function() {
  42. });
  43. }
  44. $scope.doSendSms = function(){
  45. $scope.myPromise = $http({
  46. url : myConfig.url + '/user/userSaveSmsLog?session=' + $rootScope.session,
  47. method : 'POST',
  48. data : angular.toJson($scope.login)
  49. }).success(function(data) {
  50. if(data.code == 0){
  51. $rootScope.dialogMsg("验证码已发送,请注意查收", function(){});
  52. }else{
  53. $rootScope.dialogMsg(data.errorMsg, function(){});
  54. }
  55. }).error(function() {
  56. });
  57. }
  58. $scope.submitForm = function(isValid) {
  59. $scope.submitted = true;
  60. if(isValid){
  61. $scope.myPromise = $http({
  62. url : myConfig.url + '/user/checkVerifyCode',
  63. method : 'POST',
  64. data : angular.toJson($scope.login)
  65. }).success(function(data) {
  66. if(data.code == 0){
  67. $scope.myPromise = $http({
  68. url : $rootScope.host_url + '/user/disableUser?session=' + $rootScope.session,
  69. method : 'POST'
  70. }).success(function(data) {
  71. if(data.code == 0){
  72. $rootScope.dialogMsg("删除成功", function(){
  73. $rootScope.logout();
  74. });
  75. }else{
  76. toaster.pop('error', data.message);
  77. }
  78. }).error(function() {
  79. });
  80. }else{
  81. $rootScope.dialogMsg(data.errorMsg, function(){});
  82. }
  83. }).error(function() {
  84. });
  85. }
  86. };
  87. });