LeaseGrantInfo.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import gameToast from "../Network/gameToast"
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. grantName: {
  6. default: null,
  7. type: cc.Label,
  8. serializable: true,
  9. },
  10. amount: {
  11. default: null,
  12. type: cc.Label,
  13. serializable: true,
  14. },
  15. //介绍
  16. describe: {
  17. default: null,
  18. type: cc.Label,
  19. serializable: true,
  20. },
  21. inputInviteValue: {
  22. default: 1,
  23. visible: false
  24. },
  25. //当前操作的果实信息
  26. fruitInfo: {
  27. default: null,
  28. serializable: true,
  29. visible: false
  30. },
  31. upTarget: {
  32. default: null,
  33. type: cc.Node,
  34. tooltip: "把当前操作的ui按钮传进来"
  35. },
  36. },
  37. // LIFE-CYCLE CALLBACKS:
  38. // onLoad () {},
  39. start() {
  40. },
  41. /**
  42. * 赠送
  43. */
  44. onGrant() {
  45. },
  46. setInfo(grantName, amount) {
  47. this.grantName.string = grantName;
  48. this.amount.string = amount;
  49. },
  50. inputValue(value, e) {
  51. this.inputInviteValue = value;
  52. },
  53. onclose() {
  54. this.node.destroy();
  55. },
  56. //确定销售果实
  57. onLeaseGrantFruit() {
  58. //todo 判断一下amount
  59. console.log(this.inputInviteValue);
  60. if (this.inputInviteValue.length < 20) {
  61. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "输入地址", 2, () => {
  62. console.log("finish toast!");
  63. });
  64. return;
  65. }
  66. //默认赠送全部
  67. GlobalD.GameData.onGrantFruit({ fruitId: this.fruitInfo.id, amount: Number(this.amount.string), address: this.inputInviteValue }, (res, value) => {
  68. // console.log(value);
  69. if (value.code === 0) {
  70. let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
  71. //这里只隐藏
  72. this.upTarget.active = false;
  73. NumLabel.string = 0;
  74. this.saleAmount.string = 0;
  75. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
  76. console.log("finish toast!");
  77. });
  78. } else {
  79. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
  80. console.log("finish toast!");
  81. });
  82. }
  83. });
  84. }
  85. });