import User from "../../FrameWork/User/User";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import Common5 from "../../Platform/th/Common5";

export enum TuFaShiJian_Id{
    TFSJ_1,
    TFSJ_2,
    TFSJ_3
}
let AllConfig = [
    {id:TuFaShiJian_Id.TFSJ_1,contentStr:'苏铭(大舅哥)问你要走了8000块钱,并且对你吐了口唾沫,还骂了你一句穷鬼!',rightBtnStr:'确定'},
 


]

const {ccclass, property} = cc._decorator;

@ccclass
export default class TuFaShiJian extends cc.Component {
    @property(cc.Label)
    contentStr: cc.Label = null;

    @property(cc.Label)
    btnLeftStr: cc.Label = null;

    @property(cc.Label)
    btnRightStr: cc.Label = null;

    @property(cc.Node)
    failNode: cc.Node = null;

    @property(cc.Label)
    failContentStr: cc.Label = null;
    
    // onLoad () {}
    isLeftBtnRight = null
    finishCallFunc = null
    start () {
        
    }
    initView(id,isLeftBtnRight,finishCallFunc){
        this.isLeftBtnRight = isLeftBtnRight
        this.finishCallFunc = finishCallFunc

        let selectConfig = null
        for(let i=0;i<AllConfig.length;i++){
            if(id == AllConfig[i].id){
                selectConfig = AllConfig[i]
                break
            }
        }
        this.contentStr.string = selectConfig.contentStr
        this.btnLeftStr.string = selectConfig.leftBtnStr
        this.btnRightStr.string = selectConfig.rightBtnStr
        this.failContentStr.string = selectConfig.failContentStr
        if(!selectConfig.leftBtnStr){
            this.node.getChildByName('突发事件框').getChildByName('layout').getChildByName('btnLeft').active = false
        }
    }
    onLeftBtnClick(){
        if(this.isLeftBtnRight){
            this.finishCallFunc && this.finishCallFunc()
            this.node.removeFromParent()
        }else{
            this.failNode.active = true
        }
    }
    onRightBtnClick(){
        if(this.isLeftBtnRight){
            this.failNode.active = true
        }else{
            this.finishCallFunc && this.finishCallFunc()
            this.node.removeFromParent()
        }
    }
    onBtnFuHuoClick(){
        let tab = {
            onClose: (finish)=>{
                if (finish) {
                    Common5.ReportDY("inLevel", '突发事件-AD-复活');
                    this.finishCallFunc && this.finishCallFunc()
                    this.node.removeFromParent()
                }
                else{
                    Common5.showTips_custom("广告未观看完");
                }
            },onFailed:()=>{

            }
        }
        AppPlatform.playVideo_custom(tab)
    }
    onBtnRestart(){
        User.restartGame()
        this.node.removeFromParent()
        cc.director.loadScene("MainScene");
    }
}