Browse Source

存钱罐代码优化

薛鸿潇 5 years ago
parent
commit
97017540d8

+ 11 - 1
assets/script/game/data/GameData.ts

@@ -234,8 +234,18 @@ class PlayerProp {
         return this._piggyBank;
     }
 
+    _isWithdrawable = 0;
     /** 存钱罐能否提现 */
-    isWithdrawable = 0;
+    set isWithdrawable(value: number) {
+        if (this._isWithdrawable != value) {
+            this._isWithdrawable = value;
+            gData.pigbank.init_data = true;
+        }
+    }
+    get isWithdrawable(): number {
+        return this._isWithdrawable;
+    }
+
     /** 存钱罐每日提现次数 */
     piggyBankCashTimes = 0;
     /** 累计存钱罐每日提现次数 */

+ 1 - 14
assets/script/game/data/module/PigBankData.ts

@@ -16,23 +16,10 @@ export class PigBankData extends Data {
      * 数据初始化
      */
     public init() {
-        // 提现状态
-        this.cash_enable = gData.gameData.gameData.isWithdrawable;
     }
 
     /** 标志位:是否需要刷新数据 */
     public init_data: boolean = true;
-    /** 是否可提现 */
-    private _cash_enable: number = 0;
-    set cash_enable(bool: number) {
-        if (this._cash_enable != bool) {
-            this._cash_enable = bool;
-            this.init_data = true;
-        }
-    }
-    get cash_enable(): number {
-        return this._cash_enable;
-    }
 
     /** 提现最低限制 */
     public cash_min_limit: number = 0.3;
@@ -59,7 +46,7 @@ export class PigBankData extends Data {
         else if (response.CashMode == 1) {//公众号打款
 
         }
-        this.cash_enable = 0;
+        gData.gameData.gameData.isWithdrawable = 0;
         
     }
 }

+ 2 - 2
assets/script/game/module/pigBank/PigBank.ts

@@ -43,7 +43,7 @@ export default class PigBank extends cc.Component {
      * 提现描述展示
      */
     private initCashDesc() {
-        if (gData.pigbank.cash_enable) {
+        if (gData.gameData.gameData.isWithdrawable) {
             this.lbl_get_desc.string = '直接提现';
             this.node_tip_anim.active = false;
             this.anim_btn_cash.play();
@@ -74,7 +74,7 @@ export default class PigBank extends cc.Component {
      */
     private clickCashOP() {
         mk.audio.playEffect("button");
-        if (!gData.pigbank.cash_enable) {
+        if (!gData.gameData.gameData.isWithdrawable) {
             mk.tip.pop('明日可提现')
             return;
         } else if (gData.gameData.gameData.piggyBank < gData.pigbank.cash_min_limit) {