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 ActivityAdController : PFUIPanel { Dictionary caches; private int activityType = 0;//0:内置网页 1:骑行 2:赛事 private int routeId = 0; private int competitionId = 0; protected override void Awake() { caches = new Dictionary(); UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => { Close(); if (App.adQueue.Count > 0) { Invoke("ShowSelf", 0.5f); } }); UIManager.AddEvent(transform.Find("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b => { Close(); if (activityType == 1) { App.RouteIdParam = routeId; var routeRes = ConfigHelper.mapApi.GetById(routeId); if (routeRes.result) { if (routeRes.data.EnableAR) { SceneManager.LoadScene("VideoPlay"); } else { SceneManager.LoadScene("Ride"); } } return; } //可以传参 //UIManager.ShowActivityPanel(url); await ConfigHelper.activityApi.JoinActivity(id); if (string.IsNullOrEmpty(App.CurrentUser.Contact) || string.IsNullOrEmpty(App.CurrentUser.ContactPhone) || string.IsNullOrEmpty(App.CurrentUser.ContactAddress)) { UIManager.ShowAddressPanel(); } else { UIManager.ShowActivityPanel(url); } }); //UIManager.AddEvent(transform.Find("LightUpChina/BtnRule").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => //{ // Application.OpenURL("https://www.baidu.com/"); //}); } private void ShowSelf() { var ad = App.adQueue.Dequeue(); ad.Url = ad.Url + $"?Token={App.CurrentUser.cookie}"; UIManager.ShowActivityAdPanel(ad); } string image = null, url = null; int id = 0; public void Initial(ActivityModel activity) { this.id = activity.Id; this.image = activity.DetailUrl; var ri = transform.Find("Image").GetComponent(); Utils.DisplayImageTempDict(ri, image, caches); App.ActivityUrl = url; this.url = activity.Url; this.activityType = activity.ActivityType; this.routeId = activity.RouteId; this.competitionId = activity.CompetitionId; } // Update is called once per frame void Update() { } protected override void OnDestroy() { caches = null; Resources.UnloadUnusedAssets(); } }