InputReplayCode.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. console.log(this.m_strInput);
  25. var strFmt = ' ';
  26. if (tag.node.name == 'del') {
  27. if (this.m_strInput.length > 0) {
  28. this.m_strInput = this.m_strInput.slice(0, this.m_strInput.length - 1);
  29. this.m_strShowInput = this.m_strShowInput.slice(0, this.m_strShowInput.length - 6);
  30. }
  31. } else if (tag.node.name == 'reset') {
  32. this.m_LabInput.string = '';
  33. this.m_strInput = '';
  34. this.m_strShowInput = '';
  35. } else {
  36. this.m_strInput += tag.node.name;
  37. if(this.m_strInput.length > 6) return;
  38. if (this.m_strShowInput.length == 0) {
  39. this.m_strShowInput += tag.node.name;
  40. } else {
  41. this.m_strShowInput += strFmt + tag.node.name;
  42. }
  43. }
  44. this.m_LabInput.string = this.m_strShowInput;
  45. if (this.m_strInput.length >= 6) {
  46. var webUrl = window.PHP_HOME + '/GameRecord.php?&GetMark=8&ReplayCode=' + this.m_strInput;
  47. console.log(webUrl);
  48. WebCenter.GetData(webUrl, 30, function (data) {
  49. var Arr = JSON.parse(data);
  50. if (Arr.length == 0) {
  51. this.m_LabInput.string = '';
  52. this.m_strInput = '';
  53. this.m_strShowInput = '';
  54. g_CurScene.ShowTips('重播碼錯誤,請輸入正確的');
  55. return;
  56. } else {
  57. var UserInfo = new Object();
  58. UserInfo.dwUserID = Arr[1]
  59. this.m_Hook.m_Hook.OnRePlayGame(Arr[0], Arr[2], UserInfo);
  60. this.node.active = false;
  61. }
  62. }.bind(this));
  63. }
  64. },
  65. });