|
@@ -8,7 +8,22 @@ cc.Class({
|
|
|
properties: {
|
|
properties: {
|
|
|
|
|
|
|
|
inputInviteValue: {
|
|
inputInviteValue: {
|
|
|
- default: '',
|
|
|
|
|
|
|
+ default: 1,
|
|
|
|
|
+ visible: false
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ //1 对应3个月,2对应1年,3对应5年
|
|
|
|
|
+ toggleInputValue: {
|
|
|
|
|
+ default: '1',
|
|
|
|
|
+ visible: false
|
|
|
|
|
+ },
|
|
|
|
|
+ totalPriceLabel: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Label,
|
|
|
|
|
+ serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+ totalPriceValue: {
|
|
|
|
|
+ default: 0,
|
|
|
visible: false
|
|
visible: false
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -22,6 +37,38 @@ cc.Class({
|
|
|
default: null,
|
|
default: null,
|
|
|
type: cc.Node,
|
|
type: cc.Node,
|
|
|
serializable: true
|
|
serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggle1: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Toggle,
|
|
|
|
|
+ serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggle2: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Toggle,
|
|
|
|
|
+ serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ toggle3: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Toggle,
|
|
|
|
|
+ serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ //这个显示的时候,拦截输入
|
|
|
|
|
+ blockInput: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Node,
|
|
|
|
|
+ serializable: true
|
|
|
|
|
+ },
|
|
|
|
|
+ leaseFarmlandInfoNode: {
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ type: cc.Node,
|
|
|
|
|
+ serializable: true,
|
|
|
|
|
+ visible:false,
|
|
|
|
|
+ toolTip:"操作的土地对象,初始化时候传入"
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -29,9 +76,9 @@ cc.Class({
|
|
|
|
|
|
|
|
// onLoad () {},
|
|
// onLoad () {},
|
|
|
|
|
|
|
|
- start() {
|
|
|
|
|
|
|
+ // start() {
|
|
|
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // },
|
|
|
|
|
|
|
|
onOpenInfo() {
|
|
onOpenInfo() {
|
|
|
this.node.active = true;
|
|
this.node.active = true;
|
|
@@ -40,33 +87,91 @@ cc.Class({
|
|
|
|
|
|
|
|
//初始化时候需要初始化一次默认值
|
|
//初始化时候需要初始化一次默认值
|
|
|
onToggleInput(value, evnentData) {
|
|
onToggleInput(value, evnentData) {
|
|
|
- console.log(value.isChecked, evnentData);
|
|
|
|
|
|
|
+ // console.log(value.isChecked, evnentData);
|
|
|
|
|
+ this.toggleInputValue = evnentData;
|
|
|
|
|
+ this._updatePrice();
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
inputLeaseValue(value, e) {
|
|
inputLeaseValue(value, e) {
|
|
|
|
|
|
|
|
var numberTemp = new RegExp("^[A-Za-z0-9]+$");
|
|
var numberTemp = new RegExp("^[A-Za-z0-9]+$");
|
|
|
if (numberTemp.test(value)) {
|
|
if (numberTemp.test(value)) {
|
|
|
- this.inputInviteValue = Number(value);
|
|
|
|
|
- console.log(this.inputInviteValue);
|
|
|
|
|
|
|
+ if(Number(value)>=1){
|
|
|
|
|
+ this.inputInviteValue = Number(value);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.inputInviteValue = 1;
|
|
|
|
|
+ this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- this.inputInviteValue = '';
|
|
|
|
|
|
|
+ this.inputInviteValue = 1;
|
|
|
this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
|
- console.log("请输入整数的倍数",this.inputInviteValue);
|
|
|
|
|
|
|
+ console.log("请输入整数的倍数", this.inputInviteValue);
|
|
|
// gameToast.getInstance().show(this.ToastParent, "请输入整数的倍数", 2, () => {
|
|
// gameToast.getInstance().show(this.ToastParent, "请输入整数的倍数", 2, () => {
|
|
|
// console.log("finish toast!");
|
|
// console.log("finish toast!");
|
|
|
// }, this);
|
|
// }, this);
|
|
|
}
|
|
}
|
|
|
|
|
+ this._updatePrice();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ _updatePrice() {
|
|
|
|
|
+ //this.inputInviteValue 默认是1倍
|
|
|
|
|
+ // console.log( this.inputInviteValue);
|
|
|
|
|
+ switch (this.toggleInputValue) {
|
|
|
|
|
+ case "1":
|
|
|
|
|
+ this.totalPriceValue = 700 * this.inputInviteValue;
|
|
|
|
|
+ this.totalPriceLabel.string = this.totalPriceValue + "CNT";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "2":
|
|
|
|
|
+ this.totalPriceValue = 2500 * this.inputInviteValue;
|
|
|
|
|
+ this.totalPriceLabel.string = this.totalPriceValue + "CNT";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "3":
|
|
|
|
|
+ this.totalPriceValue = 5000 * this.inputInviteValue;
|
|
|
|
|
+ this.totalPriceLabel.string = this.totalPriceValue + "CNT";
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ console.error("this.toggleInputValue 不是1 2 3!", this.toggleInputValue);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 显示面板时候,设置一下初始化数据
|
|
|
|
|
+ */
|
|
|
|
|
+ onInitLeaseInfo(multiple){
|
|
|
|
|
+ //这里处理倍数
|
|
|
|
|
+ this.inputInviteValue = multiple;
|
|
|
|
|
+ this.inputContainer.getComponent(cc.EditBox).string = this.inputInviteValue;
|
|
|
|
|
+ this._updatePrice();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ //租赁支付
|
|
|
onLeaseInfo() {
|
|
onLeaseInfo() {
|
|
|
- console.log('inputInviteValue:' + this.inputInviteValue);
|
|
|
|
|
|
|
+ console.log('支付总额:' + this.totalPriceValue);
|
|
|
if (!GlobalD.dapp) {
|
|
if (!GlobalD.dapp) {
|
|
|
console.error("onBindInviteInfo warn,dapp未初始化!");
|
|
console.error("onBindInviteInfo warn,dapp未初始化!");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
let _self = this;
|
|
let _self = this;
|
|
|
|
|
+ //cntAmount,payType,itemType,callback
|
|
|
|
|
+ Global.game.payCNT(this.totalPriceValue, 1, this.toggleInputValue, (data) => {
|
|
|
|
|
+ console.log("土地支付", this.totalPriceValue, "==", 1, "==", this.toggleInputValue);
|
|
|
|
|
+ console.log("支付data:", data);
|
|
|
|
|
+ gameToast.getInstance().show(this.ToastParent, "支付成功!", 3, () => {
|
|
|
|
|
+ console.log("finish toast!");
|
|
|
|
|
+ }, this);
|
|
|
|
|
+ if (err === null) {
|
|
|
|
|
+ // TODO 成功, 支付为链上操作,需要提供回调接口给这边服务端确认交易成功后修改购买订单结果
|
|
|
|
|
+ console.log(tx) // 交易hash,唯一标识符
|
|
|
|
|
+
|
|
|
|
|
+ //解锁土地操作
|
|
|
|
|
+ this.leaseFarmlandInfoNode.getComponent("LeaseFarmlandInfo").onUnlockLand();
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
// GlobalD.dapp.bindParent(_self.inputInviteValue).then((data) => {
|
|
// GlobalD.dapp.bindParent(_self.inputInviteValue).then((data) => {
|
|
|
// if (data.err === null) {
|
|
// if (data.err === null) {
|
|
|
// // 返回成功,见下面消息体
|
|
// // 返回成功,见下面消息体
|
|
@@ -77,9 +182,7 @@ cc.Class({
|
|
|
// //如果存在父节点,隐藏输入框
|
|
// //如果存在父节点,隐藏输入框
|
|
|
// _self.inputContainer.active = false;
|
|
// _self.inputContainer.active = false;
|
|
|
|
|
|
|
|
- // gameToast.getInstance().show(_self.ToastParent, "绑定成功!", 3, () => {
|
|
|
|
|
- // console.log("finish toast!");
|
|
|
|
|
- // }, _self);
|
|
|
|
|
|
|
+
|
|
|
// } else {
|
|
// } else {
|
|
|
// //TODO 服务错误
|
|
// //TODO 服务错误
|
|
|
// console.log(data.err)
|
|
// console.log(data.err)
|
|
@@ -91,8 +194,8 @@ cc.Class({
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onClose() {
|
|
onClose() {
|
|
|
- this.node.active = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.node.destroy();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
|
|
|
});
|
|
});
|