Przeglądaj źródła

提取存钱罐接口对接

薛鸿潇 5 lat temu
rodzic
commit
3421350e6a

+ 2 - 1
tower_sanguo/assets/scripts/data/GameData.ts

@@ -605,7 +605,8 @@ export default class GameData {
         this.player.setProp(PLAYERPROP.TASK_REDBAG_COUNT, data.taskRedBag);
         this.player.setProp(PLAYERPROP.USER_DAILY_ACTIVE_S_INFO, data.dailyTask);
         this.player.setProp(PLAYERPROP.USER_EXCHANGE_TIMES, data.userExchangeTimes);
-
+        this.player.setProp(PLAYERPROP.PIGGYBOX_DATA, data.piggyBox);
+        
         // this.player.setProp(PLAYERPROP.GENERAL_TRAIN_TIMES, data.general_train_times);
         // this.player.setProp(PLAYERPROP.INVEST_TIMES, data.invest_times);
         // this.player.setProp(PLAYERPROP.GENERAL_LUCK_TIMES, data.general_luck_times);

+ 3 - 1
tower_sanguo/assets/scripts/data/GameDefinition.ts

@@ -57,8 +57,10 @@ export enum PLAYERPROP {
 
     /**剩余红包兑换元宝次数*/
     USER_EXCHANGE_TIMES = 34,
-    /** 领取粮草模块数据 */
+    /** 领取粮草模块数据 35*/
     GET_FOOD_DATA = 35,
+    /** 存钱罐数据 36*/
+    PIGGYBOX_DATA = 36,
 }
 
 export enum ITEMTYPE {

+ 0 - 1
tower_sanguo/assets/scripts/module/checkpointRedBag/CheckpointRedBagModle.ts

@@ -89,7 +89,6 @@ export default class CheckpointRedBagModle {
 
         this.redbag_data.cumulative_count++;
         this.cur_is_get = true;
-        // GameController.http.upLvGetRedBag(this.getRedBagCount.bind(this))
         // 模拟数据,直接出现
         let red_bag_path = 'module/checkpointRedBag/btn_chPo_RedBag';
         XXLoader.loadAssetByType(red_bag_path, cc.Prefab, (asset) => {

+ 13 - 5
tower_sanguo/assets/scripts/module/piggyBank/PiggyBankModel.ts

@@ -42,6 +42,8 @@ export default class PiggyBankModel {
     public static deposit: Map<number, number> = new Map();
     /** 存入存钱罐内的红包币【服务端累加值】 */
     public static piggyBox: number = 0;
+    /** 上一次存入的红包 */
+    private static last_piggyBox: number = 0;
     /** 是否达到存储上限 */
     public static piggyBoxFull: boolean = false;
     /** 当前请求红包币的概率【百分比】 */
@@ -63,11 +65,17 @@ export default class PiggyBankModel {
         cc.log('训练获得红包币:', reply)
         let data = reply.data;
         if (data && data.code === 1) {
-            this.piggyBoxFull = !!data.piggyBoxFull;
-            this.piggyBox = data.piggyBox;
-            let size = this.deposit.size;
-            this.deposit.set(size, this.piggyBox);
-            this.flyRedBagToMain();
+            let data2 = data.data;
+            this.piggyBoxFull = !!data2.piggyBoxFull;
+            this.piggyBox = data2.piggyBox;
+            if (!this.piggyBoxFull) {
+                let gap = this.piggyBox - this.last_piggyBox;
+                let size = this.deposit.size;
+                this.deposit.set(size, gap);
+                this.flyRedBagToMain();
+                this.last_piggyBox = this.piggyBox;
+            }
+            this.bank_cash_value = data2.piggyBoxYesterday;
         } else {
 
         }

+ 11 - 0
tower_sanguo/assets/scripts/module/piggyBank/PiggyBankUI.ts

@@ -3,6 +3,8 @@
  * @author xhx
  */
 import BaseUI from "../../../MOKA/component/BaseUI";
+import { PLAYERPROP } from "../../data/GameDefinition";
+import GameController from "../../GameController";
 import PiggyBankModel from "./PiggyBankModel";
 const { ccclass, property } = cc._decorator;
 
@@ -23,9 +25,13 @@ export default class PiggyBankUI extends BaseUI {
     onLoad() {
         XXEvent.addClickEvent(this.btn_receive, this.onClickReceive, this);
         XXEvent.addClickEvent(this.btn_close, this.onClickReceive, this);
+        XXEvent.on('http-piggyBox-getPiggyBox', this.onReceiveCall, this);
     }
 
     start() {
+        let data2 = GameController.gameData.player.getProp(PLAYERPROP.PIGGYBOX_DATA);
+        PiggyBankModel.bank_cash_value = data2.piggyBoxYesterday;
+        PiggyBankModel.piggyBox = data2.piggyBox;
         this.initStyle();
     }
     /** 初始化样式 */
@@ -41,6 +47,11 @@ export default class PiggyBankUI extends BaseUI {
     /** 领取奖励 */
     private onClickReceive() {
         // 提现
+        GameController.http.getPiggyBox();
+    }
+    /** 提现结果 */
+    private onReceiveCall(reply) {
+        PiggyBankModel.getRedBagCount(reply);
         PiggyBankModel.WithdrawMoney();
         this.close();
     }

+ 1 - 1
tower_sanguo/assets/scripts/net/HttpCommand.ts

@@ -352,7 +352,7 @@ export default class HttpCommand {
 
         };
         this.sendData(HTTPTYPE.getPiggyBox, data, (data) => {
-            XXEvent.emit(HTTPTYPE.getPiggyBox,data)
+            XXEvent.emit('http-piggyBox-getPiggyBox',data)
         });
     }
 

+ 11 - 0
tower_sanguo/assets/scripts/vo/PlayerVO.ts

@@ -109,6 +109,17 @@ export default class PlayerVO {
      * - 无需校验,存在 gameUserData 内
     */
     task_list_data: Array<TASKITEM> = [];
+    /** 存钱罐数据 */
+    piggyBox = {
+        /** 今日累计存入的 */
+        piggyBox: 0,
+        /** 是否达到上限 */
+        piggyBoxFull: 0,
+        /** 上次存入时间 */
+        piggyBoxLastTime: 0,
+        /** 今日可领取的 */
+        piggyBoxYesterday: 0,
+    }
     /** 玩家属性值是对象而非数字,解析服务端数据不转num的集合 */
     isObjByPLAYERPROP(id): boolean {
         let arr = [PLAYERPROP.USER_DAILY_TASK_INFO, PLAYERPROP.USER_DAILY_ACTIVE_INFO, PLAYERPROP.CHECKPOINT_REGBAG_DATA, PLAYERPROP.GET_FOOD_DATA];