UNPKG

mobileoa-common-modules

Version:

移动办公平台前端公共功能模块

40 lines (34 loc) 1.14 kB
'use strict'; var angular = require('angular'); require('../modules'); require('../../login/services/LoginService'); var module = angular.module('gesturepassword.controller'); module.controller('otherLoginCtrl',function($scope, $rootScope, $ionicLoading, $toast, $state, LoginService, LinkerService) { $scope.newUser = {}; $scope.loginInModal = function() { $scope.login($scope.newUser).then(function() { $rootScope.$broadcast('loginNewUser'); }); }; $scope.login = function(user) { return LoginService.login(user, function() {}).then(function(data) { if (data.success) { return LinkerService.getCurrentUser().then(function(loginuser) { var storage = localStorage.getItem(loginuser.userId); if (!storage) { $state.go('gesturepassword.setGesturePwd2'); } else { $state.go('core.notice'); } }); } else { $toast.showLongCenter('用户名或密码错误,请核实。'); } }, function() { $toast.showLongCenter('请求登录失败,请先配置服务器访问地址或检查网络连接。'); })['finally'](function() { $ionicLoading.hide(); }); }; });