ReservePopup.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-04-19 11:04:19
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-28 15:25:52
  6. * @Description:
  7. */
  8. import { _decorator } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import VMParent from 'db://oops-framework/libs/model-view/VMParent';
  11. import { UIID } from '../../common/config/GameUIConfig';
  12. import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil';
  13. import { smc } from '../../common/SingletonModuleComp';
  14. import { Format } from '../../utils/Format';
  15. import { DCHandler } from '../../common/manager/DCHandler';
  16. import { ServerHandler } from '../../common/manager/ServerHandler';
  17. const { ccclass, property } = _decorator;
  18. @ccclass('ReservePopup')
  19. export class ReservePopup extends VMParent {
  20. data: any = {
  21. nickName: "小白",
  22. time: "2025-04-28",
  23. money: 1000,
  24. goldNum: 1
  25. }
  26. start() {
  27. DCHandler.inst.reportData(3000200);
  28. this.setButton();
  29. this.updateData();
  30. }
  31. //更新数据
  32. updateData() {
  33. if (DeviceUtil.isAndroid && DeviceUtil.isNative) {
  34. let name = smc.account.AccountModel.accountName
  35. //超过五位数就用***代替
  36. this.data.nickName = Format.truncateCustom(name);
  37. this.data.money = Format.formatWxCoin(smc.account.AccountModel.wxCoin);
  38. //当前时间的后三天,只要年月日
  39. this.data.time = this.getThreeDaysLater();
  40. }
  41. }
  42. async btn_confirm() {
  43. //加载微信转账中
  44. oops.gui.remove(UIID.ReservePopup);
  45. this.updateState();
  46. }
  47. updateState() {
  48. ServerHandler.inst.updatePopupState({
  49. level: smc.account.AccountModel.curLevel,
  50. type: smc.game.GameModel.popupType
  51. })
  52. }
  53. // 获取当前日期后三天的日期(格式:YYYY-MM-DD)
  54. getThreeDaysLater(): string {
  55. const date = new Date();
  56. date.setDate(date.getDate() + 3); // 自动处理跨月/年逻辑[5](@ref)
  57. // 补零处理
  58. const year = date.getFullYear();
  59. const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始需+1[4](@ref)
  60. const day = date.getDate().toString().padStart(2, '0'); // 日期补零[2](@ref)
  61. return `${year}-${month}-${day}`;
  62. }
  63. }