1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict';
- app.controller('ForgotpwdCtrl', ['$scope', '$http', '$state', '$interval', function ($scope, $http, $state, $interval) {
- $scope.username = "";
- $scope.code = "";
- $scope.authError = null;
- $scope.codeTime = 0;
- $scope.getCheckCode = function () {
- $scope.authError = null;
- $http.get('/manager/user/getCode', {username: $scope.username})
- .then(function (response) {
- var data = response.data;
- if (data.result == 1) {
- $scope.authError = '无法获取验证码';
- } else {
- $scope.codeTime = 60;
- var timer = $interval(function () {
- $scope.codeTime--;
- if ($scope.codeTime <= 0) {
- $interval.cancel(timer);
- }
- }, 1000);
- }
- }, function (x) {
- $scope.authError = '服务器异常';
- });
- };
- $scope.sendCheck = function () {
- $scope.authError = null;
- $http.post('/manager/user/forgot', {username: $scope.username, code: $scope.code})
- .then(function (response) {
- var data = response.data;
- if (data.result == 1) {
- $scope.authError = '验证码不对';
- } else {
- $state.go('app');
- }
- }, function (x) {
- $scope.authError = '服务器异常';
- });
- };
- }]);
|