LoginPanel.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. cc.Class({
  2. editor: {
  3. menu: 'Login/LoginPanel'
  4. },
  5. extends: cc.Component,
  6. properties: {
  7. gotoLogin: {
  8. default: undefined,
  9. type: cc.Button,
  10. },
  11. gotoRegister: {
  12. default: undefined,
  13. type: cc.Button,
  14. },
  15. getCode: {
  16. default: undefined,
  17. type: cc.Button,
  18. },
  19. phoneEditor: {
  20. default: undefined,
  21. type: cc.EditBox,
  22. },
  23. codeEditor: {
  24. default: undefined,
  25. type: cc.EditBox,
  26. },
  27. passwordEditor: {
  28. default: undefined,
  29. type: cc.EditBox,
  30. },
  31. },
  32. onLoad () {
  33. let phoneNum = cc.sys.localStorage.getItem("user_phone_num", "")
  34. let password = cc.sys.localStorage.getItem("user_password", "")
  35. this.phoneEditor.string = phoneNum;
  36. this.passwordEditor.string = password;
  37. },
  38. reloadData (cb) {
  39. this._cb = cb;
  40. },
  41. gotoLoginOnClicked () {
  42. var phoneNum = this.phoneEditor.string;
  43. if (phoneNum.length == 0 && !G.FuncUtils.isMobile(phoneNum)) {
  44. G.AppUtils.getSceneCtrl().addToast("手机号码格式不正确");
  45. return;
  46. }
  47. var password = this.passwordEditor.string;
  48. if (password.length == 0) {
  49. G.AppUtils.getSceneCtrl().addToast("密码不能不填");
  50. return;
  51. }
  52. if (password.length > 16) {
  53. G.AppUtils.getSceneCtrl().addToast("密码过长");
  54. return;
  55. }
  56. G.LogiMngr.requestLoginByPhone(phoneNum, password);
  57. cc.sys.localStorage.setItem("user_phone_num", phoneNum)
  58. cc.sys.localStorage.setItem("user_password", password)
  59. },
  60. gotoRegisterOnClicked () {
  61. if (this._cb) {
  62. this._cb();
  63. }
  64. },
  65. getCodeOnClicked () {
  66. }
  67. });