/**
 * 签到界面
 * @author 薛鸿潇
 */
const { ccclass, property } = cc._decorator;

@ccclass
export default class Sign extends cc.Component {

    @property({ type: cc.ScrollView, displayName: '滚动视图' })
    private scroll_view: cc.ScrollView = null!;
    @property({ type: cc.Animation, displayName: '按钮_动画' })
    private anim_btn: cc.Animation = null!;

    onLoad() {

    }

    start() {
        g.sign.initListData();
        g.sign.init_data = true;
    }

    /**
     * 初始化滚动视图
     */
    private initScollView() {
        let list_data = g.sign.list_data;
        this.scroll_view.node.emit('srollview-init', list_data)
    }

    /**
     * 点击领取按钮
     */
    private clickReceiveReward() {
        g.sign.can_sign = 0;
    }
    update(dt) {
        if (g.sign.init_data) {
            g.sign.init_data = false;
            this.initScollView();
            this.initBtnStyle();
        }
    }
    private initBtnStyle() {
        if (g.sign.can_sign) {
            this.anim_btn.play();
            this.anim_btn.getComponent('SetGray').setGray(false);
        } else {
            this.anim_btn.stop();
            this.anim_btn.node.scale = 1;
            this.anim_btn.getComponent('SetGray').setGray(true);
        }
    }
}
