|
|
@@ -69,7 +69,13 @@ cc.Class({
|
|
|
toast: null,
|
|
|
scheduleObj: null,
|
|
|
toastCallback: null,
|
|
|
- isStart: true
|
|
|
+ isStart: true,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 限制重复触发支付, 正在支付中转态,
|
|
|
+ */
|
|
|
+ isPayingCnt:false,
|
|
|
+ isPlayingSnb:false,
|
|
|
|
|
|
},
|
|
|
onLoad() {
|
|
|
@@ -1132,6 +1138,11 @@ cc.Class({
|
|
|
return;
|
|
|
}
|
|
|
//
|
|
|
+ if(this.isPlayingCnt){
|
|
|
+ console.warn("同时触发支付CNT过快!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isPlayingCnt = true;
|
|
|
if (GlobalD.GameData.GetCNT() < cntAmount) {
|
|
|
console.log("cnt 不足,GetCNT:" + GlobalD.GameData.GetCNT() + "消费的cntAmount" + cntAmount);
|
|
|
GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "CNT不足!", 2, () => {
|
|
|
@@ -1145,6 +1156,7 @@ cc.Class({
|
|
|
|
|
|
GlobalD.dapp.payCnt(cntAmount, payType, itemType).then((data) => {
|
|
|
const [err, tx] = data;
|
|
|
+ this.isPlayingCnt = false;
|
|
|
if (err === null) {
|
|
|
// TODO 成功, 支付为链上操作,需要提供回调接口给这边服务端确认交易成功后修改购买订单结果
|
|
|
console.log(tx) // 交易hash,唯一标识符
|
|
|
@@ -1183,6 +1195,12 @@ cc.Class({
|
|
|
console.warn("GlobalD.dapp未初始化,不能onSnbToCnt!");
|
|
|
return;
|
|
|
}
|
|
|
+ if(this.isPlayingSnb){
|
|
|
+ console.warn("同时触发支付SNB过快!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isPlayingSnb = true;
|
|
|
+
|
|
|
if (GlobalD.GameData.GetSNB() <= 0) {
|
|
|
console.log("神农呗数量GetSNB:", GlobalD.GameData.GetSNB(), "替换snbAmount:", snbAmount);
|
|
|
GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "神农呗数量不足!", 2, () => {
|
|
|
@@ -1193,6 +1211,7 @@ cc.Class({
|
|
|
|
|
|
GlobalD.dapp.snbToCnt(snbAmount).then((data) => {
|
|
|
const [err, tx] = data;
|
|
|
+ this.isPlayingSnb = false;
|
|
|
if (err === null) {
|
|
|
// TODO 成功, 兑换为链上操作,需要提供回调接口给这边服务端确认交易成功后修改扣除SNB数量
|
|
|
console.log(tx) // 交易hash,唯一标识符
|
|
|
@@ -1244,7 +1263,7 @@ cc.Class({
|
|
|
this.toast.active = false
|
|
|
if (this.toastCallback != null && this.toastCallback != undefined) {
|
|
|
this.toastCallback();
|
|
|
- console.log(this.toastCallback);
|
|
|
+ // console.log(this.toastCallback);
|
|
|
}
|
|
|
this.isStart = false;
|
|
|
} else {
|
|
|
@@ -1258,6 +1277,7 @@ cc.Class({
|
|
|
if (this.toast) {
|
|
|
this.toast.active = true;
|
|
|
this.toast.parent = parent;
|
|
|
+ this.toast.zIndex = 999;
|
|
|
let DetailLabel = this.toast.getChildByName('DetailLabel');
|
|
|
DetailLabel.getComponent(cc.Label).string = content;
|
|
|
this.toastEndTime = time;
|
|
|
@@ -1265,6 +1285,7 @@ cc.Class({
|
|
|
cc.loader.loadRes("prefab/gameToast", function (err, texture) {
|
|
|
this.toast = cc.instantiate(texture);
|
|
|
this.toast.parent = parent;
|
|
|
+ this.toast.zIndex = 999;
|
|
|
let DetailLabel = this.toast.getChildByName('DetailLabel');
|
|
|
DetailLabel.getComponent(cc.Label).string = content;
|
|
|
this.toastEndTime = time;
|