LeaseGrantInfo.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
  75. BuildingView.onUpdateList();
  76. this.saleAmount.string = 0;
  77. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
  78. console.log("finish toast!");
  79. });
  80. } else {
  81. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
  82. console.log("finish toast!");
  83. });
  84. }
  85. });
  86. }
  87. });