| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import gameToast from "../Network/gameToast"
- cc.Class({
- extends: cc.Component,
- properties: {
- grantName: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- amount: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //介绍
- describe: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- inputInviteValue: {
- default: 1,
- visible: false
- },
- //当前操作的果实信息
- fruitInfo: {
- default: null,
- serializable: true,
- visible: false
- },
- upTarget: {
- default: null,
- type: cc.Node,
- tooltip: "把当前操作的ui按钮传进来"
- },
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start() {
- },
- /**
- * 赠送
- */
- onGrant() {
- },
- setInfo(grantName, amount) {
- this.grantName.string = grantName;
- this.amount.string = amount;
- },
- inputValue(value, e) {
- this.inputInviteValue = value;
- },
- onclose() {
- this.node.destroy();
- },
- //确定增送果实
- onLeaseGrantFruit() {
- //todo 判断一下amount
- console.log(this.inputInviteValue);
- if (this.inputInviteValue.length < 20) {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), "输入地址", 2, () => {
- console.log("finish toast!");
- });
- return;
- }
- //默认赠送全部
- GlobalD.GameData.onGrantFruit({ fruitId: this.fruitInfo.id, amount: Number(this.amount.string), address: this.inputInviteValue }, (res, value) => {
- // console.log(value);
- if (value.code === 0) {
- // let NumLabel = this.upTarget.getComponent("Content_Button").NumLabel.getComponent(cc.Label);
- //这里只隐藏
- // this.upTarget.active = false;
- // NumLabel.string = 0;
- var BuildingView = cc.find("Canvas/UICamera/BuildingContainer/BuildingView").getComponent("BuildingView");
- BuildingView.onUpdateList();
- this.saleAmount.string = 0;
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
- console.log("finish toast!");
- });
- } else {
- GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 2, () => {
- console.log("finish toast!");
- });
- }
- });
- }
- });
|