| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /*
- * @Author: mojunshou 1637302775@qq.com
- * @Date: 2025-03-20 17:53:50
- * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-24 17:21:52
- * @Description: 红包提现
- */
- import { _decorator, Label, Node } from "cc";
- import { oops } from "db://oops-framework/core/Oops";
- import { DeviceUtil } from "db://oops-framework/core/utils/DeviceUtil";
- import { ecs } from "db://oops-framework/libs/ecs/ECS";
- import { CCVMParentComp } from "db://oops-framework/module/common/CCVMParentComp";
- import { GameEvent } from "../common/config/GameEvent";
- import { UIID } from "../common/config/GameUIConfig";
- import { ServerHandler } from "../common/manager/ServerHandler";
- import List from "../ui/List";
- import { RedPackeItemView } from "./RedPackeItemView";
- import { smc } from "../common/SingletonModuleComp";
- import { Format } from "../utils/Format";
- import { DCHandler } from "../common/manager/DCHandler";
- const { ccclass, property } = _decorator;
- /** 视图层对象 */
- @ccclass('RedPackeWithdrawalViewComp')
- @ecs.register(`RedPackeWithdrawalViewComp`, false)
- export class RedPackeWithdrawalViewComp extends CCVMParentComp {
- @property(List)
- recordList: List = null!;
- @property(Label)
- lab_tips: Label = null!;
- data: any = {
- tasklist: [],
- wxCash: 0,
- hbCoin: 0,
- goldNum: 0
- };
- start() {
- this.setButton();
- this.addEvent();
- DCHandler.inst.reportData(3000900);
- this.data.taskList = smc.game.GameModel.taskList;
- this.data.wxCash = smc.game.GameModel.wxCash;
- this.data.hbCoin = Format.formatRedPacketCoin(smc.account.AccountModel.hbCoin);
- this.data.goldNum = smc.account.AccountModel.goldCoin;
- if (this.data.taskList.length > 0) {
- this.recordList.numItems = this.data.taskList.length;
- }
- this.lab_tips.string = `当前收集金砖${this.data.goldNum}块,红包10000元=人民币1元`;
- }
- addEvent() {
- oops.message.on(GameEvent.updateRedPackeTaskList, this.updateList, this);
- oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
- }
- private onListRender(item: Node, idx: number) {
- const itemView: RedPackeItemView | null = item.getComponent(RedPackeItemView);
- if (itemView) {
- itemView.setItem(this.data.taskList[idx], idx);
- }
- }
- updateList() {
- // console.log("更新提现记录信息", this.data.wxCash);
- this.data.taskList = smc.game.GameModel.taskList;
- this.data.wxCash = smc.game.GameModel.wxCash;
- const hbCoin = Format.formatRedPacketCoin(smc.account.AccountModel.hbCoin);
- this.data.hbCoin = Number(hbCoin);
- this.data.goldNum = smc.account.AccountModel.goldCoin;
- this.recordList.numItems = 0;
- if (this.data.taskList.length > 0) {
- this.recordList.numItems = this.data.taskList.length;
- }
- this.lab_tips.string = `当前收集金砖${this.data.goldNum}块,红包10000元=人民币1元`;
- oops.gui.toast("领取成功");
- }
- updateCoin() {
- this.data.wxCash = smc.game.GameModel.wxCash;
- console.log("111111111111111111111")
- const hbCoin = Format.formatRedPacketCoin(smc.account.AccountModel.hbCoin);
- console.log("22222222222222222")
- this.data.hbCoin = Number(hbCoin);
- }
- private btn_back() {
- oops.gui.remove(UIID.RedPacketWithdraw);
- oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
- DCHandler.inst.reportData(3000901);
- }
- private btn_record() {
- if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
- ServerHandler.inst.getRecordList();
- DCHandler.inst.reportData(3000902);
- } else {
- oops.gui.open(UIID.WithdrawRecord);
- }
- }
- private async btn_withdrawal() {
- //全部提现
- if (this.data.wxCash >= 0.1) {
- ServerHandler.inst.HbReward();
- DCHandler.inst.reportData(3000900, 1001);
- } else {
- oops.gui.toast("微信官方限制大于0.1元,才能提现~");
- DCHandler.inst.reportData(3000900, 1002);
- }
- }
- /** 视图对象通过 ecs.Entity.remove(WechatWithdrawalViewComp) 删除组件是触发组件处理自定义释放逻辑 */
- reset() {
- this.node.destroy();
- }
- formatNumber(num: number) {
- return Math.round(num * 100) / 100;
- }
- }
|