import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import VibrateMgr from "../../FrameWork/Mgr/VibrateMgr";
import GameReport, { ENTERTYPE, OUTTYPE } from "../../FrameWork/Report/ZyZyReport";
import User from "../../FrameWork/User/User";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import { DateUtils } from "../../FrameWork/Util/DateUtils";
import Common5 from "../../Platform/th/Common5";
import TTAPI from "../../Platform/tt/TTAPI";
// import PrefabManage, { GameType } from "../common/PrefabManage";
// import Setting from "../lobby/Setting";
// import ChengHaoReward from "../newGame/ChengHaoReward";
import LevelBase_xmj from "./LevelBase_xmj";
import NewDataManage_xmj, { GameSecondLevelManage_xmj } from "./NewDataManage_xmj";
// import { ShengXiaoCofig, ShengXiaoPanManager } from "./ShengXiaoPan";
// import ShouCangNewColor from "../newGame/ShouCangNewColor";
// import TaskManagerScript from "../newGame/TaskManagerScript";
import JieSuoNewColor_xmj from "./JieSuoNewColor_xmj";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import SingleMaJiang from "./xmj_SingleMaJiang";
import UserManager from "../Manager/UserManager";
import LevelUpManager from "../Manager/LevelUpManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class game_xmj extends LevelBase_xmj {

    @property(cc.Node)
    diTu: cc.Node = null;
    @property(cc.Node)
    paiContent: cc.Node = null;

    @property(cc.Label)
    labAllxipan: cc.Label = null;
    @property(cc.Node)
    shouzhiNode: cc.Node = null;

    @property(cc.Prefab)
    singleMaJiang: cc.Prefab = null;

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

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

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

    // @property(cc.Node)
    // btn_heCheng: cc.Node = null;

    // @property(cc.Node)
    // btn_xiPai: cc.Node = null;

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

    // @property(cc.Node)
    // progressNode: cc.Node = null;

    // @property(cc.Node)
    // finishNode: cc.Node = null;

    // @property(cc.Node)
    // targetTuZiSpine: cc.Node = null;

    // @property(cc.Node)
    // nextTargetNode: cc.Node = null;

    // @property(cc.Node)
    // chiZiDiTu: cc.Node = null;

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

    @property(cc.Node)
    leftPanZiNum: cc.Node = null;
    // @property(cc.Node)
    // jieSuoNewColor: cc.Node = null;

    @property(cc.Node)
    kuCunProgress: cc.Node = null;
    @property(cc.Node)
    faPanDaoJiShi: cc.Node = null;

    // @property(cc.Node)
    // shouCangNewColor: cc.Node = null;

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

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

    //@property(cc.Node)
    //todayTargetSpine: cc.Node = null;

    // @property(cc.Node)
    // shuiChiTiShi: cc.Node = null;

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

    @property(cc.Node)
    propChuiZi: cc.Node = null;
    // @property(cc.Node)
    // timeNode: cc.Node = null;

    // @property(cc.Node)
    // addtimeNode: cc.Node = null;

    fapaiNode: cc.Node = null;
    curSelectLineData = []//当前已选择牌
    curSelectLineIndex = -1//当前已选择列

    curSelectPanZiData = []//当前已选择盘子的牌
    curSelectPanZiIndex = -1//当前已选择盘子列

    curTargetLineTab = []//记录移动目标列(未移完时不能再次操作)

    curZIndex: number = 100
    curZIndex2: number = 1000
    isAction: boolean = false
    isKaCao1HeChenging: boolean = false
    isKaCao2HeChenging: boolean = false
    isFaPaing: boolean = false

    chenghaoId = 0
    xinShouYinDaoStepIndex: number = 0
    firstIn: boolean = false
    _dt: number = 0
    // isInVideo = false;
    // isStartTimeSch = false;
    isAllLoadFinish: boolean = false

    isStartChuiZiDaoJu: boolean = false
    isadd_500_panzi = false;
    newColorNode: cc.Node = null;
    isShouzhiShow: boolean = false;
    shouziIndex = 0

    public static _instance: any = null
    public static getInstance() {
        return game_xmj._instance
    }
    onLoad(): void {
        super.onLoad()
        this.fapaiNode = this.node.getChildByName('gameNode').getChildByName('btn_faPai')
        this.refreshTaskNode()
        this.refreshPropStatus()
        //EventMgr.onEvent_custom(ryw_Event.RefreshTaskStatus, (bShow) => {
        //this.refreshTaskNode()
        //}, this);
        // Common5.addMoney(28000)
    }
    refreshTaskNode() {
        //if(TaskManagerScript.getIsCanGetRewardTask()){
        //this.todayTargetSpine.getComponent(sp.Skeleton).setAnimation(0,'gantanhao',true)
        //}else{
        //this.todayTargetSpine.getComponent(sp.Skeleton).setAnimation(0,'putong',true)
        //}
    }
    update(dt) {
        // this._dt += dt
        // if(this._dt >= 1 && this.isAllLoadFinish){
        //     this._dt = 0
        //     // this.freshLinShiKaCao()
        //     // NewDataManage_xmj.refreshAdsLeftTimer()
        //     // this.showFaPanDaoJiShi()
        // }
    }
    start() {
        game_xmj._instance = this
        super.start()
        // this.chenghaoId = User.getChenghaoIdMJ()
        TTAPI.startRecord_custom()
        this.firstIn = false
        let yiXiaoChuNum = NewDataManage_xmj.getYiXiaoChuAllNum()
        // if(User.getFirstIn_xmj() && yiXiaoChuNum <= 0){
        this.firstIn = true
        // }else{
        // User.setFirstIn_xmj(false)
        // }
        GameSecondLevelManage_xmj.setStartCellData()
        this.initStartContent()
        // this.xinShouYinDaoStepIndex = User.getGuideStep_xmj()
        this.checkXinShouYinDao()
        // this.showFaPanDaoJiShi()
        this.isAllLoadFinish = true
        this.showJiesuoColorNodePecent()
        // if (NewDataManage_xmj.maxTime == -1){
        //     NewDataManage_xmj.maxTime = NewDataManage_xmj.getChushiTime();
        // }
        // if (!this.isStartTimeSch){
        //     this.isStartTimeSch = true;
        //     this.updateGameTime();
        // }
        // Common5.btnRegister_custom(this.addtimeNode,()=>{
        //     this.isInVideo = true;
        //     let tab = {
        //         onClose: (finish)=>{
        //             this.isInVideo = false;
        //             if (finish) {
        //                 Common5.ReportDY("inLevel", '游戏-AD-解锁临时区');
        //                 NewDataManage_xmj.maxTime += NewDataManage_xmj.getAddTime();
        //                 // this.jieSuoKaCao(true,customData)
        //             }
        //             else{
        //                 Common5.showTips_custom("广告未观看完");
        //             }
        //         },onFailed:()=>{
        //             this.isInVideo = false;
        //         }
        //     }
        //     AppPlatform.playVideo_custom(tab)
        // })
        EventMgr.onEvent_custom(ryw_Event.game_restart, () => {
            this.node.removeFromParent()
            this.node.destroy()
        }, this)
        EventMgr.onEvent_custom(ryw_Event.exitToLobby, () => {
            this.node.removeFromParent()
            this.node.destroy()
        }, this)
        EventMgr.onEvent_custom(ryw_Event.reborn, () => {
            Common5.ReportDY("inLevel", '复活');
            NewDataManage_xmj.maxTime += NewDataManage_xmj.getAddTime();
        }, this)

        this.showChenghaoProgressTab()
        this.setJiesuoNumLab()
        this.refreshAllXipan()
        this.scheduleOnce(() => {
            // PrefabManage.removeLoad()
        }, 1.0)
        this.changeTili(false)
    }
    // updateGameTime(){
    //     this.schedule(()=>{
    //         if (!this.isInVideo){                
    //             if (NewDataManage_xmj.maxTime >= 1){                
    //                 NewDataManage_xmj.maxTime--;
    //                 if (NewDataManage_xmj.maxTime >= 0){
    //                     let secondStr = "00";
    //                     let second = NewDataManage_xmj.maxTime%60;
    //                     if (second < 10){
    //                         secondStr = "0"+second;
    //                     }
    //                     else{
    //                         secondStr = second.toString();
    //                     }
    //                     this.timeNode.getComponent(cc.Label).string = Math.floor(NewDataManage_xmj.maxTime/60) + ":" +secondStr;
    //                 }
    //                 if (NewDataManage_xmj.maxTime <= 60){
    //                     this.addtimeNode.active = true;
    //                     this.timeNode.color = cc.color(255,0,0);
    //                 }
    //                 else {
    //                     this.addtimeNode.active = false;
    //                     this.timeNode.color = cc.color(250,250,215);
    //                 }
    //                 if (NewDataManage_xmj.maxTime == 0){
    //                     //showfail
    //                     PrefabManage.showFail();
    //                 }
    //             }
    //         }
    //     },1)
    // }
    setJiesuoNumLab() {
        let heChengQianColorNum = NewDataManage_xmj.getJieSuoColorNum()
        let lab = this.jinDuProgress.getChildByName('任务目标').getChildByName('NewLabel').getComponent(cc.Label)
        lab.string = `已解锁${heChengQianColorNum}种颜色`
    }
    //检测是否完成新手引导
    checkXinShouYinDao() {
        if (this.firstIn) {

            // this.node.getChildByName('gameNode').getChildByName('xiWanChiJieSuoNode').active = false
            this.btnSendCard.active = false
            this.kuCunProgress.active = false
            this.node.getChildByName('xinShouYinDaoNodeX').active = true
            if (this.xinShouYinDaoStepIndex == 0) {
                console.log('新手引导步骤1')
                // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = false
                this.paiContent.getChildByName('xinShouYinDaoNode1').active = true

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou1').active = true
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao1').active = true
            } else if (this.xinShouYinDaoStepIndex == 1) {
                console.log('新手引导步骤2')
                // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = false
                this.paiContent.getChildByName('xinShouYinDaoNode1').active = false
                this.paiContent.getChildByName('xinShouYinDaoNode2').active = true

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou1').active = false
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao1').active = false

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou2').active = true
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao2').active = true

            } else if (this.xinShouYinDaoStepIndex == 2) {
                console.log('新手引导步骤3')
                // this.paiContent.getChildByName('xinShouYinDaoNode2').active = false
                // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = false
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou2').active = false
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao2').active = false

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou3').active = true
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao3').active = true


            } else if (this.xinShouYinDaoStepIndex == 3) {
                console.log('新手引导步骤4')
                // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = true
                this.paiContent.getChildByName('xinShouYinDaoNode2').active = false
                this.chiZiNode.getChildByName('xinShouYinDaoNode3').active = true
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou3').active = false
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao3').active = false

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou4').active = true
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao4').active = true


            } else if (this.xinShouYinDaoStepIndex == 4) {
                console.log('新手引导步骤5')
                cc.tween(this.node)
                    .delay(3)
                    .call(() => {
                        // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = true
                        this.chiZiNode.getChildByName('xinShouYinDaoNode3').active = false
                        this.node.getChildByName('gameNode').getChildByName('xinShouYinDaoNode4').active = true
                        this.btnSendCard.active = true
                        this.kuCunProgress.active = true

                        this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou4').active = false
                        this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao4').active = false

                        // this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou5').active = true
                        this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao5').active = true
                    })
                    .start()


            } else if (this.xinShouYinDaoStepIndex == 5) {
                console.log('新手引导完成')
                // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = true
                this.node.getChildByName('gameNode').getChildByName('xinShouYinDaoNode4').active = false

                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('shou5').active = false
                this.node.getChildByName('xinShouYinDaoNodeX').getChildByName('qiPao5').active = false

                this.node.getChildByName('xinShouYinDaoNodeX').active = false
                // this.node.getChildByName('gameNode').getChildByName('xiWanChiJieSuoNode').active = true
                this.firstIn = false
                // User.setFirstIn_xmj(false)
                this.btnSendCard.active = true
                this.kuCunProgress.active = true
                cc.tween(this.node)
                    .delay(0.5)
                    .call(() => {
                        PrefabManage.showTextTips('麻将机中的麻将,也可以移回到工作台。', 2)
                    })
                    .delay(3.5)
                    .call(() => {
                        PrefabManage.showTextTips('恭喜完成新手引导,继续挑战吧!')
                    })
                    .start()
            }
        } else {
            // this.node.getChildByName('gameNode').getChildByName('chiZiNode').active = true
            // this.node.getChildByName('gameNode').getChildByName('xiWanChiJieSuoNode').active = true
        }
    }
    freshLinShiKaCao() {
        let unLock9 = NewDataManage_xmj.getTempUnLockAdsStatus(9)
        let unLock10 = NewDataManage_xmj.getTempUnLockAdsStatus(10)
        let unLock11 = NewDataManage_xmj.getTempUnLockAdsStatus(11)
        // let unLock13 = NewDataManage_xmj.getTempUnLockAdsStatus(13)
        if (unLock9) {
            // let times = NewDataManage_xmj.getUnlockAdsLeftTimer(9)
            this.diTu.getChildByName('line_9').getChildByName('ADSuoDing').active = false
            // this.paiContent.getChildByName('leftTimer_9').active = true
            // this.paiContent.getChildByName('leftTimer_9').getComponent(cc.Label).string = DateUtils.formatTime3_custom(times)
        } else {
            this.diTu.getChildByName('line_9').getChildByName('ADSuoDing').active = true
            // this.paiContent.getChildByName('leftTimer_9').active = false
            // NewDataManage_xmj.clearSingleLineData(9)
            // this.paiContent.getChildByName('line_9').removeAllChildren()
        }
        if (unLock10) {
            // let times = NewDataManage_xmj.getUnlockAdsLeftTimer(10)
            this.diTu.getChildByName('line_10').getChildByName('ADSuoDing').active = false
            // this.paiContent.getChildByName('leftTimer_10').active = true
            // this.paiContent.getChildByName('leftTimer_10').getComponent(cc.Label).string = DateUtils.formatTime3_custom(times)
        } else {
            this.diTu.getChildByName('line_10').getChildByName('ADSuoDing').active = true
            // this.paiContent.getChildByName('leftTimer_10').active = false
            // NewDataManage_xmj.clearSingleLineData(10)
            // this.paiContent.getChildByName('line_10').removeAllChildren()
        }
        if (unLock11) {
            // let times = NewDataManage_xmj.getUnlockAdsLeftTimer(11)
            this.diTu.getChildByName('line_11').getChildByName('ADSuoDing').active = false
            // this.paiContent.getChildByName('leftTimer_11').active = true
            // this.paiContent.getChildByName('leftTimer_11').getComponent(cc.Label).string = DateUtils.formatTime3_custom(times)
        } else {
            this.diTu.getChildByName('line_11').getChildByName('ADSuoDing').active = true
            // this.paiContent.getChildByName('leftTimer_11').active = false
            // NewDataManage_xmj.clearSingleLineData(11)
            // this.paiContent.getChildByName('line_11').removeAllChildren()
        }
        // if(unLock13){
        //     // let times = NewDataManage_xmj.getUnlockAdsLeftTimer(11)
        //     this.diTu.getChildByName('line_13').getChildByName('ADSuoDing').active = false
        //     // this.paiContent.getChildByName('leftTimer_11').active = true
        //     // this.paiContent.getChildByName('leftTimer_11').getComponent(cc.Label).string = DateUtils.formatTime3_custom(times)
        // }else{
        //     this.diTu.getChildByName('line_13').getChildByName('ADSuoDing').active = true
        //     // this.paiContent.getChildByName('leftTimer_11').active = false
        //     // NewDataManage_xmj.clearSingleLineData(11)
        //     // this.paiContent.getChildByName('line_11').removeAllChildren()
        // }
    }
    refreshAllXipan() {
        let yiXiaoChuNum = NewDataManage_xmj.getYiXiaoChuAllNum()
        console.log(yiXiaoChuNum, 'yiXiaoChuNum+++++++====')
        if (yiXiaoChuNum >= 0 && yiXiaoChuNum < 10) {
            this.labAllxipan.string = "000" + yiXiaoChuNum
        } else if (yiXiaoChuNum >= 10 && yiXiaoChuNum < 100) {
            this.labAllxipan.string = "00" + yiXiaoChuNum
        } else if (yiXiaoChuNum >= 100 && yiXiaoChuNum < 1000) {
            this.labAllxipan.string = "0" + yiXiaoChuNum
        } else {
            this.labAllxipan.string = yiXiaoChuNum + ''
        }

    }
    initStartContent() {

        let cellData = NewDataManage_xmj.getCellData()
        for (let i = 0; i < 12; i++) {
            this.paiContent.getChildByName('line_' + i).removeAllChildren()
            for (let j = 0; j < cellData[i].length; j++) {
                let card = cc.instantiate(this.singleMaJiang)
                card.active = true
                this.paiContent.getChildByName('line_' + i).addChild(card)
                let scale = this.getPanZiScale(i, j)
                card.scale = scale
                card.x = Math.floor(Math.random() * 11) - 5 + this.getPanZiOffsetX(scale, i, j)
                card.y = 10 * j
                card.getComponent(SingleMaJiang).setMaJiangSpFrame(cellData[i][j])
                card.attr({ lineIndex: i })

            }
        }
        this.refreshAllKaCao()
        this.initXiWanChiContent()
        // this.refreshShengJiLevel()
        // this.refreshXiWanChi2JieSuo()
        this.refreshLeftPanZiNum()
        this.refreshFinishProgress()
        this.freshLinShiKaCao()
        // this.refreshProgressNode(true)
        // this.setTuZiSpine()
        // this.refreshHeChengFlag(true)
        // this.checkXiPaiBtnShow()
    }
    // //设置单张牌位置
    // setCardPos(card,bDuiQi){
    //     if(bDuiQi){

    //     }
    //     card.x = Math.floor(Math.random()*11) - 5
    //     card.y = 10*j
    // }

    //设置盘子大小(上大下小,前大后小)
    getPanZiScale(lineIndex, yIndex) {
        let baseScale1 = 1//前大后小
        if (lineIndex == 0 || lineIndex == 1 || lineIndex == 2 || lineIndex == 9) {
            baseScale1 = 1
        } else if (lineIndex == 3 || lineIndex == 4 || lineIndex == 5 || lineIndex == 10) {
            baseScale1 = 0.95
        } else if (lineIndex == 6 || lineIndex == 7 || lineIndex == 8 || lineIndex == 11) {
            baseScale1 = 0.9
        }

        let baseScale2 = 1.3 + 0.01 * yIndex//上大下小 
        return baseScale1 * baseScale2
    }
    //获取盘子x轴的偏移量(左两列左偏,右两列右偏)
    getPanZiOffsetX(scale, lineIndex, yIndex) {
        let offsetX = 0
        return 0
        // if(lineIndex == 0 || lineIndex == 5 || lineIndex == 9){
        //     offsetX = -2*yIndex
        // }else if(lineIndex == 1 || lineIndex == 6 || lineIndex == 10){
        //     offsetX = -0.8*yIndex
        // }else if(lineIndex == 2 || lineIndex == 11){
        //     offsetX = 0
        // }else if(lineIndex == 3 || lineIndex == 7 || lineIndex == 12){
        //     offsetX = 0.8*yIndex
        // }else if(lineIndex == 4 || lineIndex == 8 || lineIndex == 13){
        //     offsetX = 2*yIndex
        // }
        // return scale*offsetX
    }

    //刷新已完成进度
    refreshFinishProgress() {
        let targetNum = NewDataManage_xmj.getGuanQiaTargetNum()
        let curGuanQiaFinishNum = NewDataManage_xmj.getCurGuanQiaFinishNum()
        let curGuanQiaNum = NewDataManage_xmj.getCurGuanQiaNum()

        // this.jinDuProgress.getComponent(cc.ProgressBar).progress = curGuanQiaFinishNum/targetNum
        // this.jinDuProgress.getChildByName('numStr').getComponent(cc.Label).string = `${Math.floor(curGuanQiaFinishNum/targetNum * 100 * 10)/10}%`//`${curGuanQiaFinishNum}/${targetNum}`
        // this.jinDuProgress.getChildByName('diJiGuan').getComponent(cc.Label).string = `第${curGuanQiaNum}关`
        this.refreshLeftPanZiNum();
        EventMgr.emitEvent_custom(ryw_Event.freshGuanQiaProgress)
    }
    refreshLeftPanZiNum() {
        let num = NewDataManage_xmj.getLeftPanZiNum()
        let maxNum = NewDataManage_xmj.getChuShiKuCun()
        this.kuCunProgress.getComponent(cc.ProgressBar).progress = num / maxNum
        this.leftPanZiNum.getComponent(cc.Label).string = `${num}/${maxNum}`

        let unlock_cell = NewDataManage_xmj.getUnlockCell()
        //应发牌数量
        let faPaiNum = (unlock_cell + 1) * 6
        let leftPanZiNum = NewDataManage_xmj.getLeftPanZiNum()
        if (this.firstIn) {
            return
        }
        if (leftPanZiNum < faPaiNum) {

            this.btnSendCard.active = false
            this.btnBuHuo.active = true
            return false
        } else {
            this.btnSendCard.active = true
            this.btnBuHuo.active = false
            // NewDataManage_xmj.subLeftPanZiNum(faPaiNum)
            // this.refreshLeftPanZiNum()
            return true
        }
    }
    onBtnJieSuoXiWanChiClick() {
        // let jieSuoMoney = NewDataManage_xmj.getKaCaoJieSuoCoin('ChiZi_13')
        // let money = Common5.getCurMoney()
        // if(money >= jieSuoMoney){
        //     Common5.subMoney(jieSuoMoney)
        //     NewDataManage_xmj.setUnlockAdsXiWanChi2(true)
        //     this.refreshXiWanChi2JieSuo()
        //     PrefabManage.showTextTips('解锁成功')
        // }else{
        //     PrefabManage.showTextTips('金币不足')
        // }
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    GameReport.ADReport('解锁洗碗池', 1, '洗麻将')
                    Common5.ReportDY("inLevel", '游戏-AD-解锁洗碗池');
                    NewDataManage_xmj.setUnlockAdsXiWanChi2(true)
                    this.refreshXiWanChi2JieSuo()
                    PrefabManage.showTextTips('解锁成功')
                }
                else {
                    GameReport.ADReport('解锁洗碗池', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }
    refreshXiWanChi2JieSuo() {
        let unlock_adsXiWanChi2 = NewDataManage_xmj.getUnlockAdsXiWanChi2()
        if (unlock_adsXiWanChi2) {
            this.chiZiNode.getChildByName('chiZi_15').active = true
            // this.chiZiDiTu.getChildByName('chiZi_15').active = true
            // this.node.getChildByName('gameNode').getChildByName('xiWanChiJieSuoNode').active = false

        } else {
            this.chiZiNode.getChildByName('chiZi_15').active = false
            // this.chiZiDiTu.getChildByName('chiZi_15').active = false
            // this.node.getChildByName('gameNode').getChildByName('xiWanChiJieSuoNode').active = true
        }
        // let jieSuoMoney = NewDataManage_xmj.getKaCaoJieSuoCoin('ChiZi_13')
        // this.chiZiNode.getChildByName('xiWanChiJieSuoNode').getChildByName('money').getComponent(cc.Label).string = ''+jieSuoMoney
    }
    initXiWanChiContent() {
        let cellData = NewDataManage_xmj.getCellData()
        for (let i = 12; i <= 12; i++) {

            for (let j = 0; j < cellData[i].length; j++) {
                let card = cc.instantiate(this.singleMaJiang)
                card.active = true
                // this.chiZiNode.getChildByName('chiZi_'+i).addChild(card)
                this.chiZiNode.getChildByName('chiZi_' + i).getChildByName('panZi_' + (j % 24)).addChild(card)
                card.x = 0
                card.y = 0
                card.getComponent(SingleMaJiang).setMaJiangSpFrame(cellData[i][j])
                card.attr({ lineIndex: i })
            }
        }
        // let coinNum = NewDataManage_xmj.getKaCaoJieSuoCoin('ChiZi_13')
        // this.chiZiNode.getChildByName('kaCaoNode1').getChildByName('money').getComponent(cc.Label).string = ''+ coinNum
    }
    // checkXiPaiBtnShow(){
    //     let kongGeNum = NewDataManage_xmj.getAllKongGeNum()
    //     if(kongGeNum >= 8){
    //         this.btn_xiPai.active = false
    //     }else{
    //         this.btn_xiPai.active = true
    //     }

    // }
    onLineClick(customData) {
        console.log('选中音效')
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/选中")
        VibrateMgr.vibrateShort_custom();
        //目标列正在操作中
        if (this.curTargetLineTab.indexOf(customData) > -1) {
            return
        }
        if (this.isAction || this.isFaPaing) {
            return
        }
        // if(this.isAction){
        //     return
        // }
        if (customData == 12 && this.isKaCao1HeChenging) {
            return
        } else if (customData == 13 && this.isKaCao2HeChenging) {
            return
        }
        if (this.firstIn) {
            if (customData == 1) {
                if (this.curSelectLineData.length > 0) {
                    return
                }
                if (this.xinShouYinDaoStepIndex == 0) {
                    this.xinShouYinDaoStepIndex++
                    // User.setGuideStep_xmj(this.xinShouYinDaoStepIndex)
                    this.checkXinShouYinDao()
                } else {
                    return
                }

            } else if (customData == 0) {
                if (this.xinShouYinDaoStepIndex == 1) {
                    this.xinShouYinDaoStepIndex++
                    // User.setGuideStep_xmj(this.xinShouYinDaoStepIndex)
                    this.checkXinShouYinDao()
                } else if (this.xinShouYinDaoStepIndex == 2) {
                    this.xinShouYinDaoStepIndex++
                    // User.setGuideStep_xmj(this.xinShouYinDaoStepIndex)
                    this.checkXinShouYinDao()
                } else {
                    return
                }

            } else if (customData == 12) {
                if (this.xinShouYinDaoStepIndex == 3) {
                    this.xinShouYinDaoStepIndex++
                    // User.setGuideStep_xmj(this.xinShouYinDaoStepIndex)
                    this.checkXinShouYinDao()
                } else {
                    return
                }
            }
        }

        let unlock_cell = NewDataManage_xmj.getUnlockCell()
        if (parseInt(customData) == 9 || parseInt(customData) == 10 || parseInt(customData) == 11) {
            //看广告解锁临时牌区
            if (!NewDataManage_xmj.getTempUnLockAdsStatus(customData)) {
                let tab = {
                    onClose: (finish) => {
                        if (finish) {
                            GameReport.ADReport('解锁临时区', 1, '洗麻将')
                            Common5.ReportDY("inLevel", '游戏-AD-解锁临时区');
                            NewDataManage_xmj.setUnlockAds(customData, true)
                            this.freshLinShiKaCao()
                            // NewDataManage_xmj.setUnlockAdsLeftTimer(customData)
                            // this.jieSuoKaCao(true,customData)
                        }
                        else {
                            GameReport.ADReport('解锁临时区', 0, '洗麻将')
                            Common5.showTips_custom("广告未观看完");
                        }
                    }, onFailed: () => {

                    }
                }
                AppPlatform.playVideo_custom(tab)

                return
            } else {

            }
        } else if (parseInt(customData) > unlock_cell && parseInt(customData) <= 8) {
            // PrefabManage.showTextTips('该列暂未解锁')
            return
        }
        // 使用锤子道具
        if (customData <= 11) {
            let childrenNum = this.paiContent.getChildByName('line_' + customData).childrenCount
            if (this.isStartChuiZiDaoJu && childrenNum > 0) {
                this.isAction = true
                NewDataManage_xmj.clearSingleLineData(customData)

                let topChild = this.paiContent.getChildByName('line_' + customData).children[childrenNum - 1]
                Common5.setNodeToTargetPos(this.chuiZiNode.getChildByName('chuiZiSpine'), topChild)
                this.chuiZiNode.getChildByName('chuiZiSpine').getComponent(sp.Skeleton).setAnimation(0, 'chuizi', false)
                cc.tween(this.node)
                    .delay(0.3)
                    .call(() => {
                        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/锤子")
                        this.diTu.getChildByName('line_' + customData).getChildByName('missSpine').active = true
                        this.diTu.getChildByName('line_' + customData).getChildByName('missSpine').getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
                        // console.log('yaSuiNumTab[i]==',i,yaSuiNumTab[i])
                        //牌移动及压碎
                        for (let k = 0; k < childrenNum; k++) {
                            let cardScale = this.getPanZiScale(customData, 0)
                            let card_pre = this.paiContent.getChildByName('line_' + customData).children[k]
                            let xOffset = this.getPanZiOffsetX(cardScale, customData, 0) + Math.floor(Math.random() * 11) - 5
                            let yOffset = 0
                            cc.tween(card_pre)
                                .to(0.2, { x: xOffset, y: yOffset, scale: cardScale }, {
                                    onUpdate: (target, ratio: number) => {
                                        if (card_pre.y <= 0) {
                                            card_pre.removeFromParent()
                                        }
                                    }
                                })
                                .start()
                        }

                        this.scheduleOnce(() => {
                            this.diTu.getChildByName('line_' + customData).getChildByName('missSpine').active = false
                            this.isAction = false
                        }, 1)
                    })
                    .delay(0.8)
                    .call(() => {
                        cc.tween(this.chuiZiNode)
                            .to(0.2, { scale: 0 })
                            .call(() => {
                                this.chuiZiNode.active = false
                            })
                            .start()

                    })
                    .start()
                this.isStartChuiZiDaoJu = false
                return
            }
        }


        //未选择牌(首次选中)
        if (this.curSelectLineData.length <= 0) {
            this.curSelectLineData = NewDataManage_xmj.getLineCellSelectData(customData)
            //改变zIndex,可保证移动的牌在最上层
            if (parseInt(customData) <= 11) {

            }

            //有牌被选中
            if (this.curSelectLineData.length > 0) {
                this.curSelectLineIndex = customData
                this.selectCardAni()
            } else {
                this.curSelectLineIndex = -1
            }
            console.log('当列选中的牌数据==', this.curSelectLineData)
        } else {
            //重复点击了选中列(取消选中)
            if (customData == this.curSelectLineIndex) {
                //这里执行取消牌操作
                this.cancelCardAni()
                this.curSelectLineData = []
                this.curSelectLineIndex = -1
                //判断可否移动牌(用当前选中行数据和上次选中数据判断)
            } else {
                //当前选中
                let curSeLineData = NewDataManage_xmj.getLineCellSelectData(customData)

                let moveFunc = (canMoveData, yiPaiQianData) => {
                    this.moveCardNodeLine1ToLine2(canMoveData, yiPaiQianData, this.curSelectLineIndex, customData)
                }
                //检测并移动牌
                NewDataManage_xmj.MoveCellLine1ToLine2(this.curSelectLineData, this.curSelectLineIndex, curSeLineData, customData, moveFunc)
            }
        }
    }
    // onCloseShuiChiTiShi(){
    //     this.shuiChiTiShi.active = false
    // }
    onPaiQuItemClick(event, customData) {
        let unlock_cell = NewDataManage_xmj.getUnlockCell()
        let money = Common5.getCurZuanShi()
        let jieSuoMoney = 0
        if (customData >= 0 && customData <= 8) {
            jieSuoMoney = NewDataManage_xmj.getKaCaoJieSuoCoin('KaCao_' + customData)
            //已解锁的上一格
            if (parseInt(customData) - unlock_cell == 1) {
                if (jieSuoMoney < 0) {
                    let tab = {
                        onClose: (finish) => {
                            if (finish) {
                                Common5.ReportDY("inLevel", '游戏-AD-解锁成功卡槽' + customData);
                                GameReport.ADReport('解锁成功卡槽', 1, '洗麻将')
                                NewDataManage_xmj.jieSuoUnlockCell(parseInt(customData))
                                this.refreshAllKaCao()
                                this.refreshLeftPanZiNum()
                                PrefabManage.showTextTips('解锁成功')
                                // if(customData == 4){
                                //     // this.shuiChiTiShi.active = true
                                //     PrefabManage.loadPrefabByType(GameType.ShuiChiTiShi)
                                // }
                                return
                            }
                            else {
                                GameReport.ADReport('解锁成功卡槽', 0, '洗麻将')
                                Common5.showTips_custom("广告未观看完");
                            }
                        }, onFailed: () => {

                        }
                    }
                    AppPlatform.playVideo_custom(tab)
                } else {
                    if (money >= jieSuoMoney) {
                        Common5.subZuanShi(jieSuoMoney)
                        NewDataManage_xmj.jieSuoUnlockCell(parseInt(customData))
                        this.refreshAllKaCao()
                        this.refreshLeftPanZiNum()
                        PrefabManage.showTextTips('解锁成功')
                        // if(customData == 4){
                        //     PrefabManage.loadPrefabByType(GameType.ShuiChiTiShi)
                        //     // this.shuiChiTiShi.active = true
                        // }
                        return
                    } else {
                        PrefabManage.showTextTips('金币不足')
                        return
                    }
                }

            } else if (parseInt(customData) - unlock_cell > 1) {
                // PrefabManage.showTextTips('请先解锁上个格子')
                return
            }

        }

        this.onLineClick(customData)
    }
    onSingleCardClick(event) {
        let lineIndex = event.target.lineIndex
        this.onLineClick(lineIndex)
    }
    //贝塞尔曲线
    nodeMoving(node, i, localPos, maxLength, xDis, line2DataLength, targetNode, line2Index, cardScale) { //node为做抛物线运动的节点

        let startPos = node.position //起点,抛物线开始的坐标
        let middlePos = cc.v2(node.position.x + /*(localPos.x-node.x)*/xDis / 4 + i / maxLength * xDis / 2, line2DataLength * 20 + localPos.y + 300 + 20 * i) //中间坐标,即抛物线最高点坐标
        let destPos = localPos//cc.v2(node.position.x + 200, node.position.y) //终点,抛物线落地点
        //计算贝塞尔曲线坐标函数
        let twoBezier = (t: number, p1, cp, p2) => {
            let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
            let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
            return cc.v2(x, y);
        };
        let tweenDuration: number = 0.28;
        let isFlip = false
        let setNodeParent = () => {
            //目标节点的本地坐标
            let targetLocalPos = node.getPosition()
            //目标节点的世界坐标
            let targetWorldPos = node.parent.convertToWorldSpaceAR(targetLocalPos)

            node.parent = targetNode
            //目标节点相对于当前节点父节点的本地坐标
            let localPos = targetNode.convertToNodeSpaceAR(targetWorldPos)
            node.setPosition(localPos)
            node.lineIndex = line2Index
        }
        cc.tween(node)
            .to(tweenDuration, { position: destPos, scale: cardScale }, {
                onUpdate: (target, ratio: number) => {
                    if (ratio >= 0.5 && !isFlip) {
                        isFlip = true
                        node.zIndex = this.curZIndex++
                    }
                    // console.log('onUpdate===',ratio)
                    node.position = twoBezier(ratio, startPos, middlePos, destPos);

                }
            })
            .delay(0.01)
            .call(() => {
                setNodeParent()
            })
            .start();
    }
    //移牌
    moveCardNodeLine1ToLine2(canMoveData, yiPaiQianData, line1Index, line2Index) {

        if (canMoveData.length <= 0) {
            this.cancelCardAni()
        }
        // 
        this.curSelectLineData = []
        this.curSelectLineIndex = -1

        // this.isAction = true
        console.log('canMoveData,line1Index,line2Index==', canMoveData, line1Index, line2Index)
        //有牌可移动
        if (canMoveData.length > 0) {
            this.curTargetLineTab.push(line2Index)
            //将line1可移动的牌移动到line2
            // let cellData = NewDataManage_xmj.getCellData()
            let line2CellData = yiPaiQianData[line2Index]
            //临时区关闭(必须全部移出才关闭)
            if ((line1Index == 9 || line1Index == 10 || line1Index == 11) && yiPaiQianData[line1Index].length == canMoveData.length) {
                NewDataManage_xmj.setUnlockAds(line1Index, false)
                this.freshLinShiKaCao()
                // this.jieSuoKaCao(true,line1Index)
            }

            let delayTim1 = 0.01
            let delayTim2 = 0.04
            let xDis = 0
            // //正常牌堆
            // if(line1Index <= 11){
            //     xDis = this.paiContent.getChildByName('line_'+line2Index).x - this.paiContent.getChildByName('line_'+line1Index).x 
            // //水槽
            // }else{
            //     xDis = this.chiZiNode.getChildByName('chiZi_'+line2Index).x - this.paiContent.getChildByName('line_'+line1Index).x 
            // }
            let line2PosX = 0
            let line1PosX = 0
            let isLine1ShuiCao = (line1Index >= 12)

            if (isLine1ShuiCao) {
                line1PosX = this.chiZiNode.getChildByName('chiZi_' + line1Index).x
            } else {
                line1PosX = this.paiContent.getChildByName('line_' + line1Index).x
            }

            let isLine2ShuiCao = (line2Index >= 12)
            if (isLine2ShuiCao) {
                line2PosX = this.chiZiNode.getChildByName('chiZi_' + line2Index).x
            } else {
                line2PosX = this.paiContent.getChildByName('line_' + line2Index).x
            }
            xDis = line2PosX - line1PosX

            for (let i = 0; i < canMoveData.length; i++) {
                // let targetNode = this.chiZiNode.getChildByName('chiZi_'+line2Index).getChildByName('panZi_'+(i%12))
                let card = null
                //正常牌堆
                if (!isLine1ShuiCao) {
                    card = this.paiContent.getChildByName('line_' + line1Index).children[canMoveData[i].index]
                    //水槽
                } else {
                    card = this.chiZiNode.getChildByName('chiZi_' + line1Index).getChildByName('panZi_' + canMoveData[i].index).getChildByName('singleMaJiang')
                }
                let targetNode = null
                //正常牌堆
                if (!isLine2ShuiCao) {
                    targetNode = this.paiContent.getChildByName('line_' + line2Index)
                    //水槽
                } else {
                    targetNode = this.chiZiNode.getChildByName('chiZi_' + line2Index).getChildByName('panZi_' + ((line2CellData.length + i) % 24))
                }

                if (card && targetNode) {
                    let cardScale = this.getPanZiScale(line2Index, line2CellData.length + i)
                    // console.log('cardScale===',i,cardScale)
                    let localPos = Common5.getNodeToTargetPos(card, targetNode)
                    let localPos2 = cc.v2(localPos.x + Math.floor(Math.random() * 11) - 5 + this.getPanZiOffsetX(cardScale, line2Index, line2CellData.length + i), localPos.y + (line2CellData.length + i) * 10)
                    if (isLine2ShuiCao) {
                        localPos2 = localPos
                    }
                    //进入水槽,不改缩放
                    if (isLine2ShuiCao) {
                        cardScale = 1
                    }
                    cc.tween(this.node)
                        .delay(delayTim1 + i * delayTim2)
                        .call(() => {
                            // console.log('盘子移动音效==')
                            Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/盘子移动")

                            this.nodeMoving(card, i, localPos2, canMoveData.length, xDis, line2CellData.length, targetNode, line2Index, cardScale)
                        })
                        .start()

                    // cc.tween(card)
                    //     .to(delayTim1+i*delayTim2,{x:localPos.x,y:localPos.y+(line2CellData.length+canMoveData.length-1-i)*10})
                    //     .call(()=>{
                    //         Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/移动牌单张音效")
                    //     })
                    // .start()
                    //移完后更换父节点
                    // cc.tween(this.node)
                    //     .delay(delayTim1+canMoveData.length*delayTim2+4)
                    //     .call(()=>{
                    //         card.setPosition(cc.v2(0,(line2CellData.length+canMoveData.length-1-i)*10))
                    //         card.parent = targetNode

                    //     })
                    // .start()
                }
            }
            //移完最后一张牌回调刷新最新牌数据
            this.scheduleOnce(() => {
                // finishMoveAllCallFunc && finishMoveAllCallFunc(canMoveData,line1Index,line2Index)
                // this.cancelCardAni()
                // this.curSelectLineData = []
                // this.curSelectLineIndex = -1
                // this.refreshHeChengFlag(true)
                // this.checkXiPaiBtnShow()
                // this.isAction = false
                if (line2Index >= 12 && line2Index <= 12) {
                    this.onBtnClickHeCheng(line2Index)
                }
                this.curTargetLineTab.splice(this.curTargetLineTab.indexOf(2), 1)
            }, delayTim1 + canMoveData.length * delayTim2 + 0.3)
            //无牌可移动
        } else {
            //底座抖动

            VibrateMgr.vibrateShort_custom();
            if (line2Index < 12) {
                cc.tween(this.paiContent.getChildByName('line_' + line2Index))
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .start()
                cc.tween(this.diTu.getChildByName('line_' + line2Index))
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .start()
            } else if (line2Index >= 12) {
                cc.tween(this.chiZiNode.getChildByName('chiZi_' + line2Index))
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .by(0.05, { x: -8 })
                    .by(0.05, { x: 8 })
                    .start()
                // cc.tween(this.chiZiDiTu.getChildByName('chiZi_'+line2Index))
                //     .by(0.05,{x:-8})
                //     .by(0.05,{x:8})
                //     .by(0.05,{x:-8})
                //     .by(0.05,{x:8})
                //     .by(0.05,{x:-8})
                //     .by(0.05,{x:8})
                // .start()
            }

            this.cancelCardAni()
            this.curSelectLineData = []
            this.curSelectLineIndex = -1
            this.isAction = false
        }
    }
    //选中牌动作
    selectCardAni() {
        this.isAction = true
        //洗碗池
        if (this.curSelectLineIndex >= 12 && this.curSelectLineIndex <= 12) {
            // this.chiZiNode.getChildByName('chiZi_'+i).getChildByName('panZi_'+(j%12)).addChild(card)
            for (let i = 0; i < this.curSelectLineData.length; i++) {
                let card = this.chiZiNode.getChildByName('chiZi_' + this.curSelectLineIndex).getChildByName('panZi_' + (this.curSelectLineData[i].index)).getChildByName('singleMaJiang')
                if (card) {
                    let x = card.x
                    let y = card.y + 50
                    cc.tween(card)
                        .to(0.2, { x: 0, y: y })
                        .start()
                }
            }
        } else {
            for (let i = 0; i < this.curSelectLineData.length; i++) {
                let cardScale = this.getPanZiScale(this.curSelectLineIndex, this.curSelectLineData[i].index)
                let card = this.paiContent.getChildByName('line_' + this.curSelectLineIndex).children[this.curSelectLineData[i].index]
                if (card) {
                    let x = card.x
                    let y = card.y + 20
                    cc.tween(card)
                        .to(0.2, { x: this.getPanZiOffsetX(cardScale, this.curSelectLineIndex, this.curSelectLineData[i].index), y: y })
                        .start()
                }
            }
        }

        this.scheduleOnce(() => {
            this.isAction = false
        }, 0.21)
    }
    //取消选中牌
    cancelCardAni() {
        //洗碗池
        if (this.curSelectLineIndex >= 12 && this.curSelectLineIndex <= 12) {
            for (let i = 0; i < this.curSelectLineData.length; i++) {
                let card = this.chiZiNode.getChildByName('chiZi_' + this.curSelectLineIndex).getChildByName('panZi_' + (this.curSelectLineData[i].index)).getChildByName('singleMaJiang')
                if (card) {
                    let x = 0
                    let y = card.y - 50
                    cc.tween(card)
                        .to(0.2, { x: x, y: y })
                        .start()
                }
            }
        } else {
            for (let i = 0; i < this.curSelectLineData.length; i++) {
                let cardScale = this.getPanZiScale(this.curSelectLineIndex, this.curSelectLineData[i].index)
                let card = this.paiContent.getChildByName('line_' + this.curSelectLineIndex).children[this.curSelectLineData[i].index]
                if (card) {
                    let x = Math.floor(Math.random() * 11) - 5 + this.getPanZiOffsetX(cardScale, this.curSelectLineIndex, this.curSelectLineData[i].index)
                    let y = card.y - 20
                    cc.tween(card)
                        .to(0.2, { x: x, y: y })
                        .start()
                }
            }
        }

    }
    onBtnClickBuHuo() {
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    Common5.ReportDY("inLevel", '游戏-AD-补货');
                    let maxNum = NewDataManage_xmj.getChuShiKuCun()
                    GameReport.ADReport('补货', 1, '洗麻将')
                    NewDataManage_xmj.addLeftPanZiNum(maxNum)
                    this.refreshLeftPanZiNum()
                }
                else {
                    GameReport.ADReport('补货', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }

    changeTili(isAdd, chiziNode?: cc.Node) {
        return
        console.log(isAdd, 'changeTili')

        if (isAdd) {
            //动画
            //找到暗的电池
            let node = null
            for (let i = 0; i < this.fapaiNode.childrenCount; i++) {
                if (this.fapaiNode.children[i].getChildByName('亮')) {
                    if (!this.fapaiNode.children[i].getChildByName('亮').active) {
                        node = this.fapaiNode.children[i]
                        break
                    }
                }


            }
            if (!node) {
                node = this.fapaiNode.children[0]
            }

            let posi = node.getPosition()
            let dianSpine = this.fapaiNode.getChildByName('电光')
            dianSpine.active = true

            dianSpine.scale = 1
            Common5.setNodeToTargetPos(dianSpine, chiziNode)
            cc.tween(dianSpine)
                .delay(1.5)
                .to(0.5, { x: posi.x, y: posi.y })
                .call(() => {
                    dianSpine.active = false
                    dianSpine.setPosition(cc.v2(185, 300))
                    let index = User.getSendPZIndex()
                    console.log(index, 'btn_faPai+++++++++++===')
                    if (index >= 2) {
                        index = 2
                    }
                    for (let i = 0; i < this.fapaiNode.childrenCount; i++) {
                        if (this.fapaiNode.children[i].getChildByName('亮')) {
                            this.fapaiNode.children[i].getChildByName('亮').active = false
                        }

                    }
                    for (let i = 0; i < index; i++) {
                        if (this.fapaiNode.children[i].getChildByName('亮')) {
                            this.fapaiNode.children[i].getChildByName('亮').active = true
                        }

                    }
                })
                .start()
        } else {
            let index = User.getSendPZIndex()
            console.log(index, 'btn_faPai+++++++++++===')
            if (index >= 2) {
                index = 2
            }
            for (let i = 0; i < this.fapaiNode.childrenCount; i++) {
                if (this.fapaiNode.children[i].getChildByName('亮')) {
                    this.fapaiNode.children[i].getChildByName('亮').active = false
                }

            }
            for (let i = 0; i < index; i++) {
                if (this.fapaiNode.children[i].getChildByName('亮')) {
                    this.fapaiNode.children[i].getChildByName('亮').active = true
                }

            }
        }
    }

    onBtnClickFaPai2() {
        console.log('this.isFaPaing?==', this.isFaPaing)
        if (this.isAction || this.isFaPaing) {
            return
        }


        if (this.firstIn) {
            this.xinShouYinDaoStepIndex++
            // User.setGuideStep_xmj(this.xinShouYinDaoStepIndex)
            this.checkXinShouYinDao()
        }

        if (NewDataManage_xmj.checkIsCanSendCard()) {
            PrefabManage.showTextTips('工作台已满不可继续发盘!', 2)
            return
        }

        // if(!NewDataManage_xmj.isCanContinueGame()){
        //     this.shouziIndex++
        //     if(this.shouziIndex>=2){
        //         PrefabManage.showTextTips('走不动了吗?快使用变色道具吧!',5)
        //         this.shouziIndex = 0
        //         this.shouzhiNode.active = true
        //         if(this.isShouzhiShow){

        //         }else{
        //             this.isShouzhiShow = true
        //             this.scheduleOnce(()=>{
        //                 this.isShouzhiShow = false
        //                 this.shouzhiNode.active = false
        //             },5.0)
        //         }
        //     }else{
        //         PrefabManage.showTextTips('发牌机电量不⾜, 运转麻将机可为发牌机充电',2)
        //     }


        //     return
        // }
        NewDataManage_xmj.subSendPZIndex()
        // Common5.curGameSendCard++
        Common5.onHideState.sendCardTimes++
        this.changeTili(false)

        this.isFaPaing = true
        let unlock_cell = NewDataManage_xmj.getUnlockCell()

        //应发牌数量
        let faPaiNum = (unlock_cell + 1) * 6
        let leftPanZiNum = NewDataManage_xmj.getLeftPanZiNum()
        if (leftPanZiNum < faPaiNum) {
            PrefabManage.showTextTips('剩余盘子数量不足,请补货')
            this.refreshLeftPanZiNum()
            this.isFaPaing = false
            return
        } else {
            NewDataManage_xmj.subLeftPanZiNum(faPaiNum)
            this.refreshLeftPanZiNum()
        }



        this.btnSendCard.opacity = 150

        this.cancelCardAni()
        this.curSelectLineData = []
        this.curSelectLineIndex = -1

        // let cellData = NewDataManage_xmj.getCellData()

        let sendCardCallFunc = (faPaiData, faPaiQianData, faPaiHouData, yaSuiNumTab) => {
            Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/麻将发牌")
            let delayTim1 = 0.01
            let delayTim2 = 0.04
            let delayTim3 = 0.02
            let isHaveYaSui = false//是否有压碎的情况
            for (let n = 0; n < yaSuiNumTab.length; n++) {
                if (yaSuiNumTab[n] > 0) {
                    isHaveYaSui = true
                    console.log('isHaveYaSui===true')
                }
            }
            for (let i = 0; i <= unlock_cell; i++) {
                let lineData = faPaiData['line_' + i]
                if (lineData) {
                    for (let j = 0; j < lineData.length; j++) {
                        let card = cc.instantiate(this.singleMaJiang)
                        card.active = true
                        card.getComponent(SingleMaJiang).setMaJiangSpFrame(lineData[j])
                        this.paiContent.getChildByName('line_' + i).addChild(card)
                        card.zIndex = this.curZIndex++
                        card.attr({ lineIndex: i })
                        let cardScale = this.getPanZiScale(i, (faPaiQianData[i].length + j))
                        Common5.setNodeToTargetPos(card, this.faPaiStartNode)//新加
                        let x = Math.floor(Math.random() * 11) - 5 + this.getPanZiOffsetX(cardScale, i, (faPaiQianData[i].length + j))
                        let y = (faPaiQianData[i].length + j) * 10

                        let localPos = Common5.getNodeToTargetPos(card, this.paiContent.getChildByName('line_' + i))//新加
                        let localPos2 = cc.v2(localPos.x + x, localPos.y + y)//新加

                        let xDis = this.paiContent.getChildByName('line_' + i).x - this.btnSendCard.x

                        cc.tween(this.node)
                            .delay(delayTim1 + delayTim3 * i + j * delayTim2 + 0.01)
                            .call(() => {
                                this.nodeMoving(card, j, localPos2, lineData.length, xDis, faPaiQianData[i].length, this.paiContent.getChildByName('line_' + i), i, cardScale)
                            })
                            .start()
                    }
                }
                //压碎数量
                this.scheduleOnce(() => {
                    if (yaSuiNumTab[i] > 0) {
                        this.diTu.getChildByName('line_' + i).getChildByName('missSpine').active = true
                        this.diTu.getChildByName('line_' + i).getChildByName('missSpine').getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
                        // console.log('yaSuiNumTab[i]==',i,yaSuiNumTab[i])
                        //牌移动及压碎
                        for (let k = 0; k < faPaiHouData[i].length; k++) {
                            let cardScale = this.getPanZiScale(i, k - yaSuiNumTab[i])
                            let card_pre = this.paiContent.getChildByName('line_' + i).children[k]
                            let xOffset = this.getPanZiOffsetX(cardScale, i, k - yaSuiNumTab[i]) + Math.floor(Math.random() * 11) - 5
                            let yOffset = card_pre.y - yaSuiNumTab[i] * 10
                            cc.tween(card_pre)
                                .to(0.2, { x: xOffset, y: yOffset, scale: cardScale }, {
                                    onUpdate: (target, ratio: number) => {
                                        if (card_pre.y < 0 && k < yaSuiNumTab[i]) {
                                            card_pre.removeFromParent()
                                        }
                                    }
                                })
                                .start()
                        }

                        this.scheduleOnce(() => {
                            this.diTu.getChildByName('line_' + i).getChildByName('missSpine').active = false
                        }, 1)
                    }
                    this.scheduleOnce(() => {
                        if (i == unlock_cell) {
                            this.btnSendCard.opacity = 255
                            this.isFaPaing = false
                        }
                    }, 0.21)

                }, delayTim1 + delayTim3 * i + lineData.length * delayTim2 + 0.3)
            }
        }
        NewDataManage_xmj.getSendCardData(sendCardCallFunc)
        // NewDataManage_xmj.setFaPaiData(sendCardCallFunc)
    }
    chuiziClear() {
        // this.scheduleOnce(()=>{
        //     if(yaSuiNumTab[i] > 0){
        //         this.diTu.getChildByName('line_'+i).getChildByName('missSpine').active = true
        //         this.diTu.getChildByName('line_'+i).getChildByName('missSpine').getComponent(sp.Skeleton).setAnimation(0,'animation',false)
        //         // console.log('yaSuiNumTab[i]==',i,yaSuiNumTab[i])
        //         //牌移动及压碎
        //         for(let k=0;k<faPaiHouData[i].length;k++){
        //             let cardScale = this.getPanZiScale(i,k-yaSuiNumTab[i])
        //             let card_pre = this.paiContent.getChildByName('line_'+i).children[k]
        //             let xOffset = this.getPanZiOffsetX(cardScale,i,k-yaSuiNumTab[i])+Math.floor(Math.random()*11) - 5
        //             let yOffset = card_pre.y-yaSuiNumTab[i]*10
        //             cc.tween(card_pre)
        //                 .to(0.2,{x:xOffset,y:yOffset,scale:cardScale}, { 
        //                     onUpdate: (target, ratio: number) => {
        //                         if(card_pre.y <0 &&  k<yaSuiNumTab[i]){
        //                             card_pre.removeFromParent()
        //                         }
        //                 }})
        //             .start()
        //         }

        //         this.scheduleOnce(()=>{
        //             this.diTu.getChildByName('line_'+i).getChildByName('missSpine').active = false
        //         },1)
        //     }
        //     this.scheduleOnce(()=>{
        //         if(i== unlock_cell){
        //             this.btnSendCard.opacity =  255
        //             this.isFaPaing = false
        //         }
        //     },0.21)

        // },delayTim1+delayTim3*i+lineData.length*delayTim2+0.3)
    }
    onBtnClickHeCheng(line2Index) {
        // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        // if(this.isAction ){
        //     return
        // }
        let heChengQianColorNum = NewDataManage_xmj.getJieSuoColorNum()
        let heChengCallFunc = (heChengTab, heChengQianData, heChengQianColorAccount, heChengHouColorAccount) => {
            if (heChengTab.length > 0) {
                //Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/洗碗")
                if (line2Index == 12) {
                    this.isKaCao1HeChenging = true
                } else if (line2Index == 13) {
                    this.isKaCao2HeChenging = true
                }
            } else {
                return
            }
            let panZiIndex = 0
            if (line2Index == 12) {
                panZiIndex = 0
            } else if (line2Index == 13) {
                panZiIndex = 1
            }
            let singlePanZiCoin = NewDataManage_xmj.getPerPanZiPrice(panZiIndex)
            let panZiNum = 0
            let addAward = 0
            for (let i = 0; i < heChengTab.length; i++) {
                let chiziNode = this.chiZiNode.getChildByName('chiZi_' + heChengTab[i].line)
                // chiziNode.getChildByName('paoPaoSpine').active = true
                // chiziNode.getChildByName('paoPaoSpine').getComponent(sp.Skeleton).setAnimation(0,'肥皂泡星星',false)

                panZiNum += heChengQianData[heChengTab[i].line].length
                addAward = panZiNum * singlePanZiCoin

                cc.tween(this.node)
                    .delay(0.5 + 0.2)
                    .call(() => {
                        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/麻将消除")
                        this.chiZiNode.getChildByName('leftClearNode').getChildByName('spine').active = true
                        this.chiZiNode.getChildByName('leftClearNode').getChildByName('spine').getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
                        this.chiZiNode.getChildByName('rightClearNode').getChildByName('spine').active = true
                        this.chiZiNode.getChildByName('rightClearNode').getChildByName('spine').getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
                    })
                    .delay(1)
                    .call(() => {

                        this.chiZiNode.getChildByName('leftClearNode').getChildByName('spine').active = false
                        this.chiZiNode.getChildByName('rightClearNode').getChildByName('spine').active = false
                    })
                    .start()
                for (let j = 0; j < 24; j++) {
                    let cardnode = chiziNode.getChildByName('panZi_' + j)

                    for (let k = 0; k < cardnode.childrenCount; k++) {
                        //向左洗牌
                        if (j % 12 < 6) {
                            let localPos = Common5.getNodeToTargetPos(cardnode.children[k], this.chiZiNode.getChildByName('leftClearNode'))
                            let node = cardnode.children[k]
                            cc.tween(node)
                                .delay(0.5 + (j % 6) * 0.05)
                                .to(0.4, { x: localPos.x, y: localPos.y, scale: 0.8 })
                                .call(() => {
                                    // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/麻将掉落")
                                    node.removeFromParent()
                                })
                                .start()
                            //向右洗牌
                        } else {
                            let localPos = Common5.getNodeToTargetPos(cardnode.children[k], this.chiZiNode.getChildByName('rightClearNode'))
                            let node = cardnode.children[k]
                            cc.tween(node)
                                .delay(0.5 + (5 - j % 6) * 0.05)
                                .to(0.4, { x: localPos.x, y: localPos.y, scale: 0.8 })
                                .call(() => {
                                    node.removeFromParent()
                                })
                                .start()
                        }
                    }
                }
                cc.tween(this.node)
                    .delay(1.5)
                    .call(() => {
                        // chiziNode.getChildByName('paoPaoSpine').active = false
                    })
                    .delay(0.21)
                    .call(() => {
                        NewDataManage_xmj.addCurGuanQiaFinishNum(heChengTab[i].account, (isEnterNext, callFunc) => {
                            this.isEnterNextGuanQia(isEnterNext, callFunc)
                        })
                        this.refreshFinishProgress()
                        for (let j = 0; j < 12; j++) {
                            let cardnode = chiziNode.getChildByName('panZi_' + j)
                            cardnode.removeAllChildren()
                        }
                        Common5.addZuanShi(addAward, chiziNode, this.node.getChildByName('yuanBao'))
                        this.changeTili(true, chiziNode)
                        this.refreshAllKaCao();
                        let addCoinNode = chiziNode.getChildByName('addCoinNode')
                        addCoinNode.getChildByName('coinNum').getComponent(cc.Label).string = '+' + addAward
                        addCoinNode.active = true
                        addCoinNode.scale = 0
                        cc.tween(addCoinNode)
                            .to(0.3, { scale: 1 })
                            .delay(1.5)
                            .to(0.3, { scale: 0 })
                            .call(() => {
                                addCoinNode.active = false
                            })
                            .start()
                    })
                    .start()
            }
            //合成并生成牌后回调刷新最新牌数据
            Common5.onHideState.removeTimes++
            this.showJieSuoNewColor(heChengQianColorNum)
            this.jinduProgress()

            this.scheduleOnce(() => {
                this.showJiesuoColorNodePecent(true)
            }, 2)

            this.showChenghaoProgressTab()

            NewDataManage_xmj.addSendPZIndex()

            this.refreshAllXipan()
            // if(heChengTab.length > 0){
            //     for(let i=0;i<heChengTab.length;i++){
            //         this.showShouCangNewColor(heChengTab[i].num,heChengQianColorAccount,heChengHouColorAccount)
            //     }
            // }

            this.scheduleOnce(() => {

                if (line2Index == 12) {
                    this.isKaCao1HeChenging = false
                } else if (line2Index == 13) {
                    this.isKaCao2HeChenging = false
                }
                this.scheduleOnce(() => {
                    this.setJiesuoNumLab()
                    this.onCloseJieSuoNewColorNode()
                }, 0.01)
                // this.isAction = false
            }, 2)//这里的延时可能有问题
        }
        NewDataManage_xmj.checkHeCheng(line2Index, heChengCallFunc)

        // if(NewDataManage_xmj.yiXiaoChuNum >= 29){
        //     NewDataManage_xmj.setUnlockAdsXiWanChi2(true)
        //     this.refreshXiWanChi2JieSuo()
        // }
    }

    showChenghaoProgressTab() {
        // let tab = NewDataManage_xmj.getChenghaoProgressTab()
        // let getID = User.getChenghaoIdMJ()
        // if(this.chenghaoId != getID){
        //     this.chenghaoId = getID
        //     //称号升级,给奖励
        //     if(tab){
        //         let chenghaoConfig = NewDataManage_xmj.getChenghaoConfigByid(this.chenghaoId)
        //         let   giftNode = this.jinDuProgress.getChildByName('礼物')
        //         console.log("jiaqian+++++++++++=====",chenghaoConfig)
        //         // Common5.addMoney(chenghaoConfig.reward, giftNode, this.node.getChildByName('yuanBao'))
        //         if(chenghaoConfig.reward){
        //             PrefabManage.loadPrefabByType(GameType.ChengHaoReward, null, (prefab)=>{
        //                 prefab.getComponent(ChengHaoReward).setViewMJData(chenghaoConfig.reward, tab.skinName)
        //             })
        //         }


        //         let skinName = tab.skinName
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setSkin(skinName)
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setAnimation(0,'faguang', false)

        //         //this.jinDuProgress.getComponent(cc.ProgressBar).progress = tab.needNum/tab.allNum
        //         //this.jinDuProgress.getChildByName('numStr').getComponent(cc.Label).string = Math.floor( tab.needNum/tab.allNum*100)+'%'


        //     }else{
        //         //this.jinDuProgress.getComponent(cc.ProgressBar).progress = 1
        //         //this.jinDuProgress.getChildByName('numStr').active = false
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setAnimation(0,'putong', false)
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setSkin('浴皇大帝')

        //     }
        // }else{
        //     if(tab){
        //         //this.jinDuProgress.getComponent(cc.ProgressBar).progress = tab.needNum/tab.allNum
        //         //this.jinDuProgress.getChildByName('numStr').getComponent(cc.Label).string = Math.floor( tab.needNum/tab.allNum*100)+'%'
        //         let skinName = tab.skinName
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setAnimation(0,'putong', false)
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setSkin(skinName)
        //     }else{
        //         //this.jinDuProgress.getComponent(cc.ProgressBar).progress = 1
        //         //this.jinDuProgress.getChildByName('numStr').active = false
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setAnimation(0,'putong', false)
        //         this.jinDuProgress.getChildByName('称号皮肤').getComponent(sp.Skeleton).setSkin('浴皇大帝')
        //     }
        // }


    }

    jinduProgress() {
        let daiJieSuoPZProgressTab = NewDataManage_xmj.getDaiJieSuoPZProgressTab()

        let color = daiJieSuoPZProgressTab.color
        let lastColor = daiJieSuoPZProgressTab.lastColor
        let percent = daiJieSuoPZProgressTab.percent


        console.log(daiJieSuoPZProgressTab, 'daiJieSuoPZProgressTab')

        let yiXiaoChuNum = daiJieSuoPZProgressTab.yiXiaoChuNum
        let nextNeedXiaoChu = daiJieSuoPZProgressTab.nextNeedXiaoChu
        let oldPanzi = this.jinDuProgress.getChildByName('panzi1')
        let newPanzi = this.jinDuProgress.getChildByName('panzi2')
        this.setPZFame(oldPanzi, color - 1)
        this.setPZFame(newPanzi, color)


        if (percent >= 100) {
            this.jinDuProgress.getChildByName('taskNode').active = true
            percent = 100
            yiXiaoChuNum = nextNeedXiaoChu
        } else {
            this.jinDuProgress.getChildByName('taskNode').active = false
        }
        this.jinDuProgress.getComponent(cc.ProgressBar).progress = percent / 100
        this.jinDuProgress.getChildByName('numStr').getComponent(cc.Label).string = yiXiaoChuNum + '/' + nextNeedXiaoChu

    }

    showJiesuoColorNodePecent(bGame?) {
        let daiJieSuoPZProgressTab = NewDataManage_xmj.getDaiJieSuoPZProgressTab()

        console.log(daiJieSuoPZProgressTab, 'daiJieSuoPZProgressTab++++++++++++++===')


        let color = daiJieSuoPZProgressTab.color
        let lastColor = daiJieSuoPZProgressTab.lastColor
        let percent = daiJieSuoPZProgressTab.percent
        let yiXiaoChuNum = daiJieSuoPZProgressTab.yiXiaoChuNum
        let nextNeedXiaoChu = daiJieSuoPZProgressTab.nextNeedXiaoChu

        let numStr = this.node.getChildByName('jiesuoPZNode').getChildByName('numStr')
        numStr.getComponent(cc.Label).string = percent + '%'

        // let panzi = this.node.getChildByName('jiesuoPZNode').getChildByName('panzi')
        // let qiCaiPanZi = this.node.getChildByName('jiesuoPZNode').getChildByName('qiCaiPanZi')
        // if(color > 24){
        //     panzi.active = false
        //     qiCaiPanZi.active = true
        //     let shengXiaoId = color-25
        //     if(shengXiaoId > 11){
        //         shengXiaoId = 11
        //         numStr.getComponent(cc.Label).string = ''
        //     }
        //     let skinUrl = ShengXiaoPanManager.getShengXiaoUrlById(shengXiaoId)
        //     Common5.getSpriteFrameFromBundle("allRes", skinUrl, qiCaiPanZi.getChildByName('shengXiaoSpr').getComponent(cc.Sprite));

        // }else{
        // panzi.active = true
        // qiCaiPanZi.active = false
        // let skinUrl = 'GameRes/ui/game_xpz/texture/盘子/'+(color)+'b'
        // Common5.getSpriteFrameFromBundle("allRes", skinUrl, panzi.getComponent(cc.Sprite));
        // }


        //进度条改为盘子收集的进度
        let oldPanzi = this.jinDuProgress.getChildByName('panzi1')
        let newPanzi = this.jinDuProgress.getChildByName('panzi2')
        this.setPZFame(oldPanzi, color - 1)
        this.setPZFame(newPanzi, color)


        if (percent >= 100) {
            this.jinDuProgress.getChildByName('taskNode').active = true
            percent = 100
        } else {
            this.jinDuProgress.getChildByName('taskNode').active = false
        }
        this.jinDuProgress.getComponent(cc.ProgressBar).progress = percent / 100
        this.jinDuProgress.getChildByName('numStr').getComponent(cc.Label).string = yiXiaoChuNum + '/' + nextNeedXiaoChu



        // //收藏上一个生肖
        // if(lastColor > 24 && percent == 0){
        //     this.showShouCangNewColor(-1,-1,-1,bGame,lastColor)
        // }



        // }
    }

    setPZFame(node, colorIndex) {
        console.log(colorIndex, 'node, colorIndex+++++++++++==')
        // if(colorIndex > 24){
        //     let shengXiaoId = colorIndex-25
        //     if(shengXiaoId > 11){
        //         shengXiaoId = 11
        //     }
        //     let skinUrl1 = 'GameRes/ui/game_xpz/texture/生肖/七彩盘子2'
        //     Common5.getSpriteFrameFromBundle("allRes", skinUrl1, node.getComponent(cc.Sprite));

        //     node.getChildByName('shengXiaoSpr').active = true
        //     let skinUrl = ShengXiaoPanManager.getShengXiaoUrlById(shengXiaoId)
        //     Common5.getSpriteFrameFromBundle("allRes", skinUrl, node.getChildByName('shengXiaoSpr').getComponent(cc.Sprite));

        // }else{
        // let skinUrl = 'GameRes/ui/game_xpz/texture/盘子/'+(colorIndex)+'b'
        // Common5.getSpriteFrameFromBundle("allRes", skinUrl, node.getComponent(cc.Sprite));
        node.getComponent(SingleMaJiang).setMaJiangSpFrame(colorIndex)
        // }
    }


    showJieSuoNewColor(heChengQianColorNum) {
        let heChengHouColorNum = NewDataManage_xmj.getSendColorTypeNumByXiaoChuNum()
        console.log('heChengQianColorNum==', heChengQianColorNum)
        console.log('heChengHouColorNum==', heChengHouColorNum)

        if (heChengHouColorNum > heChengQianColorNum && heChengHouColorNum <= 34) {

            GameReport.EnterReport(ENTERTYPE.XUANGUAN, '洗麻将-' + heChengHouColorNum)
            PrefabManage.loadPrefabByType(GameType.JieSuoNewColor_xmj, this.node, (prefabNode) => {
                prefabNode.getComponent(JieSuoNewColor_xmj).initView(heChengHouColorNum, (newColorNode) => {
                    this.newColorNode = newColorNode

                })
            })
            //到达关卡目标,进入下一关
            if (heChengHouColorNum >= NewDataManage_xmj.getGuanQiaTargetColor()) {
                PrefabManage.loadPrefabByType(GameType.FinishCurGuanQia)
                NewDataManage_xmj.initNewPageData()
            }


        }

    }
    freshAllShengXiaoPan() {
        let cellData = NewDataManage_xmj.getCellData()
        for (let i = 0; i < 12; i++) {

            for (let j = 0; j < cellData[i].length; j++) {
                let card = this.paiContent.getChildByName('line_' + i).children[j]
                if (card) {
                    card.getComponent(SingleMaJiang).setMaJiangSpFrame(cellData[i][j])
                }
            }
        }
        for (let i = 12; i <= 12; i++) {
            for (let j = 0; j < cellData[i].length; j++) {
                for (let k = 0; k < this.chiZiNode.getChildByName('chiZi_' + i).getChildByName('panZi_' + (j % 24)).childrenCount; k++) {
                    let card = this.chiZiNode.getChildByName('chiZi_' + i).getChildByName('panZi_' + (j % 24)).children[k]
                    if (card) {
                        card.getComponent(SingleMaJiang).setMaJiangSpFrame(cellData[i][j])
                    }
                }
            }
        }
    }
    showShouCangNewColor(colorIndex, heChengQianColorAccount, heChengHouColorAccount, bEnter?, lastColor?) {
        // if(bEnter){
        // 	//生肖加入收藏(恶心功能)
        //     NewDataManage_xmj.addXiaoChuColorNum(lastColor-1,1)
        //     // this.freshAllShengXiaoPan()
        //     TTAPI.stopRecord_custom()
        //     PrefabManage.loadPrefabByType(GameType.ShouCangNewColor,this.node,(prefabNode)=>{
        //         prefabNode.getComponent(ShouCangNewColor).initView(colorIndex,heChengQianColorAccount,heChengHouColorAccount,bEnter,lastColor,()=>{
        //             this.onCloseShouCangNewColorNode()
        //         },()=>{
        //             this.onBtnClickShare()
        //         })
        //     })
        //     // this.shouCangNewColor.active = true
        //     // this.shouCangNewColor.getChildByName('panZi_0').removeAllChildren()
        //     // this.shouCangNewColor.getChildByName('panZi_1').removeAllChildren()
        //     // this.shouCangNewColor.getChildByName('panZi_2').removeAllChildren()
        //     // let card = cc.instantiate(this.singleCard)
        //     // card.active = true
        //     // card.x = 0
        //     // card.y = 0
        //     // card.scale = 0;
        //     // this.shouCangNewColor.getChildByName('panZi_1').addChild(card)

        //     // let skinUrl2 = 'GameRes/ui/game_xpz/texture/生肖/七彩盘子2'
        //     // Common5.getSpriteFrameFromBundle("allRes", skinUrl2, card.getComponent(cc.Sprite));
        //     // card.getChildByName('shengXiaoSpr').active = true
        // 	// let skinUrl = ShengXiaoPanManager.getShengXiaoUrlById(lastColor-25)
        //     // Common5.getSpriteFrameFromBundle("allRes", skinUrl, card.getChildByName('shengXiaoSpr').getComponent(cc.Sprite));
        //     // cc.tween(card).to(0.5,{scale:1}).start();
        // }else if(colorIndex > 0 && NewDataManage_xmj.checkIsShouCangNewColor(colorIndex-1,heChengQianColorAccount,heChengHouColorAccount)){
        //     TTAPI.stopRecord_custom()
        //     PrefabManage.loadPrefabByType(GameType.ShouCangNewColor,this.node,(prefabNode)=>{
        //         prefabNode.getComponent(ShouCangNewColor).initView(colorIndex,heChengQianColorAccount,heChengHouColorAccount,bEnter,lastColor,()=>{
        //             this.onCloseShouCangNewColorNode()
        //         },()=>{
        //             this.onBtnClickShare()
        //         })
        //     })
        //     // this.shouCangNewColor.active = true
        //     // for(let i=0;i<3;i++){
        //     //     this.shouCangNewColor.getChildByName('panZi_'+i).removeAllChildren()
        //     //     let card = cc.instantiate(this.singleCard)
        //     //     card.active = true
        //     //     card.x = 0
        //     //     card.y = 0
        //     //     card.scale = 0;
        //     //     this.shouCangNewColor.getChildByName('panZi_'+i).addChild(card)
        //     //     card.getComponent(SingleCard).setGanJingSpFrame(colorIndex)
        //     //     cc.tween(card).to(0.5,{scale:1}).start();
        //     // }
        // }
    }
    onCloseJieSuoNewColorNode() {
        if (!cc.isValid(this.newColorNode)) {
            return
        }
        //console.log('this.newColorNode==',this.newColorNode)
        let localPos = Common5.getNodeToTargetPos(this.newColorNode, this.jinDuProgress.getChildByName('称号皮肤'))
        this.newColorNode.stopAllActions()
        this.newColorNode.scale = 1
        cc.tween(this.newColorNode)
            .to(0.5, { scale: 0, x: localPos.x, y: localPos.y })
            .call(() => {
                this.newColorNode.removeFromParent()
                this.newColorNode = null
            })
            .start()
        // TTAPI.startRecord_custom()
    }
    onCloseShouCangNewColorNode() {
        // this.shouCangNewColor.active = false
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        TTAPI.startRecord_custom()
        PrefabManage.showTextTips('盘子已收入收藏馆!')
    }
    //洗牌
    onBtnClickXiPai() {
        // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        // if(this.isAction || this.isFaPaing){
        //     return
        // }
        // this.isAction = true
        let xiPaiCallFunc = (sortTab, refreshXiPaiDataFunc) => {
            //洗牌前后一致时不播音效
            let xiPaiRecordTab = NewDataManage_xmj.getXiPaiRecordTab()
            let bEqual = Common5.checkEqualOfTwoArr(sortTab, xiPaiRecordTab)
            if (!bEqual) {
                Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/洗牌音效")
            }
            console.log('上次洗牌xiPaiRecordTab==', xiPaiRecordTab)
            console.log('洗牌sortTab==', sortTab)

            for (let i = 0; i < 10; i++) {
                for (let j = 0; j < sortTab[i].length; j++) {
                    let card = this.paiContent.getChildByName('line_' + sortTab[i][j].posX).getChildByName('card_' + sortTab[i][j].posY).getChildByName('singleMaJiang')
                    let targetNode = this.paiContent.getChildByName('line_' + i).getChildByName('card_' + j)
                    if (card) {
                        //数量10以内变更位置
                        if (sortTab[i][j].isMove) {
                            let localPos = Common5.getNodeToTargetPos(card, targetNode)
                            // console.log('localPos==',localPos)
                            cc.tween(card)
                                .to(0.4, { x: localPos.x, y: localPos.y })
                                .call(() => {
                                    card.setPosition(cc.v2(0, 0))
                                    card.parent = targetNode
                                })
                                .start()
                            //数量10以外直接删除
                        } else {
                            card.removeFromParent()
                            card.destroy()
                        }

                    }
                }
            }
            //洗完牌后回调刷新最新牌数据
            this.scheduleOnce(() => {
                refreshXiPaiDataFunc && refreshXiPaiDataFunc()
                // this.refreshHeChengFlag(true)
                // this.checkXiPaiBtnShow()
                this.isAction = false
            }, 0.42)
        }
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    GameReport.ADReport('洗牌', 1, '洗麻将')
                    Common5.ReportDY("inLevel", '游戏-AD-洗牌');
                    NewDataManage_xmj.xiPaiLogic(xiPaiCallFunc)
                }
                else {
                    GameReport.ADReport('洗牌', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }
    //解锁卡槽
    // jieSuoKaCao(bRefresh,kaCaoIndex){
    //     if(!bRefresh){
    //         return
    //     }
    //     console.log('解锁卡槽=====',kaCaoIndex)
    //     let kaCaoNode = this.diTu.getChildByName('line_'+kaCaoIndex).getChildByName('kaCaoNode')
    //     kaCaoNode.stopAllActions()
    //     if(kaCaoIndex < 9){
    //         cc.tween(kaCaoNode)
    //             .to(0.3,{y:240})
    //         .start()
    //     }else{
    //         if(NewDataManage_xmj.getTempUnLockAdsStatus(kaCaoIndex)){
    //             cc.tween(kaCaoNode)
    //                 .to(0.3,{y:240})
    //             .start()
    //         }else{
    //             cc.tween(kaCaoNode)
    //                 .to(0.3,{y:0})
    //             .start()
    //         }
    //     }
    // }
    //刷新卡槽
    refreshAllKaCao() {
        let unlock_cell = NewDataManage_xmj.getUnlockCell()
        let money = Common5.getCurZuanShi()

        console.log('refreshAllKaCao++++++++++==')
        for (let i = 2; i <= 8; i++) {
            let jieSuoMoney = NewDataManage_xmj.getKaCaoJieSuoCoin('KaCao_' + i)
            //未解锁
            if (i > unlock_cell) {
                if (i > unlock_cell + 1) {
                    this.diTu.getChildByName('line_' + i).getChildByName('keJieSuo').active = false
                    this.diTu.getChildByName('line_' + i).getChildByName('suoDing').active = true
                    this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').active = false
                } else {
                    if (jieSuoMoney < 0) {
                        this.diTu.getChildByName('line_' + i).getChildByName('永久解锁').active = true
                        this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').active = false
                        this.diTu.getChildByName('line_' + i).getChildByName('keJieSuo').active = true
                        this.diTu.getChildByName('line_' + i).getChildByName('suoDing').active = false

                    } else {
                        if (money >= jieSuoMoney) {
                            this.diTu.getChildByName('line_' + i).getChildByName('keJieSuo').active = true
                            this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').position.y += 30;
                            this.diTu.getChildByName('line_' + i).getChildByName('suoDing').active = false
                        }
                        else {
                            this.diTu.getChildByName('line_' + i).getChildByName('keJieSuo').active = false
                            this.diTu.getChildByName('line_' + i).getChildByName('suoDing').active = true
                        }
                        this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').active = true
                    }

                    // this.diTu.getChildByName('line_'+i).getChildByName('suoDing').active = false

                }

                this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').getChildByName('money').getComponent(cc.Label).string = '' + jieSuoMoney

                //已解锁
            } else {
                this.diTu.getChildByName('line_' + i).getChildByName('suoDing').active = false
                this.diTu.getChildByName('line_' + i).getChildByName('keJieSuo').active = false
                this.diTu.getChildByName('line_' + i).getChildByName('jinBiNode').active = false
                this.diTu.getChildByName('line_' + i).getChildByName('永久解锁').active = false
            }
        }
        // //临时区-暂未处理逻辑
        // for(let j=10;j<=11;j++){

        // }
    }
    // //刷新进度
    // refreshProgressNode(bRefresh){
    //     if(!bRefresh){
    //         return
    //     }
    //     let curTargetMinNumber = NewDataManage_xmj.getCurTargetMinNumber()
    //     let curTargetNumber = NewDataManage_xmj.getCurTargetNumber()
    //     let num = curTargetMinNumber
    //     let progressIndex = 0
    //     for(let i=0;i<5;i++){
    //         if(curTargetNumber==num){
    //             progressIndex = i
    //         }
    //         let starNode = this.progressNode.getChildByName('starNode_'+i)
    //         if(num>curTargetNumber){
    //             starNode.getChildByName('spine').getComponent(sp.Skeleton).setAnimation(0,'1',true)
    //         }else if(num ==curTargetNumber){
    //             starNode.getChildByName('spine').getComponent(sp.Skeleton).setAnimation(0,'3',true)
    //         }else if(num <curTargetNumber){
    //             starNode.getChildByName('spine').getComponent(sp.Skeleton).setAnimation(0,'2',true)
    //         }
    //         // starNode.getChildByName('spr').active = (curTargetNumber>=num)
    //         starNode.getChildByName('num').getComponent(cc.Label).string = ''+num
    //         num ++
    //         //从左往右第三个数不作为目标值
    //         if(num - curTargetMinNumber == 3){
    //             num ++
    //         }
    //     }
    //     this.progressNode.getComponent(cc.ProgressBar).progress = 0.25*progressIndex
    // }
    //阶段结算
    // showPeriodResult(){
    //     Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/cool")


    //     this.finishNode.active = true

    //     let yiJieSuoId = NewDataManage_xmj.getJieSuoTuJianId()
    //     console.log('解锁图鉴id==',yiJieSuoId)
    //     let skin = ''
    //     if(skinConfig[yiJieSuoId]){
    //         skin = skinConfig[yiJieSuoId].name
    //     }else{
    //         skin = skinConfig[0].name
    //     }
    //     this.finishNode.getChildByName('rabbitSpine').getComponent(sp.Skeleton).setSkin(skin)
    //     this.finishNode.getChildByName('rabbitSpine').getComponent(sp.Skeleton).setAnimation(0,'cool+',false)
    //     this.finishNode.getChildByName('awardStr').getComponent(cc.Label).string = `获得阶段奖励【${skin}】`
    // }
    //完成当前关卡
    isEnterNextGuanQia(bFinish, callFunc) {
        if (!bFinish) {
            return
        }
        // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/cool")
        TTAPI.stopRecord_custom()

        this.refreshFinishProgress()

        User.setStatistics("smallgamemjhsCurGoLevel", User.getStatistics("smallgamemjhsCurGoLevel") + 1)
        Common5.showInterstitialAd()

        // this.finishNode.active = true
        // this.finishNode.getChildByName('nextTargetStr').getComponent(cc.Label).string = `下一关目标:${NewDataManage_xmj.getNextGuanQiaTargetNum()}`
        callFunc && callFunc()
    }
    //继续游戏
    onBtnClickContinue() {
        // this.finishNode.active = false
        TTAPI.startRecord_custom()
        // NewDataManage_xmj.initStartCellData()
        // this.initStartContent()
    }
    onBtnClickShare() {
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        TTAPI.shareRecord_custom(() => {
            PrefabManage.showTextTips("录屏分享成功,请继续游戏!");
        }, () => {
            PrefabManage.showTextTips("录屏分享功能调用失败,请稍后再试!");
        })
    }
    protected onDestroy(): void {
        super.onDestroy()
        EventMgr.emitEvent_custom(ryw_Event.exitToLobby)
    }
    // setTuZiSpine(){
    //     let yiJieSuoId = NewDataManage_xmj.getJieSuoTuJianId()
    //     if(skinConfig[yiJieSuoId+1]){
    //         this.targetTuZiSpine.getComponent(sp.Skeleton).setSkin(skinConfig[yiJieSuoId+1].skinName)
    //         this.targetTuZiSpine.getComponent(sp.Skeleton).setAnimation(0,'daiji',true)
    //     }
    // }
    // refreshHeChengFlag(bShow){
    //     console.log("检测合成牌=====")
    //     for(let i=0;i<12;i++){
    //         this.diTu.getChildByName('line_'+i).getChildByName('xuanzhongSpine').active = false
    //     }
    //     if(bShow){
    //         let lineTab = NewDataManage_xmj.getHeChengLine()
    //         for(let i=0;i<lineTab.length;i++){
    //             this.diTu.getChildByName('line_'+lineTab[i].line).getChildByName('xuanzhongSpine').active = true
    //         }
    //     }
    // }
    // showNextTargetNode(){
    //     this.nextTargetNode.active = true
    //     this.nextTargetNode.scale = 0
    //     this.nextTargetNode.stopAllActions()
    //     let num = NewDataManage_xmj.getCurTargetNumber()
    //     this.nextTargetNode.getChildByName('str').getComponent(cc.Label).string = ''+num
    //     cc.tween(this.nextTargetNode)
    //         .to(0.5,{scale:1})
    //         .delay(3)
    //         .to(0.5,{scale:0})
    //     .start()
    // }
    onBtnClickSet() {
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        let closeGameFunc = () => {
            GameReport.OUTReport(OUTTYPE.FANHUI, '洗麻将')
            if (cc.isValid(this.newColorNode)) {
                this.newColorNode.stopAllActions()
                this.newColorNode.removeFromParent()
                this.newColorNode = null
            }

            this.node.removeFromParent()
            this.node.destroy()

            EventMgr.emitEvent_custom(ryw_Event.exitToLobby)
        }
        //重新开始
        let restartCallFunc = () => {

            TTAPI.startRecord_custom()
            NewDataManage_xmj.restartCurPageData()
            this.initStartContent()
        }
        // PrefabManage.loadPrefabByType(GameType.Setting, null, (prefabNode) => {
        //     prefabNode.getComponent(Setting).initView(true,closeGameFunc,restartCallFunc)
        // })
    }
    gameRestart() {
        NewDataManage_xmj.restartCurPageData()
        this.initStartContent()
        NewDataManage_xmj.maxTime = NewDataManage_xmj.getChushiTime();
    }
    onBtnClickBack() {
        GameReport.OUTReport(OUTTYPE.FANHUI, '洗麻将')
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        if (cc.isValid(this.newColorNode)) {
            this.newColorNode.stopAllActions()
            this.newColorNode.removeFromParent()
            this.newColorNode = null
        }

        if (User.getStatistics('smallgamemjhsCurGoLevel') > 0) {
            PrefabManage.loadPrefabByType(GameType.SuccessGetMoney, null, (prefab) => {
                prefab.getComponent('SuccessGetMoney').setViewDate("", 5, 10)
            })
        }

        this.node.removeFromParent()
        this.node.destroy()

        EventMgr.emitEvent_custom(ryw_Event.exitToLobby)
    }
    getTwoLineDisX(lineIndex1, lineIndex2) {
        // 0,1,2,3,
        // 4,5,6,7,
        // 8,9,10,11
        // if()
    }
    onBtnShengJiPanZi(event, customData) {
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    GameReport.ADReport('升级水槽', 1, '洗麻将')
                    Common5.ReportDY("inLevel", '游戏-AD-升级水槽' + customData);
                    console.log('升级盘子==', customData)
                    NewDataManage_xmj.addXiWanChiLevel(customData)
                    this.refreshShengJiLevel()
                }
                else {
                    GameReport.ADReport('升级水槽', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }

    refreshShengJiLevel() {
        let levelTab = NewDataManage_xmj.getXiWanChiLevel()
        this.chiZiNode.getChildByName('chiZi_14').getChildByName('levelNum').getComponent(cc.Label).string = '' + levelTab[0]
        let panZiPrice0 = NewDataManage_xmj.getNextLevelPerPanZiPrice(0)
        this.chiZiNode.getChildByName('chiZi_14').getChildByName('shengJiNode').getChildByName('money').getComponent(cc.Label).string = 'x' + panZiPrice0
        //已满级
        if (panZiPrice0 <= 0) {
            this.chiZiNode.getChildByName('chiZi_14').getChildByName('shengJiNode').active = false
        }
        let panZiPrice1 = NewDataManage_xmj.getNextLevelPerPanZiPrice(1)
        this.chiZiNode.getChildByName('chiZi_15').getChildByName('levelNum').getComponent(cc.Label).string = '' + levelTab[1]
        this.chiZiNode.getChildByName('chiZi_15').getChildByName('shengJiNode').getChildByName('money').getComponent(cc.Label).string = 'x' + panZiPrice1
        //已满级
        if (panZiPrice1 <= 0) {
            this.chiZiNode.getChildByName('chiZi_15').getChildByName('shengJiNode').active = false
        }
    }

    onBtnTianJiaShouYe(Event) {
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        let target = Event.target
        TTAPI.addToZM(() => {
            // if(target){
            //     target.active = false
            // }
        })
    }

    showFaPanDaoJiShi() {
        let buPanLeftTime = NewDataManage_xmj.getAutoBuPanTimeLeftNum()

        if (buPanLeftTime > 0) {
            this.isadd_500_panzi = false
            this.node.getChildByName('gameNode').getChildByName('autoBuPanNode').active = true
            this.faPanDaoJiShi.getComponent(cc.Label).string = DateUtils.formatTime3_custom(buPanLeftTime)
        } else if (buPanLeftTime <= 0) {
            if (!this.isadd_500_panzi) {

                console.log('isadd_500_panzi+++++++++++===')
                this.isadd_500_panzi = true
                this.node.getChildByName('gameNode').getChildByName('autoBuPanNode').active = false
                this.faPanDaoJiShi.getComponent(cc.Label).string = ''
                NewDataManage_xmj.finishAutoBuPanTime()
                NewDataManage_xmj.addLeftPanZiNum(300)
                this.refreshLeftPanZiNum()
            }


        }

    }
    onBtnClickTodayTarget() {
        // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        // GameReport.EnterReport(ENTERTYPE.TIAOZHUAN, '荣耀台')
        // PrefabManage.loadPrefabByType(GameType.RongYaoTai, null, (prefab)=>{
        //     let index = 2

        //     prefab.getComponent('RongYaoTai').scrollIndexPage(index)
        // })
    }

    onBtnMoFaDaoJu() {
        let useFunc = () => {
            let tab = NewDataManage_xmj.useMoFaDaoJu()
            let changeColorPosTab = tab.changeColorPosTab
            let colorNum = tab.colorNum
            this.isAction = true
            this.moFaSpine.active = true
            this.moFaSpine.getComponent(sp.Skeleton).setAnimation(0, 'xuanzhuan2', false)
            cc.tween(this.node)
                .delay(0.5)
                .call(() => {
                    Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/变色")
                    for (let i = 0; i < changeColorPosTab.length; i++) {
                        for (let j = 0; j < changeColorPosTab[i].length; j++) {
                            let card = this.paiContent.getChildByName('line_' + i).children[changeColorPosTab[i][j]]
                            card.getComponent(SingleMaJiang).setMaJiangSpFrame(colorNum)
                        }
                    }
                })
                .delay(0.6)
                .call(() => {
                    this.moFaSpine.active = false
                    this.isAction = false
                })
                .start()
        }
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        if (User.getIsPropLiuXingFree()) {
            useFunc()

            User.setIsPropLiuXingFree(false)
            this.refreshPropStatus()
            return
        }
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    GameReport.ADReport('魔法道具', 1, '洗麻将')
                    Common5.ReportDY("inLevel", '游戏-AD-魔法道具');
                    useFunc()
                }
                else {
                    GameReport.ADReport('魔法道具', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }
    onBtnChuiZiDaoJu() {
        Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        let useFunc = () => {
            this.isStartChuiZiDaoJu = true
            this.chuiZiNode.active = true
            this.chuiZiNode.scale = 1
            this.chuiZiNode.getChildByName('chuiZiSpine').setPosition(cc.v2(70, -40))
            this.chuiZiNode.getChildByName('chuiZiSpine').getComponent(sp.Skeleton).setAnimation(0, 'chuizi1', false)
        }
        if (User.getIsPropChuiZiFree()) {
            useFunc()
            //
            User.setIsPropChuiZiFree(false)
            this.refreshPropStatus()
            return
        }
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    GameReport.ADReport('锤子道具', 1, '洗麻将')
                    Common5.ReportDY("inLevel", '游戏-AD-锤子道具');
                    useFunc()
                }
                else {
                    GameReport.ADReport('锤子道具', 0, '洗麻将')
                    Common5.showTips_custom("广告未观看完");
                }
            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }
    refreshPropStatus() {
        if (User.getIsPropChuiZiFree()) {
            this.propChuiZi.getChildByName('node1').active = false
            this.propChuiZi.getChildByName('node2').active = true
        } else {
            this.propChuiZi.getChildByName('node1').active = true
            this.propChuiZi.getChildByName('node2').active = false
        }
        if (User.getIsPropLiuXingFree()) {
            this.propLiuXIng.getChildByName('node1').active = false
            this.propLiuXIng.getChildByName('node2').active = true
        } else {
            this.propLiuXIng.getChildByName('node1').active = true
            this.propLiuXIng.getChildByName('node2').active = false
        }
    }
    onBtnOpenPanZi() {
        // Common5.getSoundFromBundle_custom("allRes", "GameRes/sound/UI按钮")
        // GameReport.EnterReport(ENTERTYPE.TIAOZHUAN,'省份详情')
        // PrefabManage.loadPrefabByType(GameType.ChinaList)
    }
}