瀏覽代碼

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework

kaka 5 年之前
父節點
當前提交
bf6fef7912

+ 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,
 }
 }
 
 

+ 3 - 3
assets/script/game/game/Game.ts

@@ -70,7 +70,7 @@ export default class Game extends cc.Component {
         this.autoOpenPanel();
         this.autoOpenPanel();
         this.runGuideWeak();
         this.runGuideWeak();
 
 
-        mk.guide.open(1);
+        // mk.guide.open(1);
         // // 测试代码
         // // 测试代码
         // this.schedule(() => {
         // this.schedule(() => {
 
 
@@ -146,13 +146,13 @@ export default class Game extends cc.Component {
     }
     }
 
 
     private changeInfo() {
     private changeInfo() {
-        this.lbl_redMoney.node.getComponent(mk.component.NumberAnim).setValue(gData.gameData.gameData.redMoney);
+        this.lbl_redMoney.node.getComponent(mk.component.numberAnim).setValue(gData.gameData.gameData.redMoney);
         // this.lbl_rmb.node.getComponent('NumberAnim').setValue(gData.gameData.gameData.piggyBank);
         // this.lbl_rmb.node.getComponent('NumberAnim').setValue(gData.gameData.gameData.piggyBank);
 
 
         const new_count = gData.gameData.gameData.piggyBank / 100;
         const new_count = gData.gameData.gameData.piggyBank / 100;
         if (parseInt(this.lbl_rmb.string) == 0 && new_count != 0 || parseInt(this.lbl_rmb.string) != 0 && new_count == 0) {
         if (parseInt(this.lbl_rmb.string) == 0 && new_count != 0 || parseInt(this.lbl_rmb.string) != 0 && new_count == 0) {
             if (this.lbl_rmb.string != new_count.toFixed(2)) {
             if (this.lbl_rmb.string != new_count.toFixed(2)) {
-                this.lbl_rmb.node.getComponent(mk.component.NumberAnim).setValue(parseFloat(new_count.toFixed(2)), 2);
+                this.lbl_rmb.node.getComponent(mk.component.numberAnim).setValue(parseFloat(new_count.toFixed(2)), 2);
             }
             }
         }
         }
         gData.gameData.init_coin = false;
         gData.gameData.init_coin = false;

+ 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;
         }
         }
     }
     }
 
 

+ 2 - 2
assets/script/game/module/sign/Sign.ts

@@ -109,12 +109,12 @@ export default class Sign extends cc.Component {
         if (gData.gameData.gameData.isSignInToday == 0 && gData.sign.haveSignDay()) {
         if (gData.gameData.gameData.isSignInToday == 0 && gData.sign.haveSignDay()) {
             this.anim_btn.play();
             this.anim_btn.play();
             // this.anim_btn.getComponent(SetGray).setGray(false);
             // this.anim_btn.getComponent(SetGray).setGray(false);
-            this.anim_btn.getComponent(mk.component.SetGray).setGray(false)
+            this.anim_btn.getComponent(mk.component.setGray).setGray(false)
         } else {
         } else {
             this.anim_btn.stop();
             this.anim_btn.stop();
             this.anim_btn.node.scale = 1;
             this.anim_btn.node.scale = 1;
             // this.anim_btn.getComponent('SetGray').setGray(true);
             // this.anim_btn.getComponent('SetGray').setGray(true);
-            this.anim_btn.getComponent(mk.component.SetGray).setGray(true)
+            this.anim_btn.getComponent(mk.component.setGray).setGray(true)
         }
         }
         gData.sign.init_data = false;
         gData.sign.init_data = false;
     }
     }

+ 2 - 2
assets/script/mk/system/MKSystem.ts

@@ -158,11 +158,11 @@ class MKSystem {
  */
  */
 class comp_type {
 class comp_type {
     /** 置灰组件 */
     /** 置灰组件 */
-    get SetGray() {
+    get setGray() {
         return SetGray;
         return SetGray;
     }
     }
     /** 置灰组件 */
     /** 置灰组件 */
-    get NumberAnim() {
+    get numberAnim() {
         return NumberAnim;
         return NumberAnim;
     }
     }
 }
 }