// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import User from "../../FrameWork/User/User";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import Common5 from "../../Platform/th/Common5";
import UiBase from "../GameBase/UiBase";
import TaskManager from "../JuQingChat/TaskManager";
import ChallengeManager from "../Manager/ChallengeManager";
import LevelUpManager from "../Manager/LevelUpManager";
import UserManager from "../Manager/UserManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class SuccessGetMoney_customMoney extends UiBase {

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

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

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

    beishuNum = 5
    money1: any;
    money2: any;
    callback1: any;
    callback2: any;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    setViewDate(name, money1, money2, callback1, callback2) {
        this.nameLab.string = name
        this.money1 = money1
        this.money2 = money2
        this.callback1 = callback1
        this.callback2 = callback2

        if (name == "") {
            this.nameLab.node.parent.getChildByName("lab1").active = false
            this.nameLab.node.parent.getChildByName("lab3").active = false
        }

        this.labelYiBei.string = '' + Common5.getNumberChangeHanzi(money1, '1', 1)
        this.labelWuBei.string = '' + Common5.getNumberChangeHanzi(money2, '1', 1)
    }

    getOneBtnEvent(event) {
        //Common5.playEffect("sound/按键点击")
        UserManager.addMoney(this.money1, event.target)
        if (this.callback1) {
            this.callback1()
        }
        this.node.removeFromParent()
        this.node.destroy()
    }
    getFiveBtnEvent(event) {
        //Common5.playEffect("sound/按键点击")

        let tab = {
            onClose: (finish) => {
                if (finish) {
                    User.setShowAdNum(User.getShowAdNum() + 1)
                    Common5.ReportDY("inLevel", `任务${TaskManager.getCurUnLockMainTaskId()}-AD-获得金钱弹框五倍奖励`)
                    UserManager.addMoney(this.money2, event.target)
                    if (this.callback2) {
                        this.callback2()
                    }
                    this.node.removeFromParent()
                    this.node.destroy()
                }
                else {

                    Common5.showTips_custom("广告未观看完");
                }

            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }

    // update (dt) {}
}