136 lines
3.8 KiB
C#
136 lines
3.8 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static LoginSceneUIManager;
|
|
|
|
public class MainPanel : PanelBasic
|
|
{
|
|
/// <summary>
|
|
/// 课程任务按钮
|
|
/// </summary>
|
|
public Button course_task_button;
|
|
/// <summary>
|
|
/// 案例中心按钮
|
|
/// </summary>
|
|
public Button case_center_button;
|
|
/// <summary>
|
|
/// 自由编程按钮
|
|
/// </summary>
|
|
public Button free_programming_button;
|
|
|
|
public HomeMenuButton course_task_changjing;
|
|
public HomeMenuButton case_center_changjing;
|
|
public HomeMenuButton free_programming_changjing;
|
|
|
|
public Carousel carousel;
|
|
void Start()
|
|
{
|
|
if(this.name!="Mini")
|
|
Init();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
//启动器启动 跳转到login场景后通过loading面板加载对应的场景
|
|
// if (InterfaceManager.isstartflag)
|
|
// {
|
|
// loading_panel.OnActive(this);
|
|
// }
|
|
}
|
|
|
|
void Init()
|
|
{
|
|
course_task_changjing = course_task_button.GetComponent<HomeMenuButton>();
|
|
case_center_changjing = case_center_button.GetComponent<HomeMenuButton>();
|
|
free_programming_changjing = free_programming_button.GetComponent<HomeMenuButton>();
|
|
|
|
//---首页
|
|
course_task_button.onClick.AddListener(OnCourseTask);
|
|
case_center_button.onClick.AddListener(OnCaseCenter);
|
|
free_programming_button.onClick.AddListener(OnFreeProgramming);
|
|
|
|
//活动配置
|
|
string url = InterfaceManager.IdAddress + ":8080/component/activeconfig/list";
|
|
StartCoroutine(InterfaceManager.Get(url, true,result =>
|
|
{
|
|
JObject jb = JObject.Parse(result);
|
|
if (jb["code"].ToObject<int>()==200)
|
|
{
|
|
if (jb["total"].ToObject<int>()>0)
|
|
{
|
|
List<string> listurls = new List<string>();
|
|
List<string> links=new List<string>();
|
|
jb["rows"].ToList().ForEach(a =>
|
|
{
|
|
if (a["pictureUrl"] != null && a["activeUrl"] != null)
|
|
{
|
|
listurls.Add(a["pictureUrl"].ToString());
|
|
links.Add(a["activeUrl"].ToString());
|
|
}
|
|
});
|
|
|
|
carousel.init(listurls, links);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(jb["msg"].ToString());
|
|
}
|
|
}));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 课程任务事件
|
|
/// </summary>
|
|
public void OnCourseTask()
|
|
{
|
|
//Debug.Log("暂时禁用课程任务!");
|
|
//return;
|
|
course_task_changjing.Hide();
|
|
case_center_changjing.Hide();
|
|
free_programming_changjing.Hide();
|
|
|
|
if (GameManager.is_login)
|
|
{
|
|
//打开课程任务面板,关闭主面板
|
|
course_task_panel.OnActive(this);
|
|
//course_task_panel.GetCourseList();
|
|
}
|
|
else
|
|
{
|
|
//打开登录弹窗,结束后打开课程任务面板,关闭主面板
|
|
login_panel.OnPopup((_islogin) => {if(_islogin) course_task_panel.OnActive(this); });
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 案例中心事件
|
|
/// </summary>
|
|
public void OnCaseCenter()
|
|
{
|
|
//Debug.Log("暂时禁用案例中心!");
|
|
//return;
|
|
course_task_changjing.Hide();
|
|
case_center_changjing.Hide();
|
|
free_programming_changjing.Hide();
|
|
|
|
//隐藏自己
|
|
//PushPanel().OnNagetive();
|
|
|
|
//打开案例中心,关闭主面板
|
|
case_center_panel.OnActive(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自由编程事件
|
|
/// </summary>
|
|
public void OnFreeProgramming()
|
|
{
|
|
|
|
}
|
|
}
|