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

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();
        console.log(this.data.configData)
        console.log(this.data.gmtCreate)
        console.log(this.formatDate(new Date(this.data.gmtCreate)));
      //  let configData = this.data["id"];
       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(); 
        var hour=now.getHours(); 
        var minute=now.getMinutes(); 
        var second=now.getSeconds(); 
        return year+"年"+month+"月"+date+"日";
   } 
}