powerfun-unity/Assets/RecommendController.cs

66 lines
1.9 KiB
C#
Raw Normal View History

using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class RecommendController : MonoBehaviour
{
public Recommand Area { get; private set; }
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Initial(Recommand area, Dictionary<string, Texture> caches = null)
{
transform.Find("Panel/Text").GetComponent<Text>().text = area.Title;
Utils.DisplayImageTempDict(GetComponent<RawImage>(), area.CoverImage, caches);
this.Area = area;
GetComponent<Button>().onClick.RemoveAllListeners();
GetComponent<Button>().onClick.AddListener(() =>
{
DoWithType();
});
}
public async void DoWithType()
{
if (Area == null) return;
switch (Area.Type)
{
case 0:
//路线
App.RouteIdParam = Area.RouteId;
SceneManager.LoadScene("Ride");
break;
case 1:
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetailItem(Area.AreaId);
2022-01-18 13:24:19 +08:00
UIManager.ShowNewRouteDetailPanel(res.data.Id);
break;
case 2:
await ConfigHelper.activityApi.JoinActivity(Area.ActivityId ?? 0);
2022-02-16 18:22:27 +08:00
UIManager.ShowActivityPanel(Area.Url + "?Token=" + App.CurrentUser.cookie);
//Application.OpenURL(Area.Url);
break;
case 3:
App.RouteIdParam = Area.RouteId;
App.CompetionId = Area.CompetitionId;
SceneManager.LoadScene("Ride");
break;
default:break;
}
}
}