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

public class MusicRedBagPanel : BasePanel
{
    public override void OnHide(object data = null)
    {

    }

    public override void OnInit(object data = null)
    {
        GetControl<Button>("btnOpen").onClick.AddListener(() =>
        {
            UIMgr.Getinstance().HidePanel<MusicRedBagPanel>();
            UIMgr.Getinstance().ShowPanel<MoneyRedBagPanel>(E_Layer.mid);

        });
        GetControl<Button>("btnClose").onClick.AddListener(() =>
        {
            UIMgr.Getinstance().GetPanel<MainPanel>().GetNextNoteList();
            UIMgr.Getinstance().HidePanel<MusicRedBagPanel>();
        });

        Dictionary<string, object> paras = new Dictionary<string, object>();
        paras.Add("song_id", UIMgr.Getinstance().GetPanel<MainPanel>().GetCurrentSongId);
        HttpTool.Instance._Get("app/v1/watermelon/songs_list", paras, new Action<SongBean>((result) =>
        {
            for (int i = 0; i < result.list.Count; i++)
            {
                if (UIMgr.Getinstance().GetPanel<MainPanel>().GetCurrentSongId == result.list[i].song_id)
                {
                    GetControl<Text>("txtMusicName").text = "你合成了歌曲“" + result.list[i].song_name + "”";
                    break;
                }
            }

        }), new Action<string, string>((code, msg) =>
        {
            Debug.unityLogger.Log("获取歌曲列表 " + code + " msg " + msg);
        }));
    }

    public override void OnRefresh(object data = null)
    {

    }
}
