活动暂存

This commit is contained in:
Caiyanpeng committed 2022-02-16 18:22:27 +08:00
1 parent e231d3540e
commit 1148e29379
30 files changed
+3478 -29

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
using Assets.Scripts.Apis.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Apis
{
public class ActivityApi : ApiBase
{
public async Task<JsonResult<object>> GetCurrentActivityList()
{
var result = await GetAsync<JsonResult<object>>($"MapRouteActivityRecord/GetCurrentActivityList");
return result;
}
public async Task<JsonResult<object>> JoinActivity(int id)
{
var result = await PostAsync<JsonResult<object>>($"MapRouteActivityRecord/Add", new { id });
return result;
}
public async Task<JsonResult<object>> GetMapRouteRecordById(int id, int activityId)
{
var result = await GetAsync<JsonResult<object>>($"MapRouteActivityRecord/GetMapRouteRecordById");
return result;
}
//
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43b1d699511a9e340a85aac88a8bbd0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8 -7
View File
@@ -20,12 +20,13 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.101:5084/";
public static string Host = "http://192.168.0.101:5085/";
public static string AppVersion = Application.version;
public static int RouteIdParam = 0;
public static UserResultModel CurrentUser { get; set; }
public static string ActivityUrl { get; internal set; }
#if !(UNITY_ANDROID || UNITY_IOS)
//pc版微信id
public static string WxAppId => "wx9e8ca734e024f084";
@@ -200,13 +201,13 @@ public static class App
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
//线上
Host = "https://wx.powerfun.com.cn/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
//Host = "https://wx.powerfun.com.cn/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
//本地
//Host = "http://192.168.0.101:5085/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
Host = "http://192.168.0.101:5085/";
UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
Debug.unityLogger.logEnabled = false;
#else
//Host = "http://pf.juze.pro/";
+9
View File
@@ -23,6 +23,15 @@ namespace Assets.Scripts
return _userApi;
}
}
private static ActivityApi _activityApi;
public static ActivityApi activityApi
{
get
{
if (_activityApi == null) _activityApi = new ActivityApi();
return _activityApi;
}
}
private static MapApi _mapApi;
public static MapApi mapApi
{
+2
View File
@@ -337,6 +337,8 @@ public class MainController : BaseScene
else
{
UIManager.ShowHomePanel();
var _r = await ConfigHelper.activityApi.GetCurrentActivityList();
UIManager.ShowActivityAdPanel();
//UIManager.ShowNewRouteOverviewPanel();
//UIManager.ShowUserInfoPanel();
//UIManager.ShowEditUserPanel();
@@ -0,0 +1,48 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ActivityAdController : PFUIPanel
{
protected override void Awake()
{
UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
UIManager.AddEvent(transform.Find("LightUpChina/Btn").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
//可以传参
//UIManager.ShowActivityPanel(url);
ConfigHelper.activityApi.JoinActivity(2);
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/");
//});
}
string image = null, url = null;
public void Initial(string image, string url)
{
this.image = image;
App.ActivityUrl = url;
this.url = url;
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7b1e8b738244e0c479ad2a05dd24d3e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,36 +1,40 @@
using System.Collections;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ActivityController : PFUIPanel
{
Transform browser;
UniWebView webView;
protected override void Awake()
{
browser = transform.Find("Browser");
UIManager.AddEvent(browser.Find("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
CloseFunc();
});
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();
}
public override void Show()
{
base.Show();
Debug.Log(20);
Invoke("StartPageFunc",1.0f);
//Debug.Log(20);
//Invoke("StartPageFunc",0.5f);
}
private void StartPageFunc()
{
Debug.Log("开始");
var rect = browser.GetComponent<RectTransform>();
var webView = browser.GetComponent<UniWebView>();
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
webView.ReferenceRectTransform = rect;
// Load a URL.
webView.Load("http://192.168.0.101:3081/Activity/LightUpChina");
webView.Load(url);
// Show it.
webView.Show();
webView.OnMessageReceived -= FromJs;
@@ -41,6 +45,8 @@ public class ActivityController : PFUIPanel
switch (message.Path)
{
case "Close": CloseFunc(); break;
case "StartRide": StartRide(message.Args); break;
case "Share": Share(message.Args); break;
default:break;
}
//if (message.Path.Equals("Close"))
@@ -49,6 +55,39 @@ public class ActivityController : PFUIPanel
// //transform.Find("Text").GetComponent<Text>().text = message.Args["msg"];
//}
}
private void Share(Dictionary<string, string> args)
{
int type = int.Parse(args["type"]);
int id = int.Parse(args["id"]);
string url = $"http://192.168.0.101:3081/Activity/LightUpChina/Share?userId={App.CurrentUser.Id}";
if (type < 2)
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(type, url, "点亮中国活动", "by " + App.CurrentUser.Nickname, null);
}
}
else
{
UnityEngine.GUIUtility.systemCopyBuffer = url;
browser.GetComponent<UniWebView>().EvaluateJavaScript("alert(\"复制成功\")");
}
}
private void StartRide(Dictionary<string, string> args)
{
var id = int.Parse(args["id"]);
App.RouteIdParam = id;
if (args.ContainsKey("routeResult"))
{
Debug.Log(args.ContainsKey("routeResult"));
App.routeResult = JsonConvert.DeserializeObject<RouteResult>(args["routeResult"]);
}
SceneManager.LoadScene("Ride");
}
private void CloseFunc()
{
CancelInvoke("StartPageFunc");
@@ -59,4 +98,22 @@ public class ActivityController : PFUIPanel
{
}
string url { get; set; }
public void Initial(string url)
{
this.url = url;
Debug.Log(this.url);
StartPageFunc();
return;
if (this.url != url)
{
this.url = url;
StartPageFunc();
}
else
{
//执行浏览器内刷新或者其他操作
}
}
}
@@ -0,0 +1,45 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AddressController : PFUIPanel
{
// Start is called before the first frame update
Dictionary<string, InputField> inputDict;
protected override void Awake()
{
inputDict = new Dictionary<string, InputField>()
{
{"Name",transform.Find("Main/Name/input").GetComponent<InputField>() },
{"Phone",transform.Find("Main/PN/input").GetComponent<InputField>() },
{"Address",transform.Find("Main/Addr/input").GetComponent<InputField>() },
};
inputDict["Name"].text = App.CurrentUser.Contact;
inputDict["Phone"].text = App.CurrentUser.ContactPhone;
inputDict["Address"].text = App.CurrentUser.ContactAddress;
UIManager.AddEvent(transform.Find("Main/BtnJoin").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
{
App.CurrentUser.Contact = inputDict["Name"].text;
App.CurrentUser.ContactPhone = inputDict["Phone"].text;
App.CurrentUser.ContactAddress = inputDict["Address"].text;
var res = await ConfigHelper.userApi.UpdateUserInfo(App.CurrentUser);
if (res.result)
{
Close();
UIManager.ShowActivityPanel(App.ActivityUrl);
}
});
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6337a1358d5d95f4293c650d8486815d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -178,8 +178,6 @@ public class HomeController : PFUIPanel
//进入比赛
private void GoMatch(BaseEventData e)
{
UIManager.ShowActivityPanel();
return;
UIManager.ShowRaceHomePanel();
OnExit(e);
}
+30 -1
View File
@@ -393,10 +393,39 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("ActivityPanel", ref this.mActivityController);
}
}
public static void ShowActivityPanel()
public static void ShowActivityPanel(string url)
{
UIManager.Show(UIManager.Instance.ActivityController, null, true);
UIManager.Instance.ActivityController.Initial(url);
}
//活动弹窗
ActivityAdController mActivityAdController;
public ActivityAdController ActivityAdController
{
get
{
return this.GetPanelInstance("ActivityAdPanel", ref this.mActivityAdController);
}
}
public static void ShowActivityAdPanel()
{
UIManager.Instance.ActivityAdController.GetComponent<ActivityAdController>().Initial("", $"http://192.168.0.101:3081/Activity/LightUpChina?Token={App.CurrentUser.cookie}");
UIManager.Show(UIManager.Instance.ActivityAdController, null, true);
}
//收货地址
AddressController mAddressController;
public AddressController AddressController
{
get
{
return this.GetPanelInstance("AddressPanel", ref this.mAddressController);
}
}
public static void ShowAddressPanel()
{
UIManager.Show(UIManager.Instance.AddressController, null, true);
}
#region 比赛点击弹窗
private RaceModalScript mRaceModalScript;
public RaceModalScript RaceDetailModal