signin.js 1014 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. /* Controllers */
  3. // signin controller
  4. app.controller('SigninFormController', ['$scope', '$http', '$state', 'md5', function ($scope, $http, $state, md5) {
  5. $scope.user = {};
  6. $scope.authError = null;
  7. $scope.login = function () {
  8. $scope.authError = null;
  9. // Try to login
  10. $http.post('/ad/advertiserLogin', {username: $scope.user.username, password: md5.createHash($scope.user.password)})
  11. .then(function (response) {
  12. var data = response.data;
  13. if (data.result == 1) {
  14. // $state.go('app.ad.manage');
  15. window.location.href = "./index.html?t=" + new Date().getTime() + "";//todo 防止切换用户没有刷新当前用户数据 或许有更好的方案
  16. } else {
  17. $scope.authError = data.description;
  18. }
  19. }, function (x) {
  20. $scope.authError = '服务器异常';
  21. });
  22. };
  23. }])
  24. ;