LeaseInfo.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * 租赁
  3. */
  4. import gameToast from "../Network/gameToast"
  5. cc.Class({
  6. extends: cc.Component,
  7. properties: {
  8. inputInviteValue: {
  9. default: '',
  10. visible: false
  11. },
  12. ToastParent: {
  13. default: null,
  14. type: cc.Node,
  15. serializable: true
  16. },
  17. //输入节点
  18. inputContainer: {
  19. default: null,
  20. type: cc.Node,
  21. serializable: true
  22. }
  23. },
  24. // LIFE-CYCLE CALLBACKS:
  25. // onLoad () {},
  26. start() {
  27. },
  28. onOpenInfo() {
  29. this.node.active = true;
  30. },
  31. //初始化时候需要初始化一次默认值
  32. onToggleInput(value, evnentData) {
  33. console.log(value.isChecked, evnentData);
  34. },
  35. inputLeaseValue(value, e) {
  36. var numberTemp = new RegExp("^[A-Za-z0-9]+$");
  37. if (numberTemp.test(value)) {
  38. this.inputInviteValue = Number(value);
  39. console.log(this.inputInviteValue);
  40. } else {
  41. this.inputInviteValue = '';
  42. this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
  43. console.log("请输入整数的倍数",this.inputInviteValue);
  44. // gameToast.getInstance().show(this.ToastParent, "请输入整数的倍数", 2, () => {
  45. // console.log("finish toast!");
  46. // }, this);
  47. }
  48. },
  49. onLeaseInfo() {
  50. console.log('inputInviteValue:' + this.inputInviteValue);
  51. if (!GlobalD.dapp) {
  52. console.error("onBindInviteInfo warn,dapp未初始化!");
  53. return;
  54. }
  55. let _self = this;
  56. // GlobalD.dapp.bindParent(_self.inputInviteValue).then((data) => {
  57. // if (data.err === null) {
  58. // // 返回成功,见下面消息体
  59. // console.log(data.res)
  60. // //绑定成功时候,隐藏输入框,设置父节点
  61. // GlobalD.Dapp.UserInfo.parent = data.res;
  62. // _self.parentInviteValue.string = GlobalD.Dapp.UserInfo.parent.invite_code;
  63. // //如果存在父节点,隐藏输入框
  64. // _self.inputContainer.active = false;
  65. // gameToast.getInstance().show(_self.ToastParent, "绑定成功!", 3, () => {
  66. // console.log("finish toast!");
  67. // }, _self);
  68. // } else {
  69. // //TODO 服务错误
  70. // console.log(data.err)
  71. // gameToast.getInstance().show(_self.ToastParent, "绑定失败!", 3, () => {
  72. // console.log("finish toast!");
  73. // }, _self);
  74. // }
  75. // })
  76. },
  77. onClose() {
  78. this.node.active = false;
  79. }
  80. });