ClubInputReplayCode.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. onLoad: function () {
  6. this.m_strInput = '';
  7. this.m_strShowInput = '';
  8. this.m_LabInput = this.$('BGInput/Label@Label');
  9. var arr = this.$('Layout').children;
  10. for (var i = 0; i < arr.length; i++) {
  11. arr[i].on('click', this.onBtClicked, this);
  12. }
  13. },
  14. onEnable: function () {
  15. this.m_LabInput.string = '';
  16. this.m_strInput = '';
  17. this.m_strShowInput = '';
  18. },
  19. SetHook: function (hook) {
  20. this.m_Hook = hook;
  21. },
  22. onBtClicked: function (tag) {
  23. console.log(tag.node.name);
  24. var strFmt = ' ';
  25. if (tag.node.name == 'del') {
  26. if (this.m_strInput.length > 0) {
  27. this.m_strInput = this.m_strInput.slice(0, this.m_strInput.length - 1);
  28. this.m_strShowInput = this.m_strShowInput.slice(0, this.m_strShowInput.length - 6);
  29. }
  30. } else if (tag.node.name == 'reset') {
  31. this.m_LabInput.string = '';
  32. this.m_strInput = '';
  33. this.m_strShowInput = '';
  34. } else {
  35. this.m_strInput += tag.node.name;
  36. if(this.m_strInput.length > 6) return;
  37. if (this.m_strShowInput.length == 0) {
  38. this.m_strShowInput += tag.node.name;
  39. } else {
  40. this.m_strShowInput += strFmt + tag.node.name;
  41. }
  42. }
  43. this.m_LabInput.string = this.m_strShowInput;
  44. if (this.m_strInput.length >= 6) {
  45. var webUrl = window.PHP_HOME + '/GameRecord.php?&GetMark=8&ReplayCode=' + this.m_strInput;
  46. WebCenter.GetData(webUrl, 30, function (data) {
  47. var Arr = JSON.parse(data);
  48. if (Arr.length == 0) {
  49. this.m_LabInput.string = '';
  50. this.m_strInput = '';
  51. this.m_strShowInput = '';
  52. g_CurScene.ShowTips('重播碼錯誤');
  53. return;
  54. } else {
  55. var UserInfo = new Object();
  56. UserInfo.dwUserID = Arr[1]
  57. this.m_Hook.m_Hook.OnRePlayGame(Arr[0], Arr[2], UserInfo);
  58. this.node.active = false;
  59. }
  60. }.bind(this));
  61. }
  62. },
  63. });