// 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 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 LevelUpManager from "../Manager/LevelUpManager";
import UserManager from "../Manager/UserManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class shiShenScript extends UiBase {

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

    minMoney = 250000
    start() {

        let money = LevelUpManager.getAdReardMoneySS()
        if (money < this.minMoney) {

        } else {
            this.minMoney = money
        }

        this.MoneyLabel.string = '获得' + Common5.getNumberChangeHanzi(this.minMoney, '1', 0) + ''


        // let desc = this.node.getChildByName('labDesc').getComponent(cc.Label)
        // let num = LevelUpManager.canLevelNum(this.minMoney)
        // desc.string = `哇,够我提升${num}级了`

        this.node.getChildByName('labDesc').active = false
    }


    lingquBtnClick(event) {
        //Common5.playEffect("sound/按键点击") 

        let target = event.target
        let tab = {
            onClose: (finish) => {
                if (finish) {
                    User.setShowAdNum(User.getShowAdNum() + 1)
                    Common5.ReportDY("inLevel", `任务${TaskManager.getCurUnLockMainTaskId()}-AD-食神赐福领取`)
                    // Common5.ReportDY("inLevel", "食神赐福-AD-领取");
                    let money = this.minMoney

                    UserManager.addMoney(money, target)

                    this.closeUi()
                }
                else {

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

            }, onFailed: () => {

            }
        }
        AppPlatform.playVideo_custom(tab)
    }


    noBtnClick() {
        //Common5.playEffect("sound/按键点击") 

        this.closeUi()
    }

    // update (dt) {}
}