diff --git a/projects/IoTClient/Assembly-CSharp-Editor.csproj b/projects/IoTClient/Assembly-CSharp-Editor.csproj index 82ef0d1c..5d3dc9d7 100644 --- a/projects/IoTClient/Assembly-CSharp-Editor.csproj +++ b/projects/IoTClient/Assembly-CSharp-Editor.csproj @@ -68,19 +68,19 @@ - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.CollabProxy.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.CollabProxy.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.Analytics.DataPrivacy.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.Analytics.DataPrivacy.dll D:/ProgramFiles/Unity/2018.3.14f1/Editor/Data/Managed/UnityEngine/UnityEngine.AIModule.dll @@ -323,22 +323,22 @@ C:/Program Files (x86)/Microsoft Visual Studio Tools for Unity/15.0/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll - D:/1.0/ZHXY/labs/IoTClient/Assets/UniversalMediaPlayer/Plugins/MediaPlayer.dll + D:/1.0/ZHXY/projects/IoTClient/Assets/UniversalMediaPlayer/Plugins/MediaPlayer.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.ads@2.0.8/Editor/UnityEditor.Advertisements.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.ads@2.0.8/Editor/UnityEditor.Advertisements.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.StandardEvents.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.StandardEvents.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Tracker.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Tracker.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.purchasing@2.0.3/Editor/UnityEditor.Purchasing.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.purchasing@2.0.3/Editor/UnityEditor.Purchasing.dll D:/ProgramFiles/Unity/2018.3.14f1/Editor/Data/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll diff --git a/projects/IoTClient/Assembly-CSharp.csproj b/projects/IoTClient/Assembly-CSharp.csproj index c96e33cf..f2b84e04 100644 --- a/projects/IoTClient/Assembly-CSharp.csproj +++ b/projects/IoTClient/Assembly-CSharp.csproj @@ -339,6 +339,8 @@ + + @@ -351,19 +353,19 @@ - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.PackageManagerUI.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.CollabProxy.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.CollabProxy.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.TextMeshPro.dll - D:/1.0/ZHXY/labs/IoTClient/Library/ScriptAssemblies/Unity.Analytics.DataPrivacy.dll + D:/1.0/ZHXY/projects/IoTClient/Library/ScriptAssemblies/Unity.Analytics.DataPrivacy.dll D:/ProgramFiles/Unity/2018.3.14f1/Editor/Data/Managed/UnityEngine/UnityEngine.AIModule.dll @@ -564,16 +566,16 @@ D:/ProgramFiles/Unity/2018.3.14f1/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll - D:/1.0/ZHXY/labs/IoTClient/Assets/UniversalMediaPlayer/Plugins/MediaPlayer.dll + D:/1.0/ZHXY/projects/IoTClient/Assets/UniversalMediaPlayer/Plugins/MediaPlayer.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Editor.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Editor.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.StandardEvents.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.StandardEvents.dll - D:/1.0/ZHXY/labs/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Tracker.dll + D:/1.0/ZHXY/projects/IoTClient/Library/PackageCache/com.unity.analytics@3.2.2/Unity.Analytics.Tracker.dll D:/ProgramFiles/Unity/2018.3.14f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll diff --git a/projects/IoTClient/Assets/Scripts/FaceDetectionController.cs b/projects/IoTClient/Assets/Scripts/FaceDetectionController.cs index 1600a29c..83489665 100644 --- a/projects/IoTClient/Assets/Scripts/FaceDetectionController.cs +++ b/projects/IoTClient/Assets/Scripts/FaceDetectionController.cs @@ -229,8 +229,9 @@ namespace Assets.Scripts { var form = new WWWForm(); form.AddBinaryData("face", jpgBytes); - using (var request = UnityWebRequest.Post("http://192.168.253.1:8000/Account/FaceLogin", form)) + using (var request = UnityWebRequest.Post(WebViewController.Server + "/Account/FaceLogin", form)) { + text.text = WebViewController.Server; yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { @@ -238,11 +239,16 @@ namespace Assets.Scripts } else { - Debug.Log(request.downloadHandler.text); - var result = JsonUtility.FromJson(request.downloadHandler.text); - if (result.Success) + var response = request.downloadHandler.text; + Debug.Log(response); + var result = JsonUtility.FromJson(response); + if (result.Code == 0) { text.text = result.NickName; + result.Server = WebViewController.Server; + result.RememberMe = WebViewController.RememberMe; + WebViewController.LoginMessage = JsonUtility.ToJson(result); + SceneManager.LoadScene(0); } } } diff --git a/projects/IoTClient/Assets/Scripts/LoginResult.cs b/projects/IoTClient/Assets/Scripts/LoginResult.cs index b7366346..467e46a7 100644 --- a/projects/IoTClient/Assets/Scripts/LoginResult.cs +++ b/projects/IoTClient/Assets/Scripts/LoginResult.cs @@ -1,6 +1,11 @@ public class LoginResult { - public bool Success; + public int Code; public string UserName; public string NickName; + public string Token; + public string Title; + public string IoTServer; + public string Server; + public bool RememberMe; } \ No newline at end of file diff --git a/projects/IoTClient/Assets/Scripts/WebViewController.cs b/projects/IoTClient/Assets/Scripts/WebViewController.cs index c937caa4..578c0c43 100644 --- a/projects/IoTClient/Assets/Scripts/WebViewController.cs +++ b/projects/IoTClient/Assets/Scripts/WebViewController.cs @@ -1,4 +1,6 @@ -using UnityEngine; +using System.Text.RegularExpressions; +using UnityEngine; +using UnityEngine.Networking; using UnityEngine.SceneManagement; public class WebViewController : MonoBehaviour @@ -6,6 +8,10 @@ public class WebViewController : MonoBehaviour { private UniWebView webView; + public static string LoginMessage { get; set; } + public static string Server { get; set; } + public static bool RememberMe { get; set; } + private void Start() { var webViewGameObject = new GameObject("UniWebView"); @@ -18,8 +24,22 @@ public class WebViewController : MonoBehaviour }; webView.OnMessageReceived += (view, message) => { - if (message.Path == "facelogin") + if (message.Path == "init") + { + if (string.IsNullOrEmpty(LoginMessage)) + { + webView.EvaluateJavaScript($"load()"); + } + else + { + webView.EvaluateJavaScript($"load2('{LoginMessage}')"); + LoginMessage = null; + } + } + else if (message.Path == "facelogin") { + Server = UnityWebRequest.UnEscapeURL(Regex.Match(message.RawMessage, "Server=(.*)&").Groups[1].Value); + RememberMe = Regex.Match(message.RawMessage, "RememberMe=(.*)").Groups[1].Value == "true"; this.FaceLogin(); } }; diff --git a/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj.meta b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj.meta new file mode 100644 index 00000000..e5aa5133 --- /dev/null +++ b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ad4e74daf3223ec46a53e3944338ad38 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/projects/IoTClient/Assets/StreamingAssets/Resource.cs.meta b/projects/IoTClient/Assets/StreamingAssets/Resource.cs.meta new file mode 100644 index 00000000..d7e25c0f --- /dev/null +++ b/projects/IoTClient/Assets/StreamingAssets/Resource.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3021fb3419ffa244ea3b795785441d3f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/projects/IoTClient/Assets/StreamingAssets/bin.meta b/projects/IoTClient/Assets/StreamingAssets/bin.meta new file mode 100644 index 00000000..ca0fbe30 --- /dev/null +++ b/projects/IoTClient/Assets/StreamingAssets/bin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 061c976d505588c4f8aea2c9cf73960a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/projects/IoTClient/Assets/StreamingAssets/obj.meta b/projects/IoTClient/Assets/StreamingAssets/obj.meta new file mode 100644 index 00000000..597df547 --- /dev/null +++ b/projects/IoTClient/Assets/StreamingAssets/obj.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3128d97a98613c340b87b33f5bbbfd19 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/css/app.css b/projects/IoTClient/Assets/StreamingAssets/wwwroot/css/app.css index 77ca62e0..c68b722b 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/css/app.css +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/css/app.css @@ -65,6 +65,9 @@ img.shot.zoom { overflow: auto; } /*html5 input rang style*/ +input[type='range']{ + width:100%; +} input[type='range']::-webkit-slider-thumb { border: 15px solid #fff; border-radius: 15px; diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html index 2447fcb4..8773495e 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/index.html @@ -27,7 +27,7 @@ 登录 - +