LeaseGrantInfo.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. if(GlobalD.GameData.isOnGrantFruit)return;
  67. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "赠送果实中...", 5);
  68. //默认赠送全部
  69. GlobalD.GameData.onGrantFruit({ fruitId: this.fruitInfo.id, amount: Number(this.amount.string), address: this.inputInviteValue }, (res, value) => {
  70. // console.log(value);
  71. if (value.code === 0) {
  72. // let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
  73. //这里只隐藏
  74. // this.upTarget.active = false;
  75. // NumLabel.string = 0;
  76. var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
  77. BuildingView.onUpdateList();
  78. this.amount.string = 0;
  79. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 1);
  80. } else {
  81. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 1);
  82. }
  83. });
  84. }
  85. });