using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MoneyRedBagPanel : BasePanel
{
    public override void OnHide(object data = null)
    {
        UIMgr.Getinstance().GetPanel<MainPanel>().GetHomeInfo();
    }

    public override void OnInit(object data = null)
    {
        GetReward();
        GetControl<Button>("btnCashOut").onClick.AddListener(() =>
        {
            UIMgr.Getinstance().HidePanel<MoneyRedBagPanel>();
            UIMgr.Getinstance().GetPanel<MainPanel>().GetNextNoteList();
            ToastPlugin.ToastHelper.ShowToast("立即提现");
        });
        GetControl<Button>("btnClose").onClick.AddListener(() =>
        {
            UIMgr.Getinstance().GetPanel<MainPanel>().GetNextNoteList();
            UIMgr.Getinstance().HidePanel<MoneyRedBagPanel>();
        });
        GetControl<Button>("btnContinue").onClick.AddListener(() =>
        {
            UIMgr.Getinstance().GetPanel<MainPanel>().GetNextNoteList();
            UIMgr.Getinstance().HidePanel<MoneyRedBagPanel>();
        });
    }

    public override void OnRefresh(object data = null)
    {

    }

    /// <summary>
    /// 获取合成奖励
    /// </summary>
    /// <param name="song_id"></param>
    public void GetReward()
    {
        Dictionary<string, object> paras = new Dictionary<string, object>();
        paras.Add("type", 1);
        HttpTool.Instance._Get("app/v1/watermelon/reward", paras, new Action<RewarBean>((result) =>
        {
            GetControl<Text>("txtTopMoney").text = (result.reward / 100f).ToString("0.00") + "元";
            GetControl<Text>("txtMoney").text = (result.available / 100f).ToString("0.00") + "元";
            GetControl<Text>("txtDiscribe").text = "再赚取" + (result.disparity / 100f).ToString("0.00") + "元可以提现";
        }), new Action<string, string>((code, msg) =>
        {
            Debug.unityLogger.Log("获取合成奖励 " + code + " msg " + msg);
        }));
    }

   
}
