weChatStudentRequireCtrl.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. app.controller('weChatStudentRequireCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$auth', '$window', '$document', '$timeout', '$filter', '$http', 'cfpLoadingBar', 'SweetAlert', 'Restangular', 'api_login',
  2. function($rootScope, $scope, $state, $translate, $localStorage, $cookieStore, $auth, $window, $document, $timeout, $filter, $http, cfpLoadingBar, SweetAlert, Restangular, api_login) {
  3. $rootScope.app.layout.isNavbarFixed = false;
  4. $rootScope.app.layout.isSidebarFixed = false;
  5. $scope.loginBtn = {
  6. closeEl: '.close',
  7. modal: {
  8. templateUrl: 'assets/views/loginform.html',
  9. postion: 'center'
  10. }
  11. };
  12. $scope.choicevalue = 1
  13. $scope.choicelogin = function(e) {
  14. $scope.choicevalue = e;
  15. }
  16. $scope.login = function() {
  17. angular.element('.el-login').trigger('click');
  18. }
  19. $scope.close = function() {
  20. console.log(angular.element('.el-login'));
  21. angular.element('.el-login').trigger('click');
  22. }
  23. $scope.loginForm = {
  24. username: "",
  25. // account:"",
  26. password: ""
  27. }
  28. $rootScope.app.isLoginFixed = true;
  29. $scope.validateUsername = function() {
  30. return $scope.loginForm.username == null || $scope.loginForm.username == "";
  31. }
  32. $scope.validatePassword = function() {
  33. return $scope.loginForm.password == null || $scope.loginForm.password == "";
  34. }
  35. $scope.formValid = function() {
  36. return $scope.loginForm.username == null || $scope.loginForm.username == "" || $scope.loginForm.password == null || $scope.loginForm.password == "";
  37. }
  38. $rootScope.$on('auth:invalid', function(ev) {
  39. $state.go('login.signin');
  40. });
  41. $scope.handleLoginClick = function(e) {
  42. // console.log(' $scope.loginForm.='+JSON.stringify( $scope.loginForm));
  43. $auth.submitLogin($scope.loginForm)
  44. .then(function(resp) {
  45. // console.log(' resp='+JSON.stringify(resp));
  46. if (resp.error != 501) {
  47. $state.go('app.incident.list');
  48. $rootScope.app.isLoginFixed = false;
  49. } else {
  50. resp.error = "";
  51. $scope.loginForm.password = "";
  52. SweetAlert.swal("用户名或者密码验证失败,请重试!", "登录错误", "error");
  53. }
  54. })
  55. .catch(function(resp) {
  56. $scope.loginForm.password = "";
  57. SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
  58. });
  59. };
  60. $scope.handleloginEnter = function(e) {
  61. if (e.keyCode == 13) {
  62. $scope.handleLoginClick();
  63. }
  64. };
  65. $scope.viewType = "password";
  66. $scope.isPassword = true;
  67. $scope.toggleView = function() {
  68. $scope.isPassword = !$scope.isPassword;
  69. $scope.viewType = $scope.isPassword ? "password" : "text";
  70. }
  71. $scope.handleSignOutBtnClick = function() {
  72. $auth.signOut()
  73. .then(function(resp) {
  74. // handle success response
  75. })
  76. .catch(function(resp) {
  77. // handle error response
  78. });
  79. };
  80. }
  81. ]);