import { _decorator, Component, Label, Node } from 'cc';
import { base_ui } from '../../fw/base_ui';
import { dataManager } from '../../manager/dataManager';
const { ccclass, property } = _decorator;

@ccclass('car_info_get_suipian')
export class car_info_get_suipian extends base_ui {
    @property(Node) btn_look_video:Node = null
    @property(Node) btn_share:Node = null
    @property(Node) lab_look_video_count:Node = null
    @property(Node) lab_share_count:Node = null

    private m_look_video_cb = null
    private m_share_cb = null

    start() {
        this.onButtonListen(this.btn_look_video, ()=>{
            this.m_look_video_cb && this.m_look_video_cb(this)
        })
        this.onButtonListen(this.btn_share, ()=>{
            this.m_share_cb && this.m_share_cb(this)
        })
    }

    initView(look_video_cb, share_cb) {
        this.m_look_video_cb = look_video_cb
        this.m_share_cb = share_cb
    }

    setData() {
        let look_video_count = dataManager.getCarDebrisLookVideoTotalCount() - dataManager.getCarDebrisUserLookVideoCount()
        if(look_video_count<0){ look_video_count=0 }
        this.lab_look_video_count.getComponent(Label).string = `今日剩余${look_video_count}次`

        let share_count = dataManager.getCarDebrisShareTotalCount() - dataManager.getCarDebrisUserShareCount()
        if(share_count<0){ share_count=0 }
        this.lab_share_count.getComponent(Label).string = `今日剩余${share_count}次`
    }
}

