修改活动逻辑;增加一些接口;可弹多个广告
This commit is contained in:
1 parent
1148e29379
commit
1b3743a135
12 files changed
+212
-18
No files matched your search
@@ -1,22 +1,30 @@
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ActivityAdController : PFUIPanel
|
||||
{
|
||||
Dictionary<string, Texture> caches;
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
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("LightUpChina/Btn").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
UIManager.AddEvent(transform.Find("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
|
||||
{
|
||||
Close();
|
||||
//可以传参
|
||||
//UIManager.ShowActivityPanel(url);
|
||||
ConfigHelper.activityApi.JoinActivity(2);
|
||||
await ConfigHelper.activityApi.JoinActivity(id);
|
||||
if (string.IsNullOrEmpty(App.CurrentUser.Contact) || string.IsNullOrEmpty(App.CurrentUser.ContactPhone) || string.IsNullOrEmpty(App.CurrentUser.ContactAddress))
|
||||
{
|
||||
UIManager.ShowAddressPanel();
|
||||
@@ -33,10 +41,19 @@ public class ActivityAdController : PFUIPanel
|
||||
//});
|
||||
|
||||
}
|
||||
string image = null, url = null;
|
||||
public void Initial(string image, string url)
|
||||
private void ShowSelf()
|
||||
{
|
||||
var ad = App.adQueue.Dequeue();
|
||||
UIManager.ShowActivityAdPanel(ad.Id, ad.DetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}");
|
||||
}
|
||||
string image = null, url = null;
|
||||
int id = 0;
|
||||
public void Initial(int id, string image, string url)
|
||||
{
|
||||
this.id = id;
|
||||
this.image = image;
|
||||
var ri = transform.Find("Image").GetComponent<RawImage>();
|
||||
Utils.DisplayImageTempDict(ri, image, caches);
|
||||
App.ActivityUrl = url;
|
||||
this.url = url;
|
||||
}
|
||||
@@ -45,4 +62,10 @@ public class ActivityAdController : PFUIPanel
|
||||
{
|
||||
|
||||
}
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,7 @@ public class ActivityController : PFUIPanel
|
||||
protected override void Awake()
|
||||
{
|
||||
browser = transform.Find("Browser");
|
||||
var rect = browser.GetComponent<RectTransform>();
|
||||
webView = browser.GetComponent<UniWebView>();
|
||||
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
|
||||
webView.ReferenceRectTransform = rect;
|
||||
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
|
||||
//webView.LoadHTMLString("<div style='width:100%;height:100%;background:#000;'></div>", "http://192.168.0.101:3081");
|
||||
//webView.Show();
|
||||
}
|
||||
@@ -34,6 +30,11 @@ public class ActivityController : PFUIPanel
|
||||
{
|
||||
Debug.Log("开始");
|
||||
// Load a URL.
|
||||
|
||||
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
|
||||
webView.ReferenceRectTransform = browser.GetComponent<RectTransform>();
|
||||
webView.SetUserAgent($"UniWebView {Application.platform} {Application.version}");
|
||||
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
|
||||
webView.Load(url);
|
||||
// Show it.
|
||||
webView.Show();
|
||||
@@ -47,6 +48,7 @@ public class ActivityController : PFUIPanel
|
||||
case "Close": CloseFunc(); break;
|
||||
case "StartRide": StartRide(message.Args); break;
|
||||
case "Share": Share(message.Args); break;
|
||||
case "OpenUrl": OpenUrl(message.Args); break;
|
||||
default:break;
|
||||
}
|
||||
//if (message.Path.Equals("Close"))
|
||||
@@ -56,6 +58,11 @@ public class ActivityController : PFUIPanel
|
||||
//}
|
||||
}
|
||||
|
||||
private void OpenUrl(Dictionary<string, string> args)
|
||||
{
|
||||
Application.OpenURL(System.Net.WebUtility.UrlDecode(args["url"]));
|
||||
}
|
||||
|
||||
private void Share(Dictionary<string, string> args)
|
||||
{
|
||||
int type = int.Parse(args["type"]);
|
||||
@@ -72,7 +79,7 @@ public class ActivityController : PFUIPanel
|
||||
else
|
||||
{
|
||||
UnityEngine.GUIUtility.systemCopyBuffer = url;
|
||||
browser.GetComponent<UniWebView>().EvaluateJavaScript("alert(\"复制成功\")");
|
||||
browser.GetComponent<UniWebView>().EvaluateJavaScript("window.postMessage(\"webview;复制成功\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user