/* * @Author: mojunshou 1637302775@qq.com * @Date: 2025-04-19 11:04:19 * @LastEditors: mojunshou 1637302775@qq.com * @LastEditTime: 2025-04-28 16:32:06 * @Description: */ import { _decorator } from 'cc'; import { oops } from 'db://oops-framework/core/Oops'; import VMParent from 'db://oops-framework/libs/model-view/VMParent'; import { UIID } from '../../common/config/GameUIConfig'; import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil'; import { smc } from '../../common/SingletonModuleComp'; import { Format } from '../../utils/Format'; import { DCHandler } from '../../common/manager/DCHandler'; import { ServerHandler } from '../../common/manager/ServerHandler'; import { GameEvent } from '../../common/config/GameEvent'; const { ccclass, property } = _decorator; @ccclass('ReservePopup') export class ReservePopup extends VMParent { data: any = { nickName: "小白", time: "2025-04-28", money: 1000, goldNum: 1 } start() { DCHandler.inst.reportData(3000200); this.setButton(); this.updateData(); oops.message.dispatchEvent(GameEvent.updateGameState, "paused"); } //更新数据 updateData() { if (DeviceUtil.isAndroid && DeviceUtil.isNative) { let name = smc.account.AccountModel.accountName //超过五位数就用***代替 this.data.nickName = Format.truncateCustom(name); this.data.money = Format.formatWxCoin(smc.account.AccountModel.wxCoin); //当前时间的后三天,只要年月日 this.data.time = this.getThreeDaysLater(); } } async btn_confirm() { //加载微信转账中 oops.gui.remove(UIID.ReservePopup); this.updateState(); } updateState() { ServerHandler.inst.updatePopupState({ level: smc.account.AccountModel.curLevel, type: smc.game.GameModel.popupType }) } // 获取当前日期后三天的日期(格式:YYYY-MM-DD) getThreeDaysLater(): string { const date = new Date(); date.setDate(date.getDate() + 3); // 自动处理跨月/年逻辑[5](@ref) // 补零处理 const year = date.getFullYear(); const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始需+1[4](@ref) const day = date.getDate().toString().padStart(2, '0'); // 日期补零[2](@ref) return `${year}-${month}-${day}`; } }