85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
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 = App.GetLocalLanguage() == "zh" ? area.Title : area.GlobeTitle; ;
|
|
|
|
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:
|
|
//路线
|
|
var routeRes = ConfigHelper.mapApi.GetById(Area.RouteId);
|
|
if (routeRes.result)
|
|
{
|
|
App.RouteIdParam = Area.RouteId;
|
|
if (routeRes.data.EnableAR)
|
|
{
|
|
SceneManager.LoadScene("VideoPlay");
|
|
}
|
|
else
|
|
{
|
|
SceneManager.LoadScene("Ride");
|
|
}
|
|
}
|
|
break;
|
|
case 1:
|
|
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetailItem(Area.AreaId);
|
|
UIManager.ShowNewRouteDetailPanel(res.data.Id, res.data.CoverImage);
|
|
break;
|
|
case 2:
|
|
await ConfigHelper.activityApi.JoinActivity(Area.ActivityId ?? 0);
|
|
if (string.IsNullOrEmpty(App.CurrentUser.Contact) || string.IsNullOrEmpty(App.CurrentUser.ContactPhone) || string.IsNullOrEmpty(App.CurrentUser.ContactAddress))
|
|
{
|
|
UIManager.ShowAddressPanel();
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowActivityPanel(Area.Url + "?Token=" + App.CurrentUser.cookie);
|
|
}
|
|
break;
|
|
case 3:
|
|
App.RouteIdParam = Area.RouteId;
|
|
App.CompetionId = Area.CompetitionId;
|
|
SceneManager.LoadScene("Ride");
|
|
break;
|
|
default:break;
|
|
}
|
|
}
|
|
}
|