123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- using System.Text.RegularExpressions;
- using System.Data.SqlClient;
- using TMPro;
- using System;
- using System.IO;
- using ZXing;
- using ZXing.QrCode;
- using System.Net;
- using SimpleJSON;
- using System.ComponentModel;
- using System.Runtime.InteropServices;
-
- public class 個人帳號罐裡 : MonoBehaviour
- {
- [SerializeField] TextMeshProUGUI 姓名;
- [SerializeField] TextMeshProUGUI 帳號;
- [SerializeField] TMP_InputField 密碼;
- [SerializeField] TextMeshProUGUI 修改日期;
- [SerializeField] TextMeshProUGUI 剩餘天;
-
- public CanvasScaler canvasScaler;
- float screenWidth;
- float screenHeight;
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
- JSONNode json;
- // Start is called before the first frame update
- void Start()
- {
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.Portrait;
- float rate = 900.0f / 1900.0f;
- if (canvasScaler == null)
- {
- canvasScaler = GetComponent<CanvasScaler>();
- }
-
- if (Main.Global.rate>rate)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
- // Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
- //Main.Global.預設伺服器路徑="test";
- //Main.Global.人員 = "李協叡";
- StartCoroutine(使用者資料());
- }
- IEnumerator 使用者資料()
- {
- string strcon = "使用者資料";
- string se = Main.Global.預設伺服器路徑;
- string pa = Main.Global.人員;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se,pa);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- json = JSON.Parse(request.downloadHandler.text);
- Debug.Log(json);
- 姓名.text=json[0].ToString().Trim('"');
- 帳號.text=json[1].ToString().Trim('"');
- 密碼.text=json[2].ToString().Trim('"');
- 修改日期.text=json[3].ToString().Trim('"');
- 剩餘天.text="NA";
- }
- public void 修改密碼()
- {
- 彈跳面板.SetActive(true);
- if (密碼.text.ToString() != "")
- {
- string na1 = json[2].ToString().Trim('"');
- string na2 = 密碼.text.ToString();
- if (na1 == na2)
- {
- 彈跳文字.text = "未更改密碼";
- }
- else
- {
- StartCoroutine(密碼修改());
- 彈跳文字.text = "更改成功";
- }
- }
- else
- {
-
- 彈跳文字.text = "未輸入密碼";
- }
- }
- IEnumerator 密碼修改()
- {
- string strcon = "密碼修改";
- string se = Main.Global.預設伺服器路徑;
- string pa = 密碼.text.ToString();
- string pa1 = DateTime.Now.ToString("yyyy/MM/dd");
- string pa2 = Main.Global.人員;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}&PA1={3}&PA2={4}", strcon, se, pa,pa1,pa2);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- }
- public void 彈跳面板關閉()
- {
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- }
- public void back()
- {
- change_Secen(1);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void 截圖()
- {
- string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
- ScreenCapture.CaptureScreenshot(fileName);
- }
- }
|