using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using TapTap.Common; using UnityEngine; using UnityEngine.UI; using ZXing; using ZXing.Common; using ZXing.QrCode.Internal; using Debug = UnityEngine.Debug; using Random = System.Random; namespace TapTap.Login.Internal { internal class QRCodeWindow : UIElement { // // \ue90f\ue91c\ue911\ue91a\ue901\ue902\ue903\ue90c 您已取消此次登录 // private static readonly string TEXT_CANCEL_LOGIN = ""; // // // \ue910\ue91f\ue91b\ue914\ue90d 请重新扫码 // private static readonly string TEXT_PLEASE_RESCRAN = ""; // // // \ue914\ue90d\ue900\ue907 扫码成功 // private static readonly string TEXT_SCAN_SUCCESS = ""; // // // \ue910\ue91e\ue917\ue90a\ue915\ue912\ue913 请在手机上确认 // private static readonly string TEXT_CONFIRM_ON_PHONE = ""; public RawImage QRCodeRawImage; public Text StatusText; public Text SubStatusText; public Image RefreshImage; public Button RefreshButton; public Button CloseButton; public Button WebLoginButton; private string clientId; private string[] permissions; private bool isLogin; private string deviceCode; private long expireAt = 0; private long lastCheckAt = 0; private long interval = 5; private Net net; private HttpListener _httpListener; private long lastWebRequestTime = 0; private string webRequestMode = ""; public override Dictionary Extra { get => extra; set { extra = value; if (extra != null) { if (extra.ContainsKey("client_id")) { clientId = extra["client_id"] as string; permissions = extra["permissions"] as string[]; isLogin = (bool)extra["isLogin"]; } } } } private void SetObjectText(string parentName, string objectName, string text) { try { var targetTransform = transform; if (!string.IsNullOrEmpty(parentName)) { targetTransform = transform.Find(parentName).gameObject.transform; } var targetObject = targetTransform.Find(objectName).gameObject; var gameText = targetObject.GetComponent(); gameText.text = text; } catch (Exception e) { Debug.Log("SetObjectText fail" + parentName + " " + objectName); Debug.Log("SetObjectText fail\n" + e); } } void Awake() { var qrImageObject = transform.Find("QRImage").gameObject; QRCodeRawImage = qrImageObject.GetComponent(); var statusObject = transform.Find("Status").gameObject; StatusText = statusObject.GetComponent(); var subStatusObject = transform.Find("SubStatus").gameObject; SubStatusText = subStatusObject.GetComponent(); var refreshObject = transform.Find("Refresh").gameObject; RefreshImage = refreshObject.GetComponent(); var refreshButtonObject = refreshObject.transform.Find("RefreshButton").gameObject; RefreshButton = refreshButtonObject.GetComponent