| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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) {
- gameToast.getInstance().show(cc.find('Canvas/UICamera'), "输入地址", 2, () => {
- console.log("finish toast!");
- }, this);
- 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;
- this.saleAmount.string = 0;
- gameToast.getInstance().show(cc.find('Canvas/UICamera'), value.msg, 2, () => {
- console.log("finish toast!");
- }, this);
- } else {
- gameToast.getInstance().show(cc.find('Canvas/UICamera'), value.msg, 2, () => {
- console.log("finish toast!");
- }, this);
- }
- });
- }
- });
|