LoginController.js 870 B

123456789101112131415161718192021222324252627
  1. Ext.define('saas.view.auth.LoginController', {
  2. extend: 'Ext.app.ViewController',
  3. alias: 'controller.login',
  4. init: function () {
  5. this.callParent(arguments);
  6. },
  7. onLoginButton: function () {
  8. var me = this,
  9. view = me.getView(),
  10. form = me.lookup('authdialog'),
  11. values = form.getValues();
  12. view.mask('请稍等...');
  13. saas.model.Session.login(values.username, values.password)
  14. .then(function (session) {
  15. view.isMasked() && view.unmask();
  16. me.getViewModel().set('session', session);
  17. me.fireEvent('login', session);
  18. })
  19. .catch(function (error) {
  20. view.isMasked() && view.unmask();
  21. saas.util.BaseUtil.showErrorToast('登录失败: ' + error.message);
  22. });
  23. }
  24. });