|
|
@@ -1,34 +1,34 @@
|
|
|
-
|
|
|
+import gameToast from "../Network/gameToast"
|
|
|
cc.Class({
|
|
|
extends: cc.Component,
|
|
|
|
|
|
properties: {
|
|
|
- grantName: {
|
|
|
- default: null,
|
|
|
- type: cc.Label,
|
|
|
- serializable: true,
|
|
|
+ grantName: {
|
|
|
+ default: null,
|
|
|
+ type: cc.Label,
|
|
|
+ serializable: true,
|
|
|
},
|
|
|
amount: {
|
|
|
- default: null,
|
|
|
- type: cc.Label,
|
|
|
- serializable: true,
|
|
|
+ default: null,
|
|
|
+ type: cc.Label,
|
|
|
+ serializable: true,
|
|
|
},
|
|
|
//介绍
|
|
|
describe: {
|
|
|
- default: null,
|
|
|
- type: cc.Label,
|
|
|
- serializable: true,
|
|
|
+ default: null,
|
|
|
+ type: cc.Label,
|
|
|
+ serializable: true,
|
|
|
},
|
|
|
inputInviteValue: {
|
|
|
default: 1,
|
|
|
visible: false
|
|
|
},
|
|
|
|
|
|
- //当前操作的果实信息
|
|
|
- fruitInfo:{
|
|
|
+ //当前操作的果实信息
|
|
|
+ fruitInfo: {
|
|
|
default: null,
|
|
|
- serializable: true,
|
|
|
- visible:false
|
|
|
+ serializable: true,
|
|
|
+ visible: false
|
|
|
},
|
|
|
upTarget: {
|
|
|
default: null,
|
|
|
@@ -41,39 +41,58 @@ cc.Class({
|
|
|
|
|
|
// onLoad () {},
|
|
|
|
|
|
- start () {
|
|
|
+ start() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 赠送
|
|
|
*/
|
|
|
- onGrant(){
|
|
|
+ onGrant() {
|
|
|
|
|
|
},
|
|
|
|
|
|
- setInfo(grantName,amount){
|
|
|
+ setInfo(grantName, amount) {
|
|
|
this.grantName.string = grantName;
|
|
|
this.amount.string = amount;
|
|
|
},
|
|
|
|
|
|
inputValue(value, e) {
|
|
|
-
|
|
|
- var numberTemp = new RegExp("^[A-Za-z0-9]+$");
|
|
|
- if (numberTemp.test(value)) {
|
|
|
- if(Number(value)>=1){
|
|
|
- this.inputInviteValue = Number(value);
|
|
|
- }else{
|
|
|
- this.inputInviteValue = 1;
|
|
|
- this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.inputInviteValue = 1;
|
|
|
- this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
|
- console.log("请输入整数的倍数", this.inputInviteValue);
|
|
|
- }
|
|
|
+ this.inputInviteValue = value;
|
|
|
},
|
|
|
- onclose(){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
});
|