Kaynağa Gözat

[FC]:更新道具存储方式(使用框架)

fengcong 5 yıl önce
ebeveyn
işleme
2ad599682a

+ 16 - 12
assets/script/before/GamePlay.ts

@@ -324,8 +324,9 @@ export default class GamePlay extends cc.Component {
 
     /**初始化锤子道具数目 */
     initHammerPropNum() {
-        if (PlayerConst.hanmmerPropNum > 0) {
-            this.label_hammerPropNum.string = PlayerConst.hanmmerPropNum.toString();
+        let hammerPropNum = gData.gameData.getProp(GameProp.hammerPropNum);
+        if (hammerPropNum) {
+            this.label_hammerPropNum.string = hammerPropNum.toString();
         }
         else {
             this.label_hammerPropNum.string = "+";
@@ -334,8 +335,9 @@ export default class GamePlay extends cc.Component {
 
     /**初始化重置道具数目 */
     initResetPropNum() {
-        if (PlayerConst.resetPropNum) {
-            this.label_resetPropNum.string = PlayerConst.resetPropNum.toString();
+        let resetPropNum = gData.gameData.getProp(GameProp.resetPropNum);
+        if (resetPropNum) {
+            this.label_resetPropNum.string = resetPropNum.toString();
         }
         else {
             this.label_resetPropNum.string = "+";
@@ -344,8 +346,9 @@ export default class GamePlay extends cc.Component {
 
     /**初始化替换道具数目 */
     initChanegPropNum() {
-        if (PlayerConst.changePropNum) {
-            this.label_changePropNum.string = PlayerConst.changePropNum.toString();
+        let changePropNum = gData.gameData.getProp(GameProp.changePropNum);
+        if (changePropNum) {
+            this.label_changePropNum.string = changePropNum.toString();
         }
         else {
             this.label_changePropNum.string = "+";
@@ -448,8 +451,9 @@ export default class GamePlay extends cc.Component {
         this.setCurSelectPropBtn(this.node_resetBtn);
 
         this.curPropType = PROPTYPE.Reset;
-        console.log("PlayerConst.resetPropNum", PlayerConst.resetPropNum);
-        if (PlayerConst.resetPropNum <= 0) {
+
+        let resetPropNum = gData.gameData.getProp(GameProp.resetPropNum);
+        if (resetPropNum) {
             mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
             return;
         }
@@ -487,8 +491,8 @@ export default class GamePlay extends cc.Component {
 
         this.curPropType = PROPTYPE.Hammer;
 
-        console.log("PlayerConst.hanmmerPropNum", PlayerConst.hanmmerPropNum);
-        if (PlayerConst.hanmmerPropNum <= 0) {
+        let hammerPropNum = gData.gameData.getProp(GameProp.hammerPropNum);
+        if (hammerPropNum<= 0) {
             mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
             return;
         }
@@ -503,10 +507,10 @@ export default class GamePlay extends cc.Component {
 
         //设置当前选择的道具按钮
         this.setCurSelectPropBtn(this.node_changeBtn);
-        console.log("PlayerConst.changePropNum", PlayerConst.changePropNum);
 
         this.curPropType = PROPTYPE.Change;
-        if (PlayerConst.changePropNum <= 0) {
+        let changePropNum = gData.gameData.getProp(GameProp.changePropNum);
+        if (changePropNum <= 0) {
             mk.ui.openPanel("game/prefab/uiPanel/GetPropUI");
             return;
         }

+ 0 - 106
assets/script/before/data/PlayerConst.ts

@@ -8,120 +8,14 @@ const { ccclass, property } = cc._decorator;
 @ccclass
 export default class PlayerConst extends cc.Component {
 
-    //玩家状态信息---------------------------------------------------------------
-    /**今日是否首次登陆 */
-    public static ifFirstLoginToday: boolean = false;
-    /**是否显示了惊喜任务 */
-    public static ifShowSurpriseTask: boolean = false;
-
-    //玩家微信信息---------------------------------------------------------------
-    /**玩家昵称 */
-    public static headImgUrl: string = "";
-    public static nickName: string = "微信未授权";
-    public static inviteCode: string = "";
-
-    //玩家数据信息---------------------------------------------------------------
-    /**玩家现金数目 */
-    public static cashNum: number = 0;
-
-    /**剩余体力恢复时间 */
-    public static leftEnergyRecoverTime: number = null;
-
-    /**锤子道具数量 */
-    public static hanmmerPropNum: number = 0;
-    /**变色道具数量 */
-    public static changePropNum: number = 0;
-    /**重设道具数量 */
-    public static resetPropNum: number = 0;
-
-    public passRedPacketCashNum: Number = 0;
-
-    /**登陆天数 */
-    public static loginDay: number = 0;
-
     //Api回传数据-------------------------------------------------------------------
     public static videoNum: number = 0;
     /**是否巨量激活 */
     public static ifJuliangApiApiActivie: boolean = false;
     /**是否巨量次留激活 */
     public static ifJuliangApiSencondActivie: boolean = false;
-
-
-    //打卡红包相关数据
-    public static clockInCashInfo: any = null;
-
-    //打卡相关数据------------------------------------------------------------------
-    
-    /**通关红包数 */
-    public static todayPassRedPacketNum: number = 0;
-    /**今日目标红包数 */
-    public static todayTargetRedPacketNum: number = 10;
-
     //平均ecpm----------------------------------------------------------------------
     public static average_ecpm: number = 0;
-
-    //商城信息-----------------------------------------------------------------------
-    public static adress: string = "";
-
-    /**获取用户detail信息 */
-    public static getDetailInfo(data: any) {
-        PlayerConst.cashNum = !!data.amount ? Number(data.amount) : 0;
-        PlayerConst.levelNum = !!data.cur_pass_no ? Number(data.cur_pass_no) : 0;
-        PlayerConst.energyNum = !!data.strength ? data.strength : 0;
-        PlayerConst.shopScoreNum = !!data.score_total ? data.score_total : 0;
-     
-        //登陆天数
-        PlayerConst.loginDay = !!data.loginDays ? data.loginDays : 1;
-      
-        //给Ecpm赋值
-        if (!!data.adShowConfig) {
-            if (PlayerConst.ifFirstLoginToday || !PlayerConst.average_ecpm) {
-                PlayerConst.average_ecpm = data.adShowConfig.average_ecpm;
-                StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.average_ecpm, PlayerConst.average_ecpm);
-                mk.console.log("[HttpMgr] detail PlayerConst.average_ecpm 首日赋值", PlayerConst.average_ecpm);
-            }
-            mk.console.log("[HttpMgr] detail PlayerConst.average_ecpm", PlayerConst.average_ecpm);
-        }
-    }
-
-    /** 获取特定类型的道具数量 */
-    public static getPropNumByType(propType: PROPTYPE): number {
-        let num: number = 0;
-        switch (propType) {
-            case PROPTYPE.Hammer:
-                num = PlayerConst.hanmmerPropNum;
-                break;
-            case PROPTYPE.Reset:
-                num = PlayerConst.resetPropNum;
-                break;
-            case PROPTYPE.Change:
-                num = PlayerConst.changePropNum;
-                break;
-            default:
-                num = 0;
-                break;
-        }
-        return num;
-    }
-
-    /**检测是否是新授权用户 */
-    public static cheeckIfNewAuthUser(registerTime: number): boolean {
-        if (!registerTime) {
-            return true;
-        }
-        let curDate = new Date();
-        let date_registerTime = new Date(registerTime * 1000);
-        let day_curDate = Util.parseTimestamp(curDate);
-        let day_registerTime = Util.parseTimestamp(date_registerTime);
-        mk.console.log("Util.parseTimestamp(day_curDate)", Util.parseTimestamp(curDate));
-        mk.console.log("Util.parseTimestamp(day_registerTime)", Util.parseTimestamp(date_registerTime));
-        if (day_curDate == day_registerTime) {
-            return true;
-        }
-        else {
-            return false;
-        }
-    }
 }
 
 export enum DATA_STORAGE_KEY {

+ 2 - 77
assets/script/before/mgr/DataMgr.ts

@@ -6,11 +6,9 @@
 //  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
 
 import PlayerConst, { DATA_STORAGE_KEY } from "../data/PlayerConst";
-import GameConst from "../data/GameConst";
 import StorageMgr from "./StorageMgr";
 import { PROPTYPE } from "../data/Enum";
 import GamePlay from "../GamePlay";
-import HttpMgr from "./HttpMgr";
 import { EVENT_TYPE, GameProp } from "../../game/data/GameData";
 
 const { ccclass, property } = cc._decorator;
@@ -30,26 +28,6 @@ export default class DataMgr extends cc.Component {
 
     /**初始化缓存数据 */
     initStorageData() {
-        //uin
-        let uin = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.uin);
-        mk.console.log("uin", uin);
-        if (!!uin) {
-            GameConst.uin = mk.encrypt.decrypt(uin, GameConst.localEncryptKey, GameConst.appid);
-            GameConst.tmp_uin = GameConst.uin;
-            mk.console.log("GameConst.uin", GameConst.uin);
-        }
-
-        //session_key 
-        let session_key = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.session_key);
-        if (!!session_key) {
-            GameConst.session_key = mk.encrypt.decrypt(session_key, GameConst.localEncryptKey, GameConst.appid);
-        }
-
-        //login_ticket
-        let login_ticket = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.login_ticket);
-        if (!!login_ticket) {
-            GameConst.login_ticket = mk.encrypt.decrypt(login_ticket, GameConst.localEncryptKey, GameConst.appid);
-        }
 
         //是否巨量api 回传激活
         let ifJuliangApiActivie = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.ifJuliangApiApiActivie);
@@ -63,64 +41,11 @@ export default class DataMgr extends cc.Component {
             PlayerConst.ifJuliangApiSencondActivie = ifJuliangApiSencondActivie;
         }
 
-        //今天通关的红包数目
-        let todayPassRedPacketNum = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.todayPassRedPacketNum);
-        if (!!todayPassRedPacketNum) {
-            PlayerConst.todayPassRedPacketNum = todayPassRedPacketNum;
-        }
-
-        //地址
-        let address = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.adress);
-        if (!!address) {
-            PlayerConst.adress = address;
-        }
-
         //平均ecpm
         let average_ecpm = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.average_ecpm);
         if (!!average_ecpm) {
             PlayerConst.average_ecpm = average_ecpm;
         }
-
-        //剩余体力恢复时间
-        let leftEnergyRecoverTime = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.leftEnergyRecoverTime);
-        if (!!leftEnergyRecoverTime) {
-            PlayerConst.leftEnergyRecoverTime = leftEnergyRecoverTime;
-        }
-
-        let date = new Date();
-
-        //体力值恢复计算--------------------------------------------------------------------
-        let energyChangeTime = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.energyChangeTime);
-        mk.console.log("energyChangeTime", energyChangeTime);
-        if (!!energyChangeTime) {
-
-            let curTime = date.getTime();
-
-            //计算总的间隔时间
-            let timeInterval = Math.floor((curTime - energyChangeTime) / 1000);
-            //计算整段恢复的数量
-            let recoverNum = Math.floor(timeInterval / GameConst.recoverTimePerEnergy);
-
-            //去除整段恢复剩余的时间
-            let leftTime = timeInterval - recoverNum * GameConst.recoverTimePerEnergy;
-
-            //如果存在剩余恢复时间
-            if (leftEnergyRecoverTime) {
-                if (leftTime >= leftEnergyRecoverTime) {
-                    recoverNum += 1;
-                    PlayerConst.leftEnergyRecoverTime = leftTime - leftEnergyRecoverTime;
-                }
-                else {
-                    PlayerConst.leftEnergyRecoverTime = leftEnergyRecoverTime - leftTime;
-                }
-            }
-
-            if (recoverNum > 0) {
-
-            }
-            mk.console.log("recoverNum", recoverNum);
-            mk.console.log("timeInterval", timeInterval);
-        }
     }
 
     /**
@@ -184,12 +109,12 @@ export default class DataMgr extends cc.Component {
     updateJuliangApi() {
         if (!PlayerConst.ifJuliangApiApiActivie) {
             this.updateJuliangApiActive(true);
-            HttpMgr.Inst.juliangAPIActive(0);
+            // HttpMgr.Inst.juliangAPIActive(0);
         }
         else {
             if (!PlayerConst.ifJuliangApiSencondActivie && PlayerConst.loginDay > 1) {
                 this.updateJuliangApiSecondActive(true);
-                HttpMgr.Inst.juliangAPIActive(6);
+                // HttpMgr.Inst.juliangAPIActive(6);
             }
         }
     }

+ 0 - 924
assets/script/before/mgr/HttpMgr.ts

@@ -1,924 +0,0 @@
-import { EVENT_TYPE } from "../../game/data/GameData";
-import MKSwitch from "../../mk/MKSwitch";
-import GameConst from "../data/GameConst";
-import PlayerConst, { DATA_STORAGE_KEY } from "../data/PlayerConst";
-import DataMgr from "./DataMgr";
-import EffectMgr from "./EffectMgr";
-
-import GameMgr, { UI_NAME } from "./GameMgr";
-import StorageMgr from "./StorageMgr";
-
-const { ccclass, property } = cc._decorator;
-
-@ccclass
-export default class HttpMgr {
-
-    //单例模式---------------------------
-    private static instance: HttpMgr = null;
-
-    public static get Inst(): HttpMgr {
-        if (!HttpMgr.instance) {
-            HttpMgr.instance = new HttpMgr();
-        }
-        return HttpMgr.instance;
-    }
-
-    /**
-   * 获取request
-   * @param url        url
-   * @param bodyData   数据
-   * @param httpMethod method 默认GET,可以选择POST
-   */
-    httpRquest(url: string, bodyData: any = null, httpMethod: HTTP_METHOD): Promise<any> {
-
-        if (!GameConst.ifConnectService) {
-            mk.console.log("[HttpMgr] 不连接服务器开关打开");
-            return new Promise((resolve, reject) => { reject() });
-            return;
-        }
-
-        // LogUtil.log("[HttpMgr] 连接服务器" + url);
-
-        // LogUtil.log("[getRequest] url", url);
-        // LogUtil.log("[getRequest] bodyData", bodyData);
-
-        return new Promise((resolve, reject) => {
-            var request = cc.loader.getXMLHttpRequest();
-            request.open(httpMethod, url, true)
-
-            request.onerror = (err) => {
-                mk.console.error(`${HTTP_METHOD[httpMethod]} 错误 onerror`);
-                EffectMgr.Inst.addTip("您的网络发生异常,请检查下哈");
-                reject(err);
-            }
-
-            request.ontimeout = (err) => {
-                mk.console.error(`${HTTP_METHOD[httpMethod]} 超时 ontimeout`);
-                reject(err);
-            }
-
-            request.onloadend = () => {
-                let respone = request.response;
-                if (!respone) {
-                    mk.console.error("[getRequest] 获取用户信息错误 ", request);
-                    reject();
-                }
-
-                let info;
-
-                if (typeof (respone) === "string") {
-                    info = JSON.parse(respone);
-                }
-                else {
-                    info = respone;
-                }
-
-                // LogUtil.log("info", info);
-
-                // LogUtil.log("url.split",url.split("/"))
-
-                // LogUtil.log(`[HttpMgr] ${HTTP_METHOD[httpMethod]}:${url.split("/")[url.split("/").length - 1]}`, info.errmsg)
-
-                if (info.errcode === 0) {
-                    resolve(info)
-                }
-                else {
-                    if (info.errcode === -20003) {
-                        GameMgr.Inst.sendEvent("Error", `服务器发生-20003错误`);
-                    }
-                    reject(info);
-                }
-            }
-
-            let headers = ["Content-Type", "application/json;charset=UTF-8"];
-
-            for (var i = 0; i < headers.length; i += 2) {
-                request.setRequestHeader(headers[i], headers[i + 1]);
-            }
-
-            //POST方式:跟后端了解,可以没有BodyData参数;GET一定没有BodyData参数
-            if (bodyData) {
-                request.send(bodyData)
-            }
-            else {
-                request.send()
-            }
-        })
-    }
-
-    //----------------------------接口操作-------------------------------------
-
-    /**上线
-     * 如果有key 或者 uin 直接进入AccountInfo
-     * 如果没有 连接
-     */
-    online() {
-        //这个需要打印
-        console.log("[HttpMgr] GameConst.url_service", GameConst.url_service);
-        if (GameConst.session_key != '' && GameConst.uin != '') {
-            mk.console.log("[HttpMgr] online 已经有缓存信息");
-            HttpMgr.instance.getUserInfo();
-        }
-        else {
-            mk.console.log("[HttpMgr] online 新用户");
-            HttpMgr.instance.connect();
-        }
-    }
-
-    /**连接
-     * 获取零食的tmp_uin
-     */
-    connect() {
-
-        // GameMgr.Inst.sendEvent(UI_NAME.Loading, "开始加载");
-
-        let url = `${GameConst.url_service}/connect`;
-        let bodyData = {
-            "psk": GameConst.randomKey,
-            "appid": GameConst.appid
-        }
-        mk.console.log("[connect]bodyData", bodyData)
-
-        let encryptData = mk.encrypt.rsaEncrypt(JSON.stringify(bodyData));
-
-        this.httpRquest(url, encryptData, HTTP_METHOD.POST).then((responseData) => {
-
-            let decryptData = mk.encrypt.decrypt(responseData.encrypt, GameConst.randomKey, GameConst.appid);
-            mk.console.log("[HttpMgr] connect", decryptData);
-            if (decryptData) {
-                GameConst.tmp_uin = JSON.parse(decryptData).tmp_uin;
-                StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.uin, GameConst.tmp_uin);
-
-                HttpMgr.instance.wxlogin();
-                //星云关键埋点
-                GameMgr.Inst.sendEventCp(`${UI_NAME.Loading}1`, "开始加载");
-            }
-
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] connect err", err);
-        });
-
-    }
-
-    /**微信登陆
-     * @param ifWxAuthCallBack 是否授权回调
-     */
-    wxlogin(ifWxAuthCallBack: boolean = false) {
-
-        mk.console.log("[Httpmgr] wxlogin 微信登陆");
-        let url = `${GameConst.url_service}/wxlogin`;
-
-        let data = {
-            "code": GameConst.wxCode,
-            "timestamp": Math.floor(new Date().getTime() * 0.001)
-        }
-        let bodydata = null;
-        let encryptInfo = null
-
-        let uin = GameConst.wxCode == '' ? GameConst.tmp_uin : GameConst.uin;
-        let encryptKey = GameConst.wxCode == "" ? GameConst.randomKey : GameConst.session_key;
-
-        encryptInfo = mk.encrypt.encrypt(JSON.stringify(data), encryptKey, GameConst.appid);
-
-        bodydata = {
-            "uin": uin,
-            "encrypt": encryptInfo
-        }
-
-        // LogUtil.log("[Httpmgr] wxlogin uin",uin);
-        // LogUtil.log("[Httpmgr] wxlogin encryptKey",encryptKey);
-        // LogUtil.log("[Httpmgr] wxlogin encryptInfo",encryptInfo);
-
-        // return;
-
-        this.httpRquest(url, JSON.stringify(bodydata), HTTP_METHOD.POST).then((responseData) => {
-
-            /**解密的数据 */
-            let decryptData = null;
-            if (GameConst.wxCode != '') {
-                decryptData = mk.encrypt.decrypt(responseData.encrypt, GameConst.session_key, GameConst.appid)
-            }
-            else {
-                decryptData = mk.encrypt.decrypt(responseData.encrypt, GameConst.randomKey, GameConst.appid)
-            }
-
-            if (decryptData) {
-
-                let data_parse = JSON.parse(decryptData);
-
-                //【测试状态】不发送事件,就不打印日志
-                mk.console.log("[HttpMgr] wxlogin", data_parse);
-
-                GameConst.login_ticket = data_parse.login_ticket
-
-                /**加密的数据 */
-                let encrypt_login_ticket =mk.encrypt.encrypt(GameConst.login_ticket, GameConst.localEncryptKey, GameConst.appid)
-                StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.login_ticket, encrypt_login_ticket);
-
-                if (GameConst.uin != data_parse.uin) {
-                    GameConst.uin = data_parse.uin
-                    // GameConst.isNew = true; //根本无须判定,getDetailInfo那边会鉴定
-                }
-                else {
-                    // GameConst.isNew = false;//根本无须判定,getDetailInfo那边会鉴定
-                }
-                mk.console.log("GameConst.isNew", GameConst.isNew);
-                mk.console.log("GameConst.uin", GameConst.uin);
-                let encrypt_uin = mk.encrypt.encrypt(GameConst.uin, GameConst.localEncryptKey, GameConst.appid)
-                StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.uin, encrypt_uin)
-
-                HttpMgr.instance.checklogin(ifWxAuthCallBack);
-            }
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] wxlogin err", err);
-        });
-    }
-
-    checklogin(ifWxAuthCallBack: boolean = false) {
-
-        let url = `${GameConst.url_service}/checklogin`;
-
-        let tmp_key
-        if (GameConst.wxCode != '') {
-            tmp_key = GameConst.session_key
-        }
-        else {
-            tmp_key = mk.encrypt.randomString()
-            GameConst.randomKey_new = tmp_key
-        }
-
-        let bodyData =
-        {
-            "tmp_key": tmp_key,
-            "uin": GameConst.uin,
-            "login_ticket": GameConst.login_ticket,
-            "appid": GameConst.appid
-        }
-
-        let rasEncryptData = mk.encrypt.rsaEncrypt(JSON.stringify(bodyData));
-
-        this.httpRquest(url, rasEncryptData, HTTP_METHOD.POST).then((responseData) => {
-
-            let decryptData = null;
-            if (GameConst.wxCode != '') {
-                decryptData = mk.encrypt.decrypt(responseData.encrypt, GameConst.session_key, GameConst.appid)
-            }
-            else {
-                decryptData = mk.encrypt.decrypt(responseData.encrypt, GameConst.randomKey_new, GameConst.appid)
-            }
-
-            mk.console.log("[HttpMgr] checklogin", decryptData);
-
-            if (decryptData) {
-                let data_parse = JSON.parse(decryptData)
-                GameConst.session_key = data_parse.session_key
-
-                let encrypt_session_key = mk.encrypt.encrypt(GameConst.session_key, GameConst.localEncryptKey, GameConst.appid)
-                StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.session_key, encrypt_session_key)
-
-                HttpMgr.Inst.getUserInfo(ifWxAuthCallBack);
-            }
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] checklogin err", err);
-        });;
-    }
-
-    /**获取账户信息 */
-    getUserInfo(ifWxAuthCallBack: boolean = false) {
-
-        let url = `${GameConst.url_service}/user`;
-
-        let data =
-        {
-            "uin": GameConst.uin,
-            "login_ticket": GameConst.login_ticket,
-            "timestamp": Math.floor(new Date().getTime() * 0.001)
-        }
-
-        mk.console.log("getUserInfo", data);
-
-        let encryptData = mk.encrypt.encrypt(JSON.stringify(data), GameConst.session_key, GameConst.appid)
-
-        let bodyData = {
-            "uin": GameConst.uin,
-            "encrypt": encryptData
-        }
-
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-
-            let data = this.parseResponseData(responseData)
-
-            mk.console.log("[HttpMgr] user", data);
-
-            // Object.keys(data).forEach((e) => {
-            //     LogUtil.log("[HttpMgr]1 " + e);
-            //     LogUtil.log("[HttpMgr]2 " + data[e]);
-            // });
-
-            if (data) {
-                GameConst.isNew = data["is_new_user"];
-                mk.console.log("[HttpMgr] user GameConst.isNew", GameConst.isNew);
-                //新手 初始化引导
-                if (GameConst.isNew) {
-             
-                }
-                else {
-
-                }
-                // LogUtil.log("data.is_new_user", data.is_new_user);
-                GameConst.isAuth = data["is_auth"]
-                mk.console.log("GameConst.isAuth", GameConst.isAuth);
-                //是否首次登陆
-                PlayerConst.ifFirstLoginToday = data["is_first_login_today"];
-
-                if (data.is_auth) {
-                    let encrypt_auth = mk.encrypt.encrypt('true', GameConst.localEncryptKey, GameConst.appid)
-                    StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.isAuth, encrypt_auth)
-
-                    PlayerConst.headImgUrl = data["HeadImgUrl"];
-                    PlayerConst.nickName = data["NickName"];
-
-                    let nickname = StorageMgr.Inst.getStorage(DATA_STORAGE_KEY.nickname);
-                    if (!!nickname) {
-                        //改名了
-                        if (nickname != data["nickname"]) {
-                            StorageMgr.Inst.setStorage(DATA_STORAGE_KEY.nickname, PlayerConst.nickName);
-                        }
-                    }
-
-                    //原本放在初始化 首页、提现、用户信息的头像取消,采用分发事件代替
-
-                    HttpMgr.Inst.getDetailInfo(ifWxAuthCallBack)
-                }
-                else {
-                    HttpMgr.Inst.getDetailInfo(ifWxAuthCallBack)
-                }
-            }
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] user err", err);
-        });
-    }
-
-    //-----------------------------------游戏相关接口---------------------------------
-
-    /**获取细节信息 */
-    getDetailInfo(ifWxAuthCallBack: boolean = false) {
-        // LogUtil.log("[HttpMgr] getDetailInfo");
-        let url = `${GameConst.url_service}/game/details`;
-
-        let data = {}
-        let bodyData = this.encryptBodyData(data);
-        // LogUtil.log("[HttpMgr] getDetailInfo", bodyData);
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-            let data = this.parseResponseData(responseData);
-
-            mk.console.log("[HttpMgr] details", data);
-
-            //解析获取的信息
-            PlayerConst.getDetailInfo(data);
-
-            //如果微信登陆回调返回
-            if (ifWxAuthCallBack) {
-
-                //检测是否刷新一下数据
-                if (PlayerConst.ifFirstLoginToday) {
-                    if (PlayerConst.cheeckIfNewAuthUser(data.register_date)) {
-                        mk.console.log("[WxAuth] 首日新用户")
-                    }
-                    else {
-                        mk.console.log("[WxAuth] 首日登陆老用户")
-                        DataMgr.Inst.resteData();
-                    }
-                }
-                else {
-                    mk.console.log("[WxAuth] 非首日登陆")
-                }
-
-                console.log("Detail  分发 微信授权事件");
-                //分发微信授权返回事件
-                mk.event.emit(EVENT_TYPE.BACK_WxAuth);
-
-                //初始化游戏 Game
-                //初始化结束按钮 gameOverUI
-                //初始化每日提现 node_dailyCashOutUI
-            }
-            else {
-                if (PlayerConst.ifFirstLoginToday) {
-                    PlayerConst.ifFirstLoginToday = false;
-                    DataMgr.Inst.resteData();
-                }
-            }
-
-            /**是否登陆结束 */
-            GameConst.ifLoginFinished = true;
-
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] details", err);
-        });
-    }
-
-    /**道具信息 */
-    propsInfo() {
-        let url = `${GameConst.url_service}/game/propsInfo`;
-
-        let data = {}
-        let bodyData = this.encryptBodyData(data);
-
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-            let data = this.parseResponseData(responseData);
-            mk.console.log("[HttpMgr] propsInfo", data);
-        });
-    }
-
-    /**道具
-     * @param handel_type 处理类型 1 增 2 减 
-     * @param prop_code   道具编号
-     * @param prop_num    道具数量
-     */
-    prop(handel_type: number, prop_code: string, prop_num: number): Promise<any> {
-
-        mk.console.log("prop_code", prop_code);
-        let url = `${GameConst.url_service}/game/prop`;
-
-        let data = {
-            "handel_type": handel_type,
-            "prop_code": prop_code,
-            "count": prop_num
-        }
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] prop", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    //-----------------------------------红包关接口-----------------------------------
-
-    /**新手红包
-     * @param:get_type   获取类型 0 普通 1 双倍
-     * @param:pass_no    关卡数
-     * @param:red_mondey 红包数目
-     */
-    newerRedPacket(get_type: number, pass_no: number, red_mondey: number): Promise<any> {
-
-        let url = `${GameConst.url_service}/red-package/newer`;
-
-        let data = {
-            "get_type": get_type,
-            "pass_no": pass_no,
-            "red_money": red_mondey
-        }
-        // LogUtil.log("data",data);
-        let bodyData = this.encryptBodyData(data);
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] newerRedPacket", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    /**登陆红包
-     * @param:get_type   获取类型 0 普通 1 双倍
-     * @param:pass_no    关卡数
-     * @param:red_mondey 红包数目
-     */
-    loginRedPacket(get_type: number, pass_no: number, red_mondey: number): Promise<any> {
-
-        let url = `${GameConst.url_service}/red-package/login`;
-
-        let data = {
-            "get_type": get_type,
-            "pass_no": pass_no,
-            "red_money": red_mondey
-        }
-        // LogUtil.log("data",data);
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] loginRedPacket", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    /**通关红包
-    * @param:get_type   获取类型 0 普通 1 双倍
-    * @param:pass_no    关卡数
-    * @param:red_mondey 红包数目
-    */
-    passRedPacket(get_type: number, pass_no: number, red_mondey: number): Promise<any> {
-
-
-        let url = `${GameConst.url_service}/red-package/pass`;
-
-        let data = {
-            "get_type": get_type,
-            "pass_no": pass_no,
-            "red_money": red_mondey
-        }
-        // LogUtil.log("data",data);
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] passRedPacket", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    /**随机红包
-    * @param:get_type   获取类型 0 普通 1 双倍
-    * @param:pass_no    关卡数
-    * @param:red_mondey 红包数目
-    */
-    randomRedPacket(get_type: number, pass_no: number, red_mondey: number): Promise<any> {
-
-        let url = `${GameConst.url_service}/red-package/random`;
-
-        let data = {
-            "get_type": get_type,
-            "pass_no": pass_no,
-            "red_money": red_mondey
-        }
-        // LogUtil.log("data",data);
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] randomRedPacket", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    //-----------------------------------提现接口-----------------------------------
-    /**提现
-     * @param amount 提现数额
-     * @param cash_type 提现类型
-     */
-    cash(amount: number, cash_type: number): Promise<any> {
-
-        let url = `${GameConst.url_service}/cash/getCash`;
-        let data = {
-            "amount": amount,
-            "cash_type": cash_type
-        }
-        let bodyData = this.encryptBodyData(data);
-
-        mk.console.log("cash_type", cash_type);
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] cash", data);
-                resolve(data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-    caseRecords(): Promise<any> {
-
-        let url = `${GameConst.url_service}/cash/records`;
-        let data = {
-
-        }
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] cash/records", data);
-            }).catch((err) => {
-                reject(err);
-            });
-        })
-    }
-
-
-    //互推位相关接口--------------------------------------------------------------------
-
-    /**抽奖 */
-    public recommendList(): Promise<any> {
-        let url = `${GameConst.url_service}/fission/recommendList`;
-        let data = {
-
-        }
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] fission/recommendList", data);
-                resolve(data);
-            }).catch((err) => {
-                mk.console.log("[HttpMgr] fission/recommendList", err);
-                reject(err);
-            });
-        })
-    }
-
-    /**抽奖 */
-    public appDownloadLog(downloadAppId: string): Promise<any> {
-        let url = `${GameConst.url_service}/fission/appDownloadLog`;
-        let data = {
-            "downloadAppId": downloadAppId,
-        }
-        let bodyData = this.encryptBodyData(data);
-
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] fission/appDownloadLog", data);
-                resolve(data);
-            }).catch((err) => {
-                mk.console.log("[HttpMgr] fission/appDownloadLog", err);
-                reject(err);
-            });
-        })
-    }
-
-    //API回传--------------------------------------------------------------------------
-    /**更新设备信息 */
-    public updateDeviceInfo(deviceInfo: any) {
-        let url = `${GameConst.url_service}/user/machine`;
-        let data = deviceInfo;
-        let bodyData = this.encryptBodyData(data);
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] user/machine", data);
-            }).catch((err) => {
-                reject(err);
-                mk.console.log("[HttpMgr] user/machine err", err);
-            });
-        })
-    }
-
-    /**巨量API回传
-     * @param type 0 激活 6 次留
-     */
-    public juliangAPIActive(type: number) {
-        if (cc.sys.os != cc.sys.OS_ANDROID) {
-            return;
-        }
-
-        mk.console.log("巨量回传 type", type);
-        let url = `${GameConst.url_service}/ad/oe/callback/activate`;
-        let data = {
-            "event_type": type,
-            "source": GameConst.appVersion + ';'
-        }
-        let bodyData = this.encryptBodyData(data);
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] juliangcallback/activate", data);
-            }).catch((err) => {
-                mk.console.log("[HttpMgr] juliangcallback/activate err", err);
-                reject(err);
-            });
-        })
-    }
-
-    //星云统计--------------------------------------------------------------------
-    /** 向星云发送事件埋点 */
-    public sendEventCp(eventKey: string, eventDes: string) {
-
-        mk.console.log('seventKey  ', eventKey);
-        mk.console.log('eventDes   ', eventDes)
-
-        //使用
-        let uin = !!GameConst.uin ? GameConst.uin : GameConst.tmp_uin;
-        if (!uin) {
-            mk.console.log("没有Uin,不执行");
-            return;
-        }
-        let url = `${GameConst.url_service}/cp`;
-        let isFirstDay = PlayerConst.loginDay == 1 ? 1 : 0;
-        let data = {
-            "appid": GameConst.appid,
-            "uid": uin,
-            "isFirstDay": isFirstDay, // 0 1 是第一天
-            "umengChannel": GameConst.umengChannel,
-            "deviceType": GameConst.deviceType,
-            "androidVerison": GameConst.androidVersion,
-            "version": GameConst.appVersion,
-            "point": eventKey,
-            "description": eventDes
-        }
-
-        // LogUtil.log("[HttpMgr] sendEventCp data", data);
-        let bodyData = this.encryptBodyData(data);
-
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-            let data = this.parseResponseData(responseData);
-            mk.console.log("[HttpMgr] sendEventCp", data);
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] sendEventCp err", err);
-        });
-    }
-
-    updateGameVersion(version: string) {
-        let url = `${GameConst.url_service}/game/updateVersion`;
-        let data = {
-            "version": version,
-        }
-        let bodyData = this.encryptBodyData(data);
-        return new Promise((resolve, reject) => {
-            this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-                let data = this.parseResponseData(responseData);
-                mk.console.log("[HttpMgr] game/updateVersion", data);
-            }).catch((err) => {
-                mk.console.log("[HttpMgr] game/updateVersion err", err);
-                reject(err);
-            });
-        })
-    }
-
-    /** 更新观看广告次数
-   */
-    updateVideoTimes(placementId, adunit_format, network_type, network_placement_id,
-        network_firm_id, adsource_id, adsource_index, adsource_price,
-        adsource_isheaderbidding, publisher_revenue, precision, ecpm_level) {
-
-        if (!GameConst.ifShowAd) {
-            return;
-        }
-
-        let url = `${GameConst.url_service}/video/updateVideo`;
-        let data = {
-            "imei": GameConst.imei,
-            "idfa": GameConst.idfa,
-            "oaid": GameConst.oaid,
-            "uin": GameConst.uin,
-            "version": GameConst.appVersion,
-            "tf_channel": GameConst.tf_channel,
-            "destoon_ad_place": placementId,
-            "ad_type": 1,
-            "adunit_format": adunit_format,
-            "network_type": network_type,
-            "network_placement_id": network_placement_id,
-            "network_firm_id": network_firm_id,
-            "adsource_id": adsource_id,
-            "adsource_index": adsource_index,
-            "adsource_price": adsource_price,
-            "adsource_isheaderbidding": adsource_isheaderbidding,
-            "publisher_revenue": publisher_revenue,
-            "precision": precision,
-            "ecpm_level": ecpm_level
-        }
-
-        mk.console.log("[HttpMgr] updateVideoTimes data", data);
-
-        Object.keys(data).forEach((key) => {
-            mk.console.log(`updateVideo ${key}`, data[key]);
-        })
-
-        let bodyData = this.encryptBodyData(data);
-
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-            let data = this.parseResponseData(responseData);
-            mk.console.log("[HttpMgr] updateVideoTimes ok", data);
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] updateVideoTimes err", err);
-        });
-    }
-
-    /** 更新其他广告次数
-         * @param type 1:激励视频成功、 2:插屏、3:信息流 4 观看视频
-         */
-    public updateADLog(type, placementId, adunit_format, network_type, network_placement_id,
-        network_firm_id, adsource_id, adsource_index, adsource_price,
-        adsource_isheaderbidding, publisher_revenue, precision, ecpm_level) {
-
-        if (!GameConst.ifShowAd) {
-            return;
-        }
-
-        let url = `${GameConst.url_service}/video/updateADLog`;
-        let data = {
-            "imei": GameConst.imei,
-            "idfa": GameConst.idfa,
-            "oaid": GameConst.oaid,
-            "uin": GameConst.uin,
-            "version": GameConst.appVersion,
-            "tf_channel": GameConst.tf_channel,
-            "destoon_ad_place": placementId,
-            "ad_type": type,
-            "adunit_format": adunit_format,
-            "network_type": network_type,
-            "network_placement_id": network_placement_id,
-            "network_firm_id": network_firm_id,
-            "adsource_id": adsource_id,
-            "adsource_index": adsource_index,
-            "adsource_price": adsource_price,
-            "adsource_isheaderbidding": adsource_isheaderbidding,
-            "publisher_revenue": publisher_revenue,
-            "precision": precision,
-            "ecpm_level": ecpm_level
-        }
-
-        mk.console.log("[HttpMgr] updateADLog data", data);
-
-        let bodyData = this.encryptBodyData(data);
-
-        this.httpRquest(url, JSON.stringify(bodyData), HTTP_METHOD.POST).then((responseData) => {
-            let data = this.parseResponseData(responseData);
-            mk.console.log("[HttpMgr] updateADLog ok", data);
-        }).catch((err) => {
-            mk.console.log("[HttpMgr] updateADLog err", err);
-        });
-    }
-
-    //-----------------------------------加解密-----------------------------------
-    /**加密参数 */
-    private encryptBodyData(data: any): any {
-
-        let encryptBodyData: any = null;
-        let encryptData: any = null;
-
-        //LogUtil.log("GameConst.tmp_uin",GameConst.tmp_uin);
-
-        data.timestamp = Math.floor(new Date().getTime() * 0.001);
-        if (GameConst.isAuth) {
-            encryptData = mk.encrypt.encrypt(JSON.stringify(data), GameConst.session_key, GameConst.appid);
-            encryptBodyData = {
-                "uin": GameConst.uin,
-                "encrypt": encryptData
-            }
-        }
-        else {
-            encryptData = mk.encrypt.encrypt(JSON.stringify(data), GameConst.session_key, GameConst.appid);
-            encryptBodyData = {
-                "uin": GameConst.tmp_uin,
-                "encrypt": encryptData
-            }
-        }
-        return encryptBodyData;
-    }
-
-    /**
-     * 解析返回的数据
-     * @param response    返回数据
-     * @param ifDataClear 是否数据是明文发送 默认暗文
-     */
-    private parseResponseData(response: any, ifDataClear: boolean = false): any {
-        let data = null
-        if (ifDataClear) {
-            data = response.data
-        }
-        else {
-            if (response.encrypt) {
-                data = mk.encrypt.decrypt(response.encrypt, GameConst.session_key, GameConst.appid)
-                data = JSON.parse(data)
-            }
-            else if (response.data) {
-                data = response.data
-            }
-        }
-        return data
-    }
-
-}
-
-export enum HTTP_METHOD {
-    GET = "GET",
-    POST = "POST"
-}
-
-export enum HTTP_TYPE {
-    connect = "connect",
-    recommendList = "recommendList"
-
-}
-
-//通关接口ERR CODE
-export enum PASS_ERR_CODE {
-    /** 关卡号不正*/
-    PASSNO_INCORRECT = 9001,
-    /**关卡号不能为空或者小于1 */
-    PASSNO_NULL = 9002,//
-    /***获取积分异常(积分传参非法)*/
-    SCORE_PARAM_ILLEGAL = 9003,
-    /**已达单关积分获取次数*/
-    SCORE_OVER_TIMES = 9004,
-    /**已达今日积分上限*/
-    SCORE_REACH_LIMIT = 9005
-}

+ 0 - 9
assets/script/before/mgr/HttpMgr.ts.meta

@@ -1,9 +0,0 @@
-{
-  "ver": "1.0.8",
-  "uuid": "72ec12d2-6d90-400a-a894-f8d119785357",
-  "isPlugin": false,
-  "loadPluginInWeb": true,
-  "loadPluginInNative": true,
-  "loadPluginInEditor": false,
-  "subMetas": {}
-}

+ 1 - 19
assets/script/before/util/GameLogic.ts

@@ -15,7 +15,7 @@ export default class GameLogic extends cc.Component {
      */
     public static loadHeadImg(headImgUrl: string, headSpr: cc.Sprite, size: number) {
         mk.console.log("[LoaderUtil] loadHeadImg ----------------------------------- ", headImgUrl);
-        mk.loader.loadRemote(`PlayerConst.headImgUrl + "?aaa=aa.jpg"`, null).then((res) => {
+        mk.loader.loadRemote(`${headImgUrl}+"?aaa=aa.jpg"`, null).then((res) => {
             let tex: cc.Texture2D = res as cc.Texture2D;
             headSpr.spriteFrame = new cc.SpriteFrame(tex);
             headSpr.node.setContentSize(size, size);
@@ -322,22 +322,4 @@ export default class GameLogic extends cc.Component {
         return leftXindexArr;
     }
 
-
-    //Ecpm相关-------------------------------------------------------
-    public static getVideoNumByEcpm() {
-        let videoNum_min: number = 5;
-        let videoNum_max: number = 30;
-        let videoNum: number = 5;
-        let ecpm = PlayerConst.average_ecpm;
-        if (ecpm) {
-            videoNum = Math.floor(0.5 * 1000 / PlayerConst.average_ecpm) + 1;
-        }
-        else {
-            return videoNum_max;
-        }
-        if (videoNum <= videoNum_min) { videoNum = videoNum_min; }
-        if (videoNum >= videoNum_max) { videoNum = videoNum_max; }
-        mk.console.log("videoNum", videoNum);
-        return videoNum;
-    }
 }

+ 1 - 10
assets/script/before/view/PauseUI.ts

@@ -132,17 +132,8 @@ export default class PauseUI extends cc.Component {
     }
 
     onClickRestartBtn() {
-        GameMgr.Inst.sendEvent(UI_NAME.PauseUI, "点击重新开始按钮");
-        if (PlayerConst.energyNum <= 0) {
-            EffectMgr.Inst.addTip("体力不足,请补充体力");
-            // this.node.active = false;
-            mk.ui.closePanel("PauseUI");
-            return;
-        }
-
+        //GameMgr.Inst.sendEvent(UI_NAME.PauseUI, "点击重新开始按钮");
         GamePlay.Inst.restart();
-  
-        // this.node.active = false;
         mk.ui.closePanel(this.node.name);
     }
 

+ 4 - 5
assets/script/before/view/PlayerInfoUI.ts

@@ -145,11 +145,11 @@ export default class PlayerInfoUI extends cc.Component {
     }
 
     initHead() {
-        GameLogic.loadHeadImg(PlayerConst.headImgUrl + "?aaa=aa.jpg", this.spr_head, 95);
+        GameLogic.loadHeadImg("" + "?aaa=aa.jpg", this.spr_head, 95);
     }
 
     initNickName() {
-        this.label_nickName.string = PlayerConst.nickName;
+        this.label_nickName.string = "PlayerConst.nickName";
     }
 
     initInviteCode() {
@@ -157,9 +157,8 @@ export default class PlayerInfoUI extends cc.Component {
     }
 
     initCaseNum() {
-        // let num = Math.round((PlayerConst.cashNum * 100)) / 100;
-        let num = Util.numberFixed(PlayerConst.cashNum, 2);
-        this.label_cashNum.string = `¥ ${num}`;
+        // let num = Util.numberFixed(PlayerConst.cashNum, 2);
+        // this.label_cashNum.string = `¥ ${num}`;
     }
 
     onClickCloseBtn() {

+ 0 - 216
assets/script/before/view/uiItem/ClockInItem.ts

@@ -1,216 +0,0 @@
-// Learn TypeScript:
-//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
-
-import PlayerConst from "../../data/PlayerConst";
-import GameConst from "../../data/GameConst";
-import EffectMgr from "../../mgr/EffectMgr";
-import GameMgr, { UIITEM_NAME } from "../../mgr/GameMgr";
-
-const { ccclass, property } = cc._decorator;
-
-@ccclass
-export default class ClockInItem extends cc.Component {
-
-
-    /**普通bg */
-    @property(cc.Node)
-    node_nromalClockInBg: cc.Node = null;
-    /**未打卡bg */
-    @property(cc.Node)
-    node_unClockInBg: cc.Node = null;
-    /**已经打卡icon */
-    @property(cc.Node)
-    node_haveClockInIcon: cc.Node = null;
-
-    /**红包 */
-    @property(cc.Node)
-    node_reaPacket: cc.Node = null;
-    /**提示 */
-    @property(cc.Node)
-    node_tip: cc.Node = null;
-    /**宝箱 */
-    @property(cc.Node)
-    node_box: cc.Node = null;
-
-    /**当前打卡天 */
-    public curClockInDay: number = 0;
-    /**奖励类型 null 是无奖励 1 红包 2 是宝箱 */
-    public rewardType: number = null;
-    /**奖励数量 */
-    public rewardNum: number = null;
-
-    /**红包数目 */
-    public reaPacketCashNum: number = 0;
-
-    /**是否打卡成功 */
-    public ifClockInDay: boolean = false;
-
-    // LIFE-CYCLE CALLBACKS:
-
-    // onLoad () {}
-
-    start() {
-        this.node.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
-    }
-
-    // update (dt) {}
-
-    init(day: number = null) {
-        // LogUtil.log("day",day)
-
-        // if (!day) {
-        //     return;
-        // }
-
-        if (day) {
-            this.curClockInDay = day;
-        }
-
-        // LogUtil.log("this.curClockInDay", this.curClockInDay);
-
-        let config = GameConst.config_clockIn[this.curClockInDay - 1];
-        // LogUtil.log("GameConst.config_clockIn", GameConst.config_clockIn);
-
-        this.rewardType = config.rewardType;
-        this.rewardNum = config.rewardNum
-
-        this.ifClockInDay = PlayerConst.ifClockInToday; 
-
-        let curRealClockInDay: number = 0;
-        //如果已经打卡  1 对应 1
-        if (this.ifClockInDay) {
-            curRealClockInDay = this.curClockInDay;
-        }
-        //如果未打开   1 对应 0
-        else {
-            curRealClockInDay = this.curClockInDay - 1;
-        }
-
-        if (curRealClockInDay < PlayerConst.clockInDay) {
-            this.node_unClockInBg.active = false;
-
-            this.node_nromalClockInBg.active = true;
-            if (this.rewardType == 1) {
-                this.node_nromalClockInBg.setScale(1, 1);
-            }
-            else {
-                this.node_nromalClockInBg.setScale(0.8, 0.8);
-            }
-            this.node_reaPacket.active = this.rewardType == 1;
-            this.node_haveClockInIcon.active = true;
-            
-            this.node_tip.active = false;
-
-            this.node_box.active = this.curClockInDay == GameConst.maxClockInDay;
-        }
-        else if (curRealClockInDay == (PlayerConst.clockInDay)) {
-
-            this.node_unClockInBg.active = false;
-
-            this.node_nromalClockInBg.active = true;
-            this.node_nromalClockInBg.setScale(1, 1);
-
-            this.node_reaPacket.active = this.rewardType == 1;
-            mk.console.log(" this.ifClockInDay", this.ifClockInDay);
-            this.node_haveClockInIcon.active = this.ifClockInDay;
-            this.node_tip.active = !this.ifClockInDay;
-
-            this.node_box.active = this.curClockInDay == GameConst.maxClockInDay;
-        }
-        else {
-
-            this.node_haveClockInIcon.active = false;
-            this.node_nromalClockInBg.active = false;
-            this.node_unClockInBg.active = true;
-            this.node_reaPacket.active = this.rewardType == 1;
-
-            this.node_box.active = this.rewardType == 2;
-        }
-
-
-
-        // if (this.curClockInDay < PlayerConst.clockInDay) {
-
-        //     //第一天情况特殊
-        //     if (PlayerConst.clockInDay == 0) {
-        //         this.node_unClockInBg.active = false;
-
-        //         this.node_nromalClockInBg.active = true;
-        //         this.node_nromalClockInBg.setScale(1, 1);
-
-        //         this.node_reaPacket.active = this.rewardType == 1;
-        //         LogUtil.log(" this.ifClockInDay", this.ifClockInDay);
-        //         this.node_haveClockInIcon.active = this.ifClockInDay;
-        //         this.node_tip.active = !this.ifClockInDay;
-
-        //         this.node_box.active = this.curClockInDay == GameConst.maxClockInDay;
-        //     }
-        //     else {
-        //         this.node_unClockInBg.active = false;
-
-        //         this.node_nromalClockInBg.active = true;
-        //         if (this.rewardType == 1) {
-        //             this.node_nromalClockInBg.setScale(1, 1);
-        //         }
-        //         else {
-        //             this.node_nromalClockInBg.setScale(0.8, 0.8);
-        //         }
-        //         this.node_reaPacket.active = this.rewardType == 1;
-        //         this.node_haveClockInIcon.active = true;
-
-        //         this.node_box.active = this.curClockInDay == GameConst.maxClockInDay;
-        //     }
-        // }
-        // else if (this.curClockInDay == (PlayerConst.clockInDay)) {
-
-        //     this.node_unClockInBg.active = false;
-
-        //     this.node_nromalClockInBg.active = true;
-        //     this.node_nromalClockInBg.setScale(1, 1);
-
-        //     this.node_reaPacket.active = this.rewardType == 1;
-        //     LogUtil.log(" this.ifClockInDay", this.ifClockInDay);
-        //     this.node_haveClockInIcon.active = this.ifClockInDay;
-        //     this.node_tip.active = !this.ifClockInDay;
-
-        //     this.node_box.active = this.curClockInDay == GameConst.maxClockInDay;
-        // }
-        // else {
-
-        //     this.node_haveClockInIcon.active = false;
-        //     this.node_nromalClockInBg.active = false;
-        //     this.node_unClockInBg.active = true;
-        //     this.node_reaPacket.active = this.rewardType == 1;
-
-        //     this.node_box.active = this.rewardType == 2;
-        // }
-    }
-
-    onClick() {
-
-        GameMgr.Inst.sendEvent(UIITEM_NAME.ClockInItem, `点击${this.curClockInDay}打卡Item`);
-
-        if (this.curClockInDay == PlayerConst.clockInDay && this.ifClockInDay) {
-            if (this.rewardType != null) {
-                EffectMgr.Inst.addTip(`打卡成功,可以提现啦`);
-            }
-            else {
-                EffectMgr.Inst.addTip(`继续累计打卡,领取后面红包吧`);
-            }
-        }
-        else {
-            if (this.rewardType != null) {
-                if (this.curClockInDay == GameConst.maxClockInDay) {
-                    EffectMgr.Inst.addTip(`连续打卡${this.curClockInDay}天,领取神秘宝箱`)
-                }
-                else {
-                    EffectMgr.Inst.addTip(`连续打卡${this.curClockInDay}天,提现${this.rewardNum}元`)
-                }
-            }
-        }
-    }
-}

+ 0 - 9
assets/script/before/view/uiItem/ClockInItem.ts.meta

@@ -1,9 +0,0 @@
-{
-  "ver": "1.0.8",
-  "uuid": "c3327a3d-0185-45b7-96b9-7bd63a5ca5eb",
-  "isPlugin": false,
-  "loadPluginInWeb": true,
-  "loadPluginInNative": true,
-  "loadPluginInEditor": false,
-  "subMetas": {}
-}