2022-02-16 18:22:27 +08:00
|
|
|
|
using Assets.Scripts;
|
2022-02-17 16:05:40 +08:00
|
|
|
|
using System;
|
2022-02-16 18:22:27 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
2022-02-17 16:05:40 +08:00
|
|
|
|
using UnityEngine.UI;
|
2022-02-16 18:22:27 +08:00
|
|
|
|
|
|
|
|
|
|
public class ActivityAdController : PFUIPanel
|
|
|
|
|
|
{
|
2022-02-17 16:05:40 +08:00
|
|
|
|
Dictionary<string, Texture> caches;
|
2022-02-16 18:22:27 +08:00
|
|
|
|
protected override void Awake()
|
|
|
|
|
|
{
|
2022-02-17 16:05:40 +08:00
|
|
|
|
caches = new Dictionary<string, Texture>();
|
2022-02-16 18:22:27 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Close();
|
2022-02-17 16:05:40 +08:00
|
|
|
|
if (App.adQueue.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Invoke("ShowSelf", 0.5f);
|
|
|
|
|
|
}
|
2022-02-16 18:22:27 +08:00
|
|
|
|
});
|
2022-02-17 16:05:40 +08:00
|
|
|
|
UIManager.AddEvent(transform.Find("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
|
2022-02-16 18:22:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
Close();
|
|
|
|
|
|
//可以传参
|
|
|
|
|
|
//UIManager.ShowActivityPanel(url);
|
2022-02-17 16:05:40 +08:00
|
|
|
|
await ConfigHelper.activityApi.JoinActivity(id);
|
2022-02-16 18:22:27 +08:00
|
|
|
|
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/");
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-02-17 16:05:40 +08:00
|
|
|
|
private void ShowSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
var ad = App.adQueue.Dequeue();
|
|
|
|
|
|
UIManager.ShowActivityAdPanel(ad.Id, ad.DetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}");
|
|
|
|
|
|
}
|
2022-02-16 18:22:27 +08:00
|
|
|
|
string image = null, url = null;
|
2022-02-17 16:05:40 +08:00
|
|
|
|
int id = 0;
|
|
|
|
|
|
public void Initial(int id, string image, string url)
|
2022-02-16 18:22:27 +08:00
|
|
|
|
{
|
2022-02-17 16:05:40 +08:00
|
|
|
|
this.id = id;
|
2022-02-16 18:22:27 +08:00
|
|
|
|
this.image = image;
|
2022-02-17 16:05:40 +08:00
|
|
|
|
var ri = transform.Find("Image").GetComponent<RawImage>();
|
|
|
|
|
|
Utils.DisplayImageTempDict(ri, image, caches);
|
2022-02-16 18:22:27 +08:00
|
|
|
|
App.ActivityUrl = url;
|
|
|
|
|
|
this.url = url;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-02-17 16:05:40 +08:00
|
|
|
|
protected override void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
caches = null;
|
|
|
|
|
|
Resources.UnloadUnusedAssets();
|
|
|
|
|
|
GC.Collect();
|
|
|
|
|
|
}
|
2022-02-16 18:22:27 +08:00
|
|
|
|
}
|