|
|
|
@ -10,9 +10,8 @@ public class WebViewController : MonoBehaviour
|
|
|
|
|
private UniWebView webView;
|
|
|
|
|
private SerialDevice _sp;
|
|
|
|
|
|
|
|
|
|
public static string LoginMessage { get; set; }
|
|
|
|
|
public static string Server { get; set; }
|
|
|
|
|
public static bool RememberMe { get; set; }
|
|
|
|
|
public static string Token { get; set; }
|
|
|
|
|
public static string FaceLoginUrl { get; set; }
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
@ -26,22 +25,17 @@ public class WebViewController : MonoBehaviour
|
|
|
|
|
};
|
|
|
|
|
webView.OnMessageReceived += (view, message) =>
|
|
|
|
|
{
|
|
|
|
|
if (message.Path == "init")
|
|
|
|
|
if (message.Path == "getToken")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(LoginMessage))
|
|
|
|
|
if (!string.IsNullOrEmpty(Token))
|
|
|
|
|
{
|
|
|
|
|
webView.EvaluateJavaScript($"load()");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
webView.EvaluateJavaScript($"load2('{LoginMessage}')");
|
|
|
|
|
LoginMessage = null;
|
|
|
|
|
this.webView.EvaluateJavaScript($"faceLoginCallback('{Token}')");
|
|
|
|
|
Token = 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";
|
|
|
|
|
FaceLoginUrl = "http://" + UnityWebRequest.UnEscapeURL(Regex.Match(message.RawMessage, "host=(.*)").Groups[1].Value) + "/UserCenter/Account/FaceLogin";
|
|
|
|
|
this.FaceLogin();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -52,7 +46,7 @@ public class WebViewController : MonoBehaviour
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
webView.CleanCache();
|
|
|
|
|
webView.Load(UniWebViewHelper.StreamingAssetURLForPath("wwwroot/index.html"));
|
|
|
|
|
webView.Load(UniWebViewHelper.StreamingAssetURLForPath("wwwroot/index2.html"));
|
|
|
|
|
webView.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|