修改活动逻辑;增加一些接口;可弹多个广告
This commit is contained in:
1 parent
1148e29379
commit
1b3743a135
12 files changed
+212
-18
No files matched your search
@@ -11,15 +11,15 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class ActivityApi : ApiBase
|
||||
{
|
||||
public async Task<JsonResult<object>> GetCurrentActivityList()
|
||||
public async Task<JsonResult<List<ActivityModel>>> GetCurrentActivityList()
|
||||
{
|
||||
var result = await GetAsync<JsonResult<object>>($"MapRouteActivityRecord/GetCurrentActivityList");
|
||||
var result = await GetAsync<JsonResult<List<ActivityModel>>>($"MapRouteActivityRecord/GetCurrentActivityList");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<JsonResult<object>> JoinActivity(int id)
|
||||
{
|
||||
var result = await PostAsync<JsonResult<object>>($"MapRouteActivityRecord/Add", new { id });
|
||||
var result = await PostAsync<JsonResult<object>>($"MapRouteActivityRecord/Add", new { activityId = id });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class ActivityModel
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BannerUrl { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 点亮中国
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CreateTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string EndTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string IsDelete { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string IsPublic { get; set; }
|
||||
/// <summary>
|
||||
/// 点亮中国
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// 点亮中国
|
||||
/// </summary>
|
||||
public string Strategy { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string JsonConfig { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double TotalTicks { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 688cf851c22dcdd4b83924371a8f9c85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -28,5 +28,6 @@ namespace Assets.Scripts.Apis.Models
|
||||
/// 活动链接
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
public int? ActivityId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,8 @@ public static class App
|
||||
public static string notifyContent { get; internal set; }
|
||||
//全局用,如果弹多条消息用这个队列
|
||||
public static Queue<string> multiNotifyContent;
|
||||
//全局用,弹多个广告
|
||||
public static Queue<ActivityModel> adQueue;
|
||||
|
||||
public static RideSetting RideSetting = new RideSetting();
|
||||
public static string pageName { get; set; }
|
||||
@@ -233,6 +235,7 @@ public static class App
|
||||
//App.ChangeLanguage("en");
|
||||
globalMessageQueue = new Queue<LinkedMessageEvent>();
|
||||
multiNotifyContent = new Queue<string>();
|
||||
adQueue = new Queue<ActivityModel>();
|
||||
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,18 @@ public class MainController : BaseScene
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
var _r = await ConfigHelper.activityApi.GetCurrentActivityList();
|
||||
UIManager.ShowActivityAdPanel();
|
||||
if (_r.result && _r.data!=null)
|
||||
{
|
||||
var adList = _r.data;
|
||||
App.adQueue.Clear();
|
||||
foreach (var _ad in adList)
|
||||
{
|
||||
App.adQueue.Enqueue(_ad);
|
||||
}
|
||||
var ad = App.adQueue.Dequeue();
|
||||
UIManager.ShowActivityAdPanel(ad.Id, ad.DetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}");
|
||||
}
|
||||
|
||||
//UIManager.ShowNewRouteOverviewPanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowEditUserPanel();
|
||||
|
||||
@@ -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;复制成功\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -407,9 +407,9 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("ActivityAdPanel", ref this.mActivityAdController);
|
||||
}
|
||||
}
|
||||
public static void ShowActivityAdPanel()
|
||||
public static void ShowActivityAdPanel(int id, string image, string url)
|
||||
{
|
||||
UIManager.Instance.ActivityAdController.GetComponent<ActivityAdController>().Initial("", $"http://192.168.0.101:3081/Activity/LightUpChina?Token={App.CurrentUser.cookie}");
|
||||
UIManager.Instance.ActivityAdController.GetComponent<ActivityAdController>().Initial(id, image, url);
|
||||
UIManager.Show(UIManager.Instance.ActivityAdController, null, true);
|
||||
}
|
||||
//收货地址
|
||||
|
||||
@@ -430,6 +430,10 @@ namespace Assets.Scripts
|
||||
{
|
||||
caches.Add(url, texture);
|
||||
}
|
||||
if (img.color.a < 1)
|
||||
{
|
||||
img.color = new Color(img.color.r, img.color.g, img.color.b, 1);
|
||||
}
|
||||
},callback));
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user