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

+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(