/*
 * @Author: mojunshou 1637302775@qq.com
 * @Date: 2025-03-20 17:53:50
 * @LastEditors: mojunshou 1637302775@qq.com
 * @LastEditTime: 2025-04-08 14:59:27
 * @Description: 红包提现
 */
import { _decorator, Node } from "cc";
import { oops } from "db://oops-framework/core/Oops";
import { ecs } from "db://oops-framework/libs/ecs/ECS";
import { CCComp } from "db://oops-framework/module/common/CCComp";
import { UIID } from "../../common/config/GameUIConfig";
import List from "../ui/List";
import { RedPackeItemView } from "./RedPackeItemView";
import { GameComponent } from "db://oops-framework/module/common/GameComponent";

const { ccclass, property } = _decorator;

/** 视图层对象 */
@ccclass('RedPackeWithdrawalViewComp')
export class RedPackeWithdrawalViewComp extends GameComponent {

    @property(List)
    recordList: List = null!;

    data: any[] = [];
    onLoad() {
        this.setButton();
        const data = {
            title: `每日消除100次即可领取`,
            current: 1,
            total: 100,
            state: 0,
            goods: [
                {
                    type: 1001,
                    num: 100
                }
            ]
        }

        for (let i = 0; i < 10; i++) {
            this.data.push(data);
        }
        oops.log.logView(this.data, "this.data");
        this.recordList.numItems = this.data.length;
        oops.log.logView(this.recordList.numItems, "this.recordList.numItems");
    }


    private onListRender(item: Node, idx: number) {
        console.log("onListRender", idx);
        const itemView: RedPackeItemView | null = item.getComponent(RedPackeItemView);
        if (itemView) {
            console.log(">>>>>>>>>>>>>>>>>", itemView)
            itemView.setItem(this.data[idx], idx);
        }
    }

    private btn_back() {
        oops.gui.remove(UIID.RedPacketWithdraw);
    }


    private btn_record() {
        oops.gui.open(UIID.WithdrawRecord);
    }

}