import Panel from "../views/Panel";
import { MConfigs } from "../MConfigs";
import AchievementPicItem from "../item/AchievementPicItem";
import { NetBuried } from "../NetBuried";

export default class ViewAchievementPanel extends Panel {
    public get skinKey() { return "ViewAchievementPanel" }
    public get groupName() { return "view_achievement_panel" }

    public date: eui.Label;
    public achievementName: eui.Label;
    public picContainer: eui.DataGroup;

    protected preLoadRes() {
        return new Promise(async (resolve, reject) => {
            await RES.loadGroup(this.groupName);
            resolve();
        });
    }

    private achievementPicItem: AchievementPicItem = null;

    protected onSkinComplete() {
        super.onSkinComplete();
        NetBuried.ins.clickLog(23)
        console.log(this.data.configData)
        console.log(this.data.gmtCreate)
        console.log(this.formatDate(new Date(this.data.gmtCreate)));
        this.date.text = this.formatDate(new Date(this.data.gmtCreate))
        this.achievementName.text = this.data.configData["name"];
        this.picContainer.addChild(new AchievementPicItem(this.data.index));
    }

    formatDate(now) {
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var date = now.getDate();
        return year + "年" + month + "月" + date + "日";
    }
}