// 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 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
    beishu1: any;
    beishu2: any;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    setViewDate(name, beishu1?, beishu2?) {
        this.nameLab.string = name
        this.beishu1 = beishu1
        this.beishu2 = beishu2

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

        let levelUpSpned = LevelUpManager.levelUpSpned()


        let yibei = levelUpSpned * 10
        let wubei = levelUpSpned * 10 * 5
        if (beishu1) {
            yibei = levelUpSpned * beishu1
        }
        if (beishu2) {
            wubei = levelUpSpned * beishu2
        }
        this.labelYiBei.string = '' + Common5.getNumberChangeHanzi(yibei, '1', 1)
        this.labelWuBei.string = '' + Common5.getNumberChangeHanzi(wubei, '1', 1)
    }

    getOneBtnEvent(event) {
        //Common5.playEffect("sound/按键点击")
        let levelUpSpned = LevelUpManager.levelUpSpned()
        let yibei = levelUpSpned * 10
        if (this.beishu1) {
            yibei = levelUpSpned * this.beishu1
        }
        UserManager.addMoney(yibei, event.target)
        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-挑战五倍奖励`)
                    // Common5.ReportDY("inLevel", "挑战-AD-五倍奖励");
                    let levelUpSpned = LevelUpManager.levelUpSpned()

                    let wubei = levelUpSpned * 10 * 5
                    if (this.beishu2) {
                        wubei = levelUpSpned * this.beishu2
                    }
                    UserManager.addMoney(wubei, event.target)
                    this.node.removeFromParent()
                    this.node.destroy()
                }
                else {

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

            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }

    // update (dt) {}
}