|
|
@@ -92,6 +92,7 @@ cc.Class({
|
|
|
isOnAddFruit: false,
|
|
|
isOnSaleFruit: false,
|
|
|
isOnGrantFruit: false,
|
|
|
+ isExchangeSeed: false,
|
|
|
|
|
|
//自动存储数据
|
|
|
AutoSaveData: null
|
|
|
@@ -556,23 +557,29 @@ cc.Class({
|
|
|
GetDiamond: function () {
|
|
|
return parseInt(this.Diamond);
|
|
|
},
|
|
|
- SetDiamond: function (num) {
|
|
|
+ SetDiamond: function (num, bPush) {
|
|
|
let LastMoney = this.Diamond;
|
|
|
this.Diamond = num;
|
|
|
let CurrentMoney = num;
|
|
|
-
|
|
|
+
|
|
|
this.ManageUI.getComponent("ManageUI").DiamondNowlabel.string = this.Diamond + '/30000'
|
|
|
|
|
|
this.ManageUI.getComponent('ManageUI').DiamondChangeCallBack(this.GetDiamond(), LastMoney, CurrentMoney);
|
|
|
|
|
|
+ console.log("Diamond:", bPush);
|
|
|
+ if (bPush) {
|
|
|
+ //每次砖石操作。更新一次数据
|
|
|
+ this.pushData(true);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
},
|
|
|
PlusDiamond: function (num) {
|
|
|
if (this.Diamond + num < 0) {
|
|
|
- this.SetDiamond(0);
|
|
|
+ this.SetDiamond(0, true);
|
|
|
}
|
|
|
else {
|
|
|
- this.SetDiamond(this.Diamond + num);
|
|
|
+ this.SetDiamond(this.Diamond + num, true);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -957,7 +964,7 @@ cc.Class({
|
|
|
|
|
|
/** 推送信息 */
|
|
|
utils.post(utils.api.playerPushInfo, data, (res, playerPushInfoTemp) => {
|
|
|
- // console.log('playerPushInfoTemp', playerPushInfoTemp);
|
|
|
+ // console.log('playerPushInfoTemp');
|
|
|
})
|
|
|
} else {
|
|
|
console.log("存储本地:" + isNetwork);
|
|
|
@@ -973,6 +980,11 @@ cc.Class({
|
|
|
* 扣除相应的钻石
|
|
|
*/
|
|
|
exchangeSeed(diamondAmount, callback) {
|
|
|
+ if (this.isExchangeSeed) {
|
|
|
+ console.warn("正在兑换中...");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isExchangeSeed = true;
|
|
|
//先暂停存储
|
|
|
this.unschedule(this.AutoSaveData);
|
|
|
|
|
|
@@ -984,10 +996,11 @@ cc.Class({
|
|
|
let _playerData = JSON.parse(value.data.playerData);
|
|
|
console.log("兑换后的钻石:", _playerData.Diamond);
|
|
|
//更新本地钻石数据
|
|
|
- this.SetDiamond(_playerData.Diamond);
|
|
|
+ this.SetDiamond(_playerData.Diamond, false);
|
|
|
|
|
|
}
|
|
|
callback(res, value);
|
|
|
+ this.isExchangeSeed = false;
|
|
|
//重新开启存储
|
|
|
this.schedule(this.AutoSaveData, 15);
|
|
|
})
|