login.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. (function(vc){
  2. vc.extends({
  3. data:{
  4. loginInfo:{
  5. username:'',
  6. passwd:'',
  7. errorInfo:''
  8. }
  9. },
  10. _initMethod:function(){
  11. vc.component.clearCacheData();
  12. },
  13. _initEvent:function(){
  14. vc.component.$on('errorInfoEvent',function(_errorInfo){
  15. vc.component.loginInfo.errorInfo = _errorInfo;
  16. console.log('errorInfoEvent 事件被监听',_errorInfo)
  17. });
  18. vc.component.$on('validate_code_component_param_change_event',function(params){
  19. for(var tmpAttr in params){
  20. vc.component.loginInfo[tmpAttr] = params[tmpAttr];
  21. }
  22. console.log('errorInfoEvent 事件被监听',params)
  23. });
  24. vc.on('login','doLogin',function(){
  25. vc.component.doLogin();
  26. })
  27. },
  28. methods:{
  29. clearCacheData:function(){
  30. vc.clearCacheData();
  31. },
  32. doLogin:function(){
  33. vc.http.post(
  34. 'login',
  35. 'doLogin',
  36. JSON.stringify(vc.component.loginInfo),
  37. {
  38. emulateJSON:true
  39. },
  40. function(json,res){
  41. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  42. if(res.status == 200){
  43. vc.jumpToPage("/");
  44. return ;
  45. }
  46. vc.component.loginInfo.errorInfo = json;
  47. },
  48. function(errInfo,error){
  49. console.log('请求失败处理');
  50. vc.component.loginInfo.errorInfo = errInfo;
  51. });
  52. }
  53. },
  54. _destroyedMethod:function(){
  55. console.log("登录页面销毁调用");
  56. }
  57. });
  58. })(window.vc);