No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

個人帳號罐裡.cs 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6. using UnityEngine.Networking;
  7. using System.Text.RegularExpressions;
  8. using System.Data.SqlClient;
  9. using TMPro;
  10. using System;
  11. using System.IO;
  12. using ZXing;
  13. using ZXing.QrCode;
  14. using System.Net;
  15. using SimpleJSON;
  16. using System.ComponentModel;
  17. using System.Runtime.InteropServices;
  18. public class 個人帳號罐裡 : MonoBehaviour
  19. {
  20. [SerializeField] TextMeshProUGUI 姓名;
  21. [SerializeField] TextMeshProUGUI 帳號;
  22. [SerializeField] TMP_InputField 密碼;
  23. [SerializeField] TextMeshProUGUI 修改日期;
  24. [SerializeField] TextMeshProUGUI 剩餘天;
  25. public CanvasScaler canvasScaler;
  26. float screenWidth;
  27. float screenHeight;
  28. [SerializeField] GameObject 彈跳面板;
  29. [SerializeField] TextMeshProUGUI 彈跳文字;
  30. JSONNode json;
  31. // Start is called before the first frame update
  32. void Start()
  33. {
  34. Screen.autorotateToPortrait = false;
  35. Screen.orientation = ScreenOrientation.Portrait;
  36. float rate = 900.0f / 1900.0f;
  37. if (canvasScaler == null)
  38. {
  39. canvasScaler = GetComponent<CanvasScaler>();
  40. }
  41. if (Main.Global.rate>rate)
  42. {
  43. canvasScaler.matchWidthOrHeight = 1f;
  44. }
  45. else
  46. {
  47. canvasScaler.matchWidthOrHeight = 0f;
  48. }
  49. // Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
  50. //Main.Global.預設伺服器路徑="test";
  51. //Main.Global.人員 = "李協叡";
  52. StartCoroutine(使用者資料());
  53. }
  54. IEnumerator 使用者資料()
  55. {
  56. string strcon = "使用者資料";
  57. string se = Main.Global.預設伺服器路徑;
  58. string pa = Main.Global.人員;
  59. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se,pa);
  60. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  61. yield return request.SendWebRequest();
  62. if (request.result == UnityWebRequest.Result.ConnectionError)
  63. {
  64. Debug.Log(request.error);
  65. yield break;
  66. }
  67. json = JSON.Parse(request.downloadHandler.text);
  68. Debug.Log(json);
  69. 姓名.text=json[0].ToString().Trim('"');
  70. 帳號.text=json[1].ToString().Trim('"');
  71. 密碼.text=json[2].ToString().Trim('"');
  72. 修改日期.text=json[3].ToString().Trim('"');
  73. 剩餘天.text="NA";
  74. }
  75. public void 修改密碼()
  76. {
  77. 彈跳面板.SetActive(true);
  78. if (密碼.text.ToString() != "")
  79. {
  80. string na1 = json[2].ToString().Trim('"');
  81. string na2 = 密碼.text.ToString();
  82. if (na1 == na2)
  83. {
  84. 彈跳文字.text = "未更改密碼";
  85. }
  86. else
  87. {
  88. StartCoroutine(密碼修改());
  89. 彈跳文字.text = "更改成功";
  90. }
  91. }
  92. else
  93. {
  94. 彈跳文字.text = "未輸入密碼";
  95. }
  96. }
  97. IEnumerator 密碼修改()
  98. {
  99. string strcon = "密碼修改";
  100. string se = Main.Global.預設伺服器路徑;
  101. string pa = 密碼.text.ToString();
  102. string pa1 = DateTime.Now.ToString("yyyy/MM/dd");
  103. string pa2 = Main.Global.人員;
  104. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}&PA1={3}&PA2={4}", strcon, se, pa,pa1,pa2);
  105. Debug.Log(strUrl);
  106. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  107. yield return request.SendWebRequest();
  108. if (request.result == UnityWebRequest.Result.ConnectionError)
  109. {
  110. Debug.Log(request.error);
  111. yield break;
  112. }
  113. }
  114. public void 彈跳面板關閉()
  115. {
  116. 彈跳面板.SetActive(false);
  117. 彈跳文字.text = "";
  118. }
  119. public void back()
  120. {
  121. change_Secen(1);
  122. }
  123. public void change_Secen(int _screenNum)
  124. {
  125. SceneManager.LoadScene(_screenNum);
  126. }
  127. public void 截圖()
  128. {
  129. string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
  130. ScreenCapture.CaptureScreenshot(fileName);
  131. }
  132. }