Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo

# Conflicts:
#	Assets/Scripts/App.cs
This commit is contained in:
lishuo committed 2022-02-18 15:49:54 +08:00
commit f5294b0d39
42 files changed
+3786 -135

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<List<ActivityModel>>> 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 { activityId = 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:
@@ -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:
+1
View File
@@ -28,5 +28,6 @@ namespace Assets.Scripts.Apis.Models
/// 活动链接
/// </summary>
public string Url { get; set; }
public int? ActivityId { get; set; }
}
}
+14 -7
View File
@@ -20,12 +20,13 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.102:5082/";
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";
@@ -65,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; }
@@ -187,6 +190,9 @@ public static class App
}
}
}
public static bool CanOpenAd = false;
public static Dictionary<string, string> websiteDict = new Dictionary<string, string>()
{
{"https://wx.powerfun.com.cn/","http://www.powerfun.com/" },
@@ -201,13 +207,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/";
@@ -233,6 +239,7 @@ public static class App
//App.ChangeLanguage("en");
globalMessageQueue = new Queue<LinkedMessageEvent>();
multiNotifyContent = new Queue<string>();
adQueue = new Queue<ActivityModel>();
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
}
+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
{
+4
View File
@@ -117,6 +117,10 @@ public class LoginController : BaseScene
public Texture avatar;
// Start is called before the first frame update
private void Awake()
{
App.CanOpenAd = true;
}
void Start()
{
#if UNITY_ANDROID || UNITY_IOS
+18
View File
@@ -337,6 +337,24 @@ public class MainController : BaseScene
else
{
UIManager.ShowHomePanel();
if (App.CanOpenAd)
{
App.CanOpenAd = false;
var _r = await ConfigHelper.activityApi.GetCurrentActivityList();
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();
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81ba7cd19f440d4418b28812b34dbe86
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
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("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
{
Close();
//可以传参
//UIManager.ShowActivityPanel(url);
await ConfigHelper.activityApi.JoinActivity(id);
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/");
//});
}
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;
}
// Update is called once per frame
void Update()
{
}
protected override void OnDestroy()
{
caches = null;
Resources.UnloadUnusedAssets();
GC.Collect();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7b1e8b738244e0c479ad2a05dd24d3e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,125 @@
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");
webView = browser.GetComponent<UniWebView>();
//webView.Show();
}
public override void Show()
{
base.Show();
//Debug.Log(20);
//Invoke("StartPageFunc",0.5f);
}
private void StartPageFunc()
{
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();
webView.OnMessageReceived -= FromJs;
webView.OnMessageReceived += FromJs;
}
private void FromJs(UniWebView webView, UniWebViewMessage message)
{
switch (message.Path)
{
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"))
//{
// Debug.Log(message.Args["msg"]);
// //transform.Find("Text").GetComponent<Text>().text = message.Args["msg"];
//}
}
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"]);
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("window.postMessage(\"webview;复制成功\")");
}
}
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");
Close();
}
// Update is called once per frame
void Update()
{
}
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,11 @@
fileFormatVersion: 2
guid: f1555c37779867f4c8f57a837cfe01c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
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);
}
});
UIManager.AddEvent(transform.Find("Main/Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
}
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:
@@ -16,6 +16,7 @@ public class UserInfoController : PFUIPanel
{
this.transform.localPosition = new Vector3(0, 0, 0);
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
#if UNITY_ANDROID || UNITY_IOS
UIManager.AddEvent(transform.Find("InfoButton").gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowAppleInfoModal(() =>
@@ -23,6 +24,7 @@ public class UserInfoController : PFUIPanel
Load();
});
});
#endif
UIManager.AddEvent(exitBtn.gameObject, EventTriggerType.PointerClick, (b) =>
{
UIManager.ShowPrePanel();
@@ -105,9 +107,12 @@ public class UserInfoController : PFUIPanel
var summary = r.data;
var user = App.CurrentUser;
Debug.Log(user.CanCreateRace);
if(infoPanel == null) infoPanel = transform.Find("InfoPanel").Find("P");
if(summaryPanel == null) summaryPanel = transform.Find("SummaryPanel");
Utils.DisplayHead(infoPanel.Find("Avatar").GetComponent<RawImage>(), user.WxHeadImg);
#if UNITY_ANDROID || UNITY_IOS
transform.Find("InfoButton").gameObject.SetActive(string.IsNullOrEmpty(user.Phone));
#endif
infoPanel.Find("Status").Find("Country").GetComponent<RawImage>().texture
= UIManager.Instance.loginRegOptions.GetCountryImageByName(user.Country);
//infoPanel.Find("Status").Find("Wx").gameObject.SetActive(
+43
View File
@@ -383,6 +383,49 @@ public class UIManager : MonoBehaviour
UIManager.Show(UIManager.Instance.AndroidUpdate, null, true);
UIManager.Instance.AndroidUpdate.StartDownload(jo);
}
//活动页
private ActivityController mActivityController;
public ActivityController ActivityController
{
get
{
return this.GetPanelInstance("ActivityPanel", ref this.mActivityController);
}
}
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(int id, string image, string url)
{
UIManager.Instance.ActivityAdController.GetComponent<ActivityAdController>().Initial(id, image, url);
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
+4
View File
@@ -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));
}