LoginCtr.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const SceneCtrlBase = require('SceneCtrlBase');
  2. const JMLoadProgressBar = require('JMLoadProgressBar');
  3. const JMNetImage = require('JMNetImage');
  4. const LoginPanel = require('../view/login/LoginPanel');
  5. const RegisterPanel = require('../view/login/RegisterPanel');
  6. const TagType = {
  7. LOGIN: 0,
  8. REGISTER: 1
  9. };
  10. cc.Class({
  11. extends: SceneCtrlBase,
  12. editor: {
  13. menu: 'Ctrl/LoginCtrl'
  14. },
  15. properties: {
  16. loginPanel: {
  17. default: undefined,
  18. type: LoginPanel,
  19. },
  20. registerPanel: {
  21. default: undefined,
  22. type: RegisterPanel,
  23. },
  24. },
  25. onLoad () {
  26. this._super();
  27. this._tagType = TagType.LOGIN;
  28. // 进行授权、登录、注册等操作
  29. this.initAuth();
  30. this.initUI();
  31. },
  32. initAuth () {
  33. },
  34. initUI () {
  35. this.showpanel(TagType.LOGIN);
  36. this.loginPanel.reloadData(()=> {
  37. this.showpanel(TagType.REGISTER);
  38. });
  39. this.registerPanel.reloadData(()=> {
  40. this.showpanel(TagType.LOGIN);
  41. });
  42. },
  43. showpanel (tagType) {
  44. this._tagType = tagType;
  45. this.loginPanel.node.active = tagType == TagType.LOGIN;
  46. this.registerPanel.node.active = tagType == TagType.REGISTER;
  47. }
  48. });