修改活动逻辑;增加一些接口;可弹多个广告
This commit is contained in:
parent
1148e29379
commit
1b3743a135
@ -50,6 +50,7 @@ public class RecommendController : MonoBehaviour
|
||||
UIManager.ShowNewRouteDetailPanel(res.data.Id);
|
||||
break;
|
||||
case 2:
|
||||
await ConfigHelper.activityApi.JoinActivity(Area.ActivityId ?? 0);
|
||||
UIManager.ShowActivityPanel(Area.Url + "?Token=" + App.CurrentUser.cookie);
|
||||
//Application.OpenURL(Area.Url);
|
||||
break;
|
||||
|
||||
@ -294,7 +294,7 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 525523089819956055}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -368,6 +368,7 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 2090836201531894202}
|
||||
- {fileID: 2050749757860681065}
|
||||
- {fileID: 525523089472465304}
|
||||
m_Father: {fileID: 0}
|
||||
@ -539,7 +540,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &2050749757860681065
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -556,7 +557,7 @@ RectTransform:
|
||||
- {fileID: 8531341998025236401}
|
||||
- {fileID: 6473701544485149591}
|
||||
m_Father: {fileID: 525523089819956055}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -678,6 +679,77 @@ MonoBehaviour:
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u9A6C\u4E0A\u53C2\u52A0"
|
||||
--- !u!1 &3385961605716274462
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2090836201531894202}
|
||||
- component: {fileID: 6322400348156303082}
|
||||
- component: {fileID: 4877973275652039468}
|
||||
m_Layer: 5
|
||||
m_Name: Image
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2090836201531894202
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3385961605716274462}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 525523089819956055}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 365, y: 365}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6322400348156303082
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3385961605716274462}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &4877973275652039468
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3385961605716274462}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Texture: {fileID: 0}
|
||||
m_UVRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
--- !u!1 &6816544219278866307
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
61
Assets/Scripts/Apis/Models/ActivityModel.cs
Normal file
61
Assets/Scripts/Apis/Models/ActivityModel.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/ActivityModel.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/ActivityModel.cs.meta
Normal file
@ -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));
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user