cocos2d js 做签到功能,根据不同的月数显示不同月数,求大神给个思路

cocos2d js 做签到功能,根据不同的月数显示不同月数,求大神给个思路

没明白你的意思啊,描述清楚点啊。。。

写一个7*5的数组,然后计算当月1号位置在星期几,后面递增。

    let date = new Date();

    //获取当月1号是星期几
    let n1str = new Date(date.getFullYear(),date.getMonth(),1);
    let firstday = n1str.getDay();
    let m_days = new Array(31,28 + this.is_leap(date.getFullYear()),31,30,31,30,31,31,30,31,30,31);

    let total = 42 ; //表格总长度为42

    //开始补齐上月信息
    this.table.removeAllChildren(); //清除表格

    let LastMonth = (date.getMonth() == 0) ? m_days[ m_days.length - 1] : m_days[ date.getMonth() - 1 ];

    for(let i=0 ; i < firstday ; i++){
        let td = cc.instantiate(this.td);
        let Label = td.getComponent(cc.Label);
        Label.string = LastMonth - i;
        this.table.addChild(td);
    }

    //处理本月日期

    let days = m_days[date.getMonth()];

    for(let i = 0 ; i < days ; i++){

        let td = cc.instantiate(this.td);
        let selfDay = i + 1 ;
        if(selfDay == date.getDate()){
            var Label = td.getComponent(cc.Label);
        }else{
            var Label = td.getComponent(cc.Label);
        }
        Label.string = i + 1;
        this.table.addChild(td);
    }

    //补齐下月天数
    let next = total - this.table.childrenCount;

    for(let i=0 ; i < next ; i++){
        let td = cc.instantiate(this.td);
        let Label = td.getComponent(cc.Label);
        Label.string = i + 1;
        this.table.addChild(td);
    }

谢谢你

谢谢啦