PhoneLogin.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_editPhone:cc.EditBox,
  5. m_editPassWord:cc.EditBox,
  6. m_editCode:cc.EditBox,
  7. },
  8. OnShowView:function() {
  9. this.m_editPhone.string = '';
  10. this.m_editPassWord.string = '';
  11. var platform = cc.sys.localStorage.getItem(window.Key_LoginPlatform);
  12. if(platform == window.PLATFORM_PHONE) {
  13. if(window.g_PhpUserName != null){
  14. this.m_editPhone.string = window.g_PhpUserName ;
  15. this.m_editPassWord.string = window.g_PhpPassword;
  16. } else {
  17. var acc = cc.sys.localStorage.getItem('LoginAcc');
  18. if(acc != null) this.m_editPhone.string = acc;
  19. }
  20. }
  21. var platform = cc.sys.localStorage.getItem(window.Key_LoginPlatform);
  22. if(platform != window.PLATFORM_PHONE) this.m_editPhone.string = '';
  23. if(!this.m_VeriCtrl) {
  24. this.m_VeriCtrl = this.$('ToggleContainer/1/checkmark/VerCode@VerificationCtrl');
  25. this.m_VeriCtrl.SetHook(this, null);
  26. this.m_VeriCtrl.SetKey('PhoneLogin');
  27. this.m_VeriCtrl.SetCheckState(2);
  28. }
  29. },
  30. //点击注册
  31. OnClicked_Regist:function() {
  32. cc.gSoundRes.PlaySound('Button');
  33. this.ShowPrefabDLG('RegistAcc', this.node, function(Js) {
  34. Js.m_Hook = this.m_Hook;
  35. }.bind(this));
  36. },
  37. //点击密码登录
  38. OnClicked_Login:function() {
  39. cc.gSoundRes.PlaySound('Button');
  40. if(this.m_editPhone.string.length < 2) return this.ShowTips("請輸入有效帳號!");
  41. if(this.m_Hook){
  42. cc.sys.localStorage.setItem(window.Key_LoginPlatform, window.PLATFORM_PHONE);
  43. this.m_Hook.LoginAccount(this.m_editPhone.string, hex_md5(this.m_editPassWord.string));
  44. }
  45. this.HideView();
  46. },
  47. //点击验证码登录
  48. OnClicked_PhoneLogin: function(){
  49. cc.gSoundRes.PlaySound('Button');
  50. if(this.m_VeriCtrl) {
  51. var res = this.m_VeriCtrl.Check();
  52. if(res.code != 0) return;
  53. //提交
  54. var webUrl = window.PHP_HOME+'/UserFunc.php?&GetMark=20&strPhone='+res.PhoneNum;
  55. WebCenter.GetData(webUrl, null, function (data) {
  56. var res = JSON.parse(data);
  57. if(res.Res != 0) {
  58. this.ShowAlert('該手機未綁定任何帳號!');
  59. }else{
  60. cc.sys.localStorage.setItem(window.Key_PhoneCode, '');
  61. if(this.m_Hook) {
  62. cc.sys.localStorage.setItem(window.Key_LoginPlatform, window.PLATFORM_PHONE);
  63. this.m_Hook.LoginAccount(res.Accounts, res.LogonPass);
  64. }
  65. this.HideView();
  66. }
  67. }.bind(this));
  68. return;
  69. }
  70. },
  71. //修改密码/忘记密码
  72. OnClicked_ChangePSW:function() {
  73. cc.gSoundRes.PlaySound('Button');
  74. this.ShowPrefabDLG('ChangePsw', this.node, function(Js) {
  75. Js.OnShowView(0);
  76. }.bind(this));
  77. },
  78. });