|
|
@@ -58,6 +58,10 @@ cc.Class({
|
|
|
default: null,
|
|
|
type: cc.Node,
|
|
|
},
|
|
|
+ PaySNBPopView: {
|
|
|
+ default: null,
|
|
|
+ type: cc.Node,
|
|
|
+ },
|
|
|
buySeedIndex: -1,
|
|
|
|
|
|
snbAmountLabel: {
|
|
|
@@ -225,6 +229,14 @@ cc.Class({
|
|
|
this.PayCNTPopView.getChildByName("BG").getChildByName("BG1_sprite_splash").getChildByName("PriceLabel").getChildByName("label").getComponent(cc.Label).string = this.mySeedList[this.buySeedIndex].priceCnt + ' CNT';
|
|
|
this.PayCNTPopView.getChildByName("BG").getChildByName("BG1_sprite_splash").getChildByName("MutureDurLabel").getChildByName("label").getComponent(cc.Label).string = this.mySeedList[this.buySeedIndex].maturity;
|
|
|
},
|
|
|
+ onPaySNBPopView(myIndex) {
|
|
|
+ this.buySeedIndex = myIndex;
|
|
|
+ this.PaySNBPopView.active = true;
|
|
|
+ // console.log('this.mySeedList[this.buySeedIndex] =',this.mySeedList[this.buySeedIndex])
|
|
|
+ this.PaySNBPopView.getChildByName("BG").getChildByName("BG1_sprite_splash").getChildByName("NameLabel").getChildByName("label").getComponent(cc.Label).string = this.mySeedList[this.buySeedIndex].name;
|
|
|
+ this.PaySNBPopView.getChildByName("BG").getChildByName("BG1_sprite_splash").getChildByName("PriceLabel").getChildByName("label").getComponent(cc.Label).string = this.mySeedList[this.buySeedIndex].priceCnt + ' SNB';
|
|
|
+ this.PaySNBPopView.getChildByName("BG").getChildByName("BG1_sprite_splash").getChildByName("MutureDurLabel").getChildByName("label").getComponent(cc.Label).string = this.mySeedList[this.buySeedIndex].maturity;
|
|
|
+ },
|
|
|
PayCNT() {
|
|
|
console.log('this.cntAmount=', this.cntAmount)
|
|
|
console.log('this.cntAmount price=', this.cntAmount * parseInt(this.mySeedList[this.buySeedIndex].priceCnt))
|
|
|
@@ -283,34 +295,45 @@ cc.Class({
|
|
|
|
|
|
});
|
|
|
},
|
|
|
- //onEditDidBegan: function(editbox, customEventData) {
|
|
|
- // // 这里 editbox 是一个 cc.EditBox 对象
|
|
|
- // // 这里的 customEventData 参数就等于你之前设置的 "foobar"
|
|
|
- //},
|
|
|
- //// 假设这个回调是给 editingDidEnded 事件的
|
|
|
- //onEditDidEnded: function(editbox, customEventData) {
|
|
|
- // // 这里 editbox 是一个 cc.EditBox 对象
|
|
|
- // // 这里的 customEventData 参数就等于你之前设置的 "foobar"
|
|
|
- //},
|
|
|
- //// 假设这个回调是给 textChanged 事件的
|
|
|
- //onTextChanged: function(text, editbox, customEventData) {
|
|
|
- // // 这里的 text 表示 修改完后的 EditBox 的文本内容
|
|
|
- // // 这里 editbox 是一个 cc.EditBox 对象
|
|
|
- // // 这里的 customEventData 参数就等于你之前设置的 "foobar"
|
|
|
- // this.snbAmount = parseInt(text);
|
|
|
- //},
|
|
|
- //// 假设这个回调是给 editingReturn 事件的
|
|
|
- //onEditingReturn: function(editbox, customEventData) {
|
|
|
- // // 这里 editbox 是一个 cc.EditBox 对象
|
|
|
- // // 这里的 customEventData 参数就等于你之前设置的 "foobar"
|
|
|
- //}
|
|
|
- // 假设这个回调是给 textChanged 事件的
|
|
|
+ PaySNB() {
|
|
|
+ console.log('this.snbAmount=', this.cntAmount)
|
|
|
+ console.log('priceSnb price=', this.mySeedList[this.buySeedIndex].priceSnb)
|
|
|
+ console.log('this.snbAmount price=', this.cntAmount * parseInt(this.mySeedList[this.buySeedIndex].priceSnb))
|
|
|
+
|
|
|
+ //购买种子也要使用轮询
|
|
|
+
|
|
|
+ let currentAmount = 0;
|
|
|
+
|
|
|
+ for (let i = 0; i < this.myWareHouseSeedList.length; i++) {
|
|
|
+ if (this.myWareHouseSeedList[i].id == this.mySeedList[this.buySeedIndex].id) {
|
|
|
+ currentAmount = this.myWareHouseSeedList[i].amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //当前背包的数量
|
|
|
+ console.log("currentAmount:", {
|
|
|
+ seedId: this.mySeedList[this.buySeedIndex].id,
|
|
|
+ currentAmount: currentAmount //把当前背包的数据传进去
|
|
|
+ });
|
|
|
+
|
|
|
+ GlobalD.GameData.onBuySeedsWithSNB(this.cntAmount * parseInt(this.mySeedList[this.buySeedIndex].priceSnb), this.mySeedList[this.buySeedIndex].id, (res, value) => {
|
|
|
+ if (0 === value.code)
|
|
|
+ {
|
|
|
+ // TODO 成功, 支付为链上操作,需要提供回调接口给这边服务端确认交易成功后修改购买订单结果
|
|
|
+ console.log('snb res =====',res) // 交易hash,唯一标识符
|
|
|
+ console.log('snb value =====',value) // 交易hash,唯一标识符
|
|
|
+ //todo 种子
|
|
|
+ GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "种子购买成功!", 5);
|
|
|
+ this.PaySNBPopView.active = false;
|
|
|
+ //直接重新初始化一下列表,
|
|
|
+ this.buildingViewScript.onUpdateList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
onTextChanged1: function (text, editbox, customEventData) {
|
|
|
// 这里的 text 表示 修改完后的 EditBox 的文本内容
|
|
|
// 这里 editbox 是一个 cc.EditBox 对象
|
|
|
// 这里的 customEventData 参数就等于你之前设置的 "foobar"
|
|
|
this.cntAmount = parseInt(text);
|
|
|
-
|
|
|
},
|
|
|
// 假设这个回调是给 textChanged 事件的
|
|
|
onTextChanged2: function (text, editbox, customEventData) {
|