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

This commit is contained in:
lishuo committed 2022-02-23 11:31:23 +08:00
commit 6a0bd67a6e
20 files changed
+3005 -290

No files matched your search

@@ -57,5 +57,6 @@ namespace Assets.Scripts.Apis.Models
/// </summary>
public double TotalTicks { get; set; }
public string Url { get; set; }
public string GlobalDetailUrl { get; set; }
}
}
+1
View File
@@ -29,5 +29,6 @@ namespace Assets.Scripts.Apis.Models
/// </summary>
public string Url { get; set; }
public int? ActivityId { get; set; }
public string GlobeTitle { get; set; }
}
}
+7 -7
View File
@@ -20,7 +20,7 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.101:5085/";
public static string Host = "http://192.168.0.101:5083/";
public static string AppVersion = Application.version;
@@ -203,17 +203,17 @@ public static class App
InitLanguage();
#if !UNITY_EDITOR
//测试服务器
//Host = "http://pf.juze.pro/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
Host = "http://pf.juze.pro/";
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 = "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/";
+5 -2
View File
@@ -350,8 +350,11 @@ public class MainController : BaseScene
{
App.adQueue.Enqueue(_ad);
}
var ad = App.adQueue.Dequeue();
UIManager.ShowActivityAdPanel(ad.Id, ad.DetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}");
if (App.adQueue.Count > 0)
{
var ad = App.adQueue.Dequeue();
UIManager.ShowActivityAdPanel(ad.Id, App.GetLocalLanguage() == "zh" ? ad.DetailUrl : ad.GlobalDetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}");
}
}
}
@@ -822,9 +822,9 @@ public BaseUIManager singleUIManager;
Camera.main.transform.DOLocalMove(neareast, 1f);
//StartCoroutine(MoveCamera(far, near));//初始摄像头
var check = CheckAnt();
#if UNITY_EDITOR
//#if UNITY_EDITOR
check = true;
#endif
//#endif
if (check || isWatch)
{
singleUIManager.StartRide();
@@ -60,9 +60,9 @@ namespace Assets.Scenes.Ride.Scripts
cadance = mainController.UpdateCadence();
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
#if UNITY_EDITOR
power = 330;
#endif
//#if UNITY_EDITOR
power = 300;
//#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
}
catch (Exception ex)
@@ -6,35 +6,100 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
#if UNITY_STANDALONE_WIN
using ZenFulcrum.EmbeddedBrowser;
#endif
public class ActivityController : PFUIPanel
{
Transform browser;
#if UNITY_STANDALONE_WIN
Browser webView;
#else
UniWebView webView;
#endif
protected override void Awake()
{
this.url = null;
browser = transform.Find("Browser");
#if UNITY_STANDALONE_WIN
webView = browser.GetComponent<Browser>();
webView.onLoad -= RegisterFunc;
webView.onLoad += RegisterFunc;
#if UNITY_EDITOR
webView.ShowDevTools(true);
#endif
#else
webView = browser.GetComponent<UniWebView>();
#endif
//webView.Show();
}
#if UNITY_STANDALONE_WIN
private void RegisterFunc(JSONNode obj)
{
RunJavaScript($"navigator.pfLang = '{App.GetLocalLanguage()}';");
webView.RegisterFunction("Close", args =>
{
Debug.Log("执行返回");
CloseFunc();
});
webView.RegisterFunction("StartRide", args =>
{
if (args.Count == 2)
{
StartRide((int)args[0], args[1]);
}
});
webView.RegisterFunction("OpenUrl", args =>
{
if (args.Count == 1)
{
OpenUrl(args[0]);
}
});
webView.RegisterFunction("Share", args =>
{
if (args.Count == 2)
{
Share((int)args[0], (int)args[1]);
}
});
}
#endif
public override void Show()
{
base.Show();
//Debug.Log(20);
//Invoke("StartPageFunc",0.5f);
}
private void StartPageFunc()
#if UNITY_STANDALONE_WIN
private void StartPageFunc(Action action = null)
{
if (action == null)
{
webView.LoadURL(url, true);
}
else
{
action.Invoke();
}
}
#else
private void StartPageFunc(Action action = null)
{
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);
if (action == null)
{
webView.Load(url);
}
else
{
action.Invoke();
}
// Show it.
webView.Show();
webView.OnMessageReceived -= FromJs;
@@ -45,29 +110,22 @@ public class ActivityController : PFUIPanel
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;
case "StartRide": StartRide(int.Parse(message.Args["id"]),message.Args.ContainsKey("routeResult")?message.Args["routeResult"]:null); break;
case "Share": Share(int.Parse(message.Args["type"]),int.Parse(message.Args["id"])); break;
case "OpenUrl": OpenUrl(message.Args["url"]); break;
default:break;
}
//if (message.Path.Equals("Close"))
//{
// Debug.Log(message.Args["msg"]);
// //transform.Find("Text").GetComponent<Text>().text = message.Args["msg"];
//}
}
#endif
private void OpenUrl(string url)
{
Application.OpenURL(System.Net.WebUtility.UrlDecode(url));
}
private void OpenUrl(Dictionary<string, string> args)
private void Share(int type,int id)
{
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}";
string url = $"http://pfweb.juze.pro/Activity/LightUpChina/Share?userId={App.CurrentUser.Id}";
if (type < 2)
{
if (App.weChatController.IsWeChatAppInstalled())
@@ -75,21 +133,26 @@ public class ActivityController : PFUIPanel
App.weChatController.ShareWebpageToWX(type, url, "点亮中国活动", "by " + App.CurrentUser.Nickname, null);
}
}
else
else if (type == 2)
{
UnityEngine.GUIUtility.systemCopyBuffer = url;
browser.GetComponent<UniWebView>().EvaluateJavaScript("window.postMessage(\"webview;复制成功\")");
RunJavaScript("window.postMessage(\"webview;复制成功\")");
}
else
{
Facebook.Unity.FB.ShareLink(contentURL: new Uri(url),
contentTitle: "点亮中国活动",
contentDescription: "By " + App.CurrentUser.Nickname,
photoURL: new Uri(App.CurrentUser.WxHeadImg));
}
}
private void StartRide(Dictionary<string, string> args)
private void StartRide(int id,string routeResult)
{
var id = int.Parse(args["id"]);
App.RouteIdParam = id;
if (args.ContainsKey("routeResult"))
if (routeResult!=null)
{
Debug.Log(args.ContainsKey("routeResult"));
App.routeResult = JsonConvert.DeserializeObject<RouteResult>(args["routeResult"]);
App.routeResult = JsonConvert.DeserializeObject<RouteResult>(routeResult);
}
SceneManager.LoadScene("Ride");
}
@@ -99,6 +162,15 @@ public class ActivityController : PFUIPanel
CancelInvoke("StartPageFunc");
Close();
}
private void RunJavaScript(string js)
{
#if UNITY_STANDALONE_WIN
webView.EvalJS(js);
#else
browser.GetComponent<UniWebView>().EvaluateJavaScript(js);
#endif
}
// Update is called once per frame
void Update()
{
@@ -108,10 +180,7 @@ public class ActivityController : PFUIPanel
public void Initial(string url)
{
this.url = url;
Debug.Log(this.url);
StartPageFunc();
return;
Debug.Log(url);
if (this.url != url)
{
this.url = url;
@@ -120,6 +189,11 @@ public class ActivityController : PFUIPanel
else
{
//执行浏览器内刷新或者其他操作
StartPageFunc(()=>
{
RunJavaScript("window.postMessage(\"webview;Refresh\")");
});
}
}
}