Prechádzať zdrojové kódy

常规提现调整,可提现状态:判断用户红包币到底够几个提现档次

薛鸿潇 5 rokov pred
rodič
commit
54b2e76f43

+ 44 - 3
assets/script/game/data/module/RedBagCashData.ts

@@ -1,7 +1,7 @@
 
 
 import { Data } from "../../../mk/data/Data";
 import { Data } from "../../../mk/data/Data";
 import JsbSystem from "../../../mk/system/JsbSystem";
 import JsbSystem from "../../../mk/system/JsbSystem";
-import { GameProp } from "../GameData";
+import { GameProp, RewardState } from "../GameData";
 /**
 /**
  * 红包提现数据
  * 红包提现数据
  * - 跨Index不可提现,提示:请按顺序提现。
  * - 跨Index不可提现,提示:请按顺序提现。
@@ -26,6 +26,7 @@ export class RedBagCashData extends Data {
             });
             });
             this.c_data = gData.gameData.configs.CashCfg;
             this.c_data = gData.gameData.configs.CashCfg;
             this.sortList();
             this.sortList();
+            this.initState();
             this.init_list = true;
             this.init_list = true;
         }
         }
     }
     }
@@ -81,6 +82,7 @@ export class RedBagCashData extends Data {
         mk.ui.openPanel('module/receiptNotice/receiptNotice');
         mk.ui.openPanel('module/receiptNotice/receiptNotice');
 
 
         this.sortList();
         this.sortList();
+        this.initState();
         gData.cashNormal.getRecord();// 请求新的提现记录
         gData.cashNormal.getRecord();// 请求新的提现记录
 
 
     }
     }
@@ -102,6 +104,42 @@ export class RedBagCashData extends Data {
         }
         }
     }
     }
 
 
+    /**
+     * 初始化状态
+     */
+    public initState() {
+        let total = gData.gameData.gameData.redMoney + 0;
+        const l_count = this.c_data.length;
+        for (let i = 0; i < l_count; i++) {
+            // 已提现
+            if (this.c_data[i].index < gData.redBagCash.cash_bar) {
+                this.c_data[i].state = RewardState.none;
+            } else {
+                total = this.itemAllowCash(total, this.c_data[i].type_value);
+                if (total > 0) {
+                    this.c_data[i].state = RewardState.unlock;
+                } else {
+                    this.c_data[i].state = RewardState.lock;
+                }
+            }
+        }
+    }
+
+    /**
+     * 当前红包币足够提现多少条
+     * @param total 兑换后的红包币数量,逐条递减
+     * @param type_value 条目要求的红包币数量
+     * @returns 
+     */
+    private itemAllowCash(total: number, type_value: number): number {
+        if (total >= type_value) {
+            total -= type_value;
+            return total;
+        } else {
+            return 0;
+        }
+    }
+
 
 
     /**
     /**
      * 获取条目,通过index
      * 获取条目,通过index
@@ -133,7 +171,8 @@ export class RedBagCashData extends Data {
                 money_type: id,
                 money_type: id,
                 num: id,
                 num: id,
                 moneyshow: id,
                 moneyshow: id,
-                summoney: id
+                summoney: id,
+                state: 1
             };
             };
             this.c_data.push(obj)
             this.c_data.push(obj)
         }
         }
@@ -167,6 +206,8 @@ export type CDataType = {
     money_type: number,
     money_type: number,
     num: number,
     num: number,
     moneyshow: number,
     moneyshow: number,
-    summoney: number
+    summoney: number,
+    /** 提现状态 - 客户端加 */
+    state: number,
 }
 }
 
 

+ 1 - 0
assets/script/game/module/redBagCash/RedBagCash.ts

@@ -26,6 +26,7 @@ export default class RedBagCash extends cc.Component {
 
 
     start() {
     start() {
         gData.redBagCash.init_list = true;
         gData.redBagCash.init_list = true;
+        gData.redBagCash.initState();
         // this.initMoney();
         // this.initMoney();
         // this.initScrollView();
         // this.initScrollView();
     }
     }

+ 12 - 13
assets/script/game/module/redBagCash/RedBagCashItem.ts

@@ -1,3 +1,4 @@
+import { RewardState } from "../../data/GameData";
 import { CDataType } from "../../data/module/RedBagCashData";
 import { CDataType } from "../../data/module/RedBagCashData";
 
 
 const { ccclass, property } = cc._decorator;
 const { ccclass, property } = cc._decorator;
@@ -48,23 +49,21 @@ export default class RedBagCashItem extends cc.Component {
         rmb_value = rmb_value > 1 ? rmb_value : parseFloat(rmb_value.toFixed(2))
         rmb_value = rmb_value > 1 ? rmb_value : parseFloat(rmb_value.toFixed(2))
         this.lbl_rmb_value.string = rmb_value + '元';
         this.lbl_rmb_value.string = rmb_value + '元';
 
 
-        if (this.item_data.index < gData.redBagCash.cash_bar) {
+        if (this.item_data.state === RewardState.none) {
             // 已提现
             // 已提现
             this.node_none.active = true;
             this.node_none.active = true;
             this.node_lock.active = false;
             this.node_lock.active = false;
             this.node_unlock.active = false;
             this.node_unlock.active = false;
-        } else {
-            // 可提现
-            if (gData.gameData.gameData.redMoney >= this.item_data.type_value) {
-                this.node_none.active = false;
-                this.node_lock.active = false;
-                this.node_unlock.active = true;
-            } else {
-                // 未达成
-                this.node_none.active = false;
-                this.node_lock.active = true;
-                this.node_unlock.active = false;
-            }
+        } else if (this.item_data.state === RewardState.lock) {
+            // 未达成
+            this.node_none.active = false;
+            this.node_lock.active = true;
+            this.node_unlock.active = false;
+        } else if (this.item_data.state === RewardState.unlock) {
+            // 已解锁
+            this.node_none.active = false;
+            this.node_lock.active = false;
+            this.node_unlock.active = true;
         }
         }
     }
     }