BindPhone.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_EdPSW: cc.EditBox,
  5. m_EdPSW2: cc.EditBox,
  6. m_VeriNode: cc.Node,
  7. },
  8. ctor: function () {
  9. },
  10. OnShowView: function () {
  11. this.$('BindPhone').active = false;
  12. this.$('RebindPhone').active = false;
  13. if (!this.m_VeriCtrl) {
  14. this.m_VeriCtrl = this.$('BindPhone@VerificationCtrl');
  15. this.m_VeriCtrl.SetHook(this, null);
  16. this.m_VeriCtrl.SetKey('BindPhone');
  17. this.m_VeriCtrl.SetCheckState(1);
  18. }
  19. this.m_VeriCtrl.Reset();
  20. if (!this.m_VeriCtrlOld) {
  21. this.m_VeriCtrlOld = this.$('RebindPhone/Old@VerificationCtrl');
  22. this.m_VeriCtrlOld.SetHook(this, null);
  23. this.m_VeriCtrlOld.SetKey('BindPhoneOld');
  24. this.m_VeriCtrlOld.SetCheckState(3);
  25. }
  26. this.m_VeriCtrlOld.Reset();
  27. if (!this.m_VeriCtrlNew) {
  28. this.m_VeriCtrlNew = this.$('RebindPhone/New@VerificationCtrl');
  29. this.m_VeriCtrlNew.SetHook(this, null);
  30. this.m_VeriCtrlNew.SetKey('BindPhoneNew');
  31. this.m_VeriCtrlNew.SetCheckState(1);
  32. }
  33. this.m_VeriCtrlNew.Reset();
  34. },
  35. SetBindMode: function (bFirst) {
  36. this.m_bFirst = bFirst;
  37. if (this.m_bFirst) {
  38. this.$('BindPhone').active = true;
  39. this.$('RebindPhone').active = false;
  40. } else {
  41. this.$('BindPhone').active = false;
  42. this.$('RebindPhone').active = true;
  43. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  44. // 检查绑定手机
  45. var webUrl = window.PHP_HOME + '/UserFunc.php?GetMark=19&dwUserID=' + pGlobalUserData.dwUserID;
  46. WebCenter.GetData(webUrl, 3, function (data) {
  47. if (data == "") {
  48. } else {
  49. this.m_VeriCtrlOld.SetPhoneNum(data);
  50. var pLabel = this.$('LabPNum@Label', this.m_VeriCtrlOld.node);
  51. if(pLabel) {
  52. pLabel.string = cutPhone(data);
  53. }
  54. }
  55. }.bind(this));
  56. }
  57. },
  58. OnClick_BtNext: function () {
  59. cc.gSoundRes.PlaySound('Button');
  60. var res = this.m_VeriCtrl.Check();
  61. if (res.code != 0) {
  62. return;
  63. }
  64. this.$('NdPhone').active = false;
  65. this.$('NdPsw').active = true;
  66. },
  67. OnClicked_Submit: function () {
  68. cc.gSoundRes.PlaySound('Button');
  69. if (this.m_bFirst) {
  70. var resFirst = this.m_VeriCtrl.Check();
  71. if (resFirst.code != 0) {
  72. return;
  73. }
  74. //提交
  75. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  76. // var webUrl = window.PHP_HOME + '/UserFunc.php?&GetMark=2&dwUserID=' + pGlobalUserData.dwUserID;
  77. // webUrl += '&strPsw=' + hex_md5(pGlobalUserData.szPassword);
  78. // webUrl += '&Phone=' + this.m_EdPhone.string + '&Code=' + this.m_EdCode.string
  79. var webUrl = `${window.PHP_HOME}/UserFunc.php?&GetMark=2&dwUserID=${pGlobalUserData.dwUserID}&strPsw=${pGlobalUserData.szPassword}&Phone=${resFirst.PhoneNum}&Code=${resFirst.PhoneCode}`;
  80. WebCenter.GetData(webUrl, null, function (data) {
  81. if (this.m_Hook) this.m_Hook.StopLoading();
  82. if (data === -1) {
  83. this.ShowTips('請檢查網路!');
  84. } else {
  85. var res = JSON.parse(data);
  86. if (res.Res == 0) cc.sys.localStorage.setItem(window.Key_PhoneCode, '');
  87. this.ShowAlert(res.Describe, Alert_Yes, function (Res) {
  88. if (res.Res == 0 && Res) {
  89. if(this.m_Hook && this.m_Hook.OnBindSuccess) this.m_Hook.OnBindSuccess(resFirst.PhoneNum);
  90. if (this.m_Hook.OnBtRefeshRoomCard) this.m_Hook.OnBtRefeshRoomCard();
  91. this.HideView();
  92. }
  93. }.bind(this))
  94. }
  95. }.bind(this));
  96. this.m_VeriCtrl.Reset();
  97. return;
  98. }
  99. var resOld = this.m_VeriCtrlOld.Check();
  100. if (resOld.code != 0) return;
  101. var resNew = this.m_VeriCtrlNew.Check();
  102. if (resNew.code != 0) return;
  103. //提交
  104. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  105. var webUrl = `${window.PHP_HOME}/UserFunc.php?&GetMark=30&dwUserID=${pGlobalUserData.dwUserID}&strPsw=${pGlobalUserData.szPassword}&PhoneNumOld=${resOld.PhoneNum}&PhoneNumNew=${resNew.PhoneNum}&Code=${resNew.PhoneCode}`;
  106. WebCenter.GetData(webUrl, null, function (data) {
  107. if (this.m_Hook) this.m_Hook.StopLoading();
  108. if (data === -1) {
  109. this.ShowTips('請檢查網路!');
  110. } else {
  111. var res = JSON.parse(data);
  112. if (res.Res == 0) {
  113. this.m_VeriCtrlOld.Clear();
  114. this.m_VeriCtrlNew.Clear();
  115. }
  116. this.ShowAlert(res.Describe, Alert_Yes, function (Res) {
  117. if (res.Res == 0 && Res) {
  118. if(this.m_Hook && this.m_Hook.OnBindSuccess) this.m_Hook.OnBindSuccess(resNew.PhoneNum);
  119. if (g_CurScene.OnBtRefeshRoomCard) g_CurScene.OnBtRefeshRoomCard();
  120. var platform = cc.sys.localStorage.getItem(window.Key_LoginPlatform);
  121. if(platform == window.PLATFORM_PHONE) {
  122. cc.sys.localStorage.setItem('LoginAcc', resNew.PhoneNum);
  123. }
  124. this.HideView();
  125. }
  126. }.bind(this))
  127. }
  128. }.bind(this));
  129. // this.m_VeriCtrlOld.Reset();
  130. // this.m_VeriCtrlNew.Reset();
  131. },
  132. });