import { Widget, _decorator, Node } from 'cc';
import { UIBase } from '../scriptBase/UIBase';
import { UI } from '../enum/UI';
import { CfgLoginReward } from '../config/CfgLoginReward';
import { ArrayUtil } from '../util/ArrayUtil';
import { StorageUtil } from '../util/StorageUtil';
const { ccclass, property, requireComponent } = _decorator;

@ccclass('UI/UILoginReward')
@requireComponent(Widget)
export class UILoginReward extends UIBase {

    public onOpen(data?: any): void {

    }

    public onClose(data?: any): void {

    }

    protected onBtnCloseClick(): void {
        this.close()
    }

    protected onBtnGetAllClick(): void {
        this.close()
        this.open(UI.GetReward, CfgLoginReward)
        StorageUtil.setItem('loginRewardGetTime', Date.now())
    }

    protected onBtnGetOneClick(): void {
        this.close()
        this.open(UI.GetReward, [ArrayUtil.pickItem(CfgLoginReward)])
        StorageUtil.setItem('loginRewardGetTime', Date.now())
    }

}


