151 lines
4.1 KiB
C#
151 lines
4.1 KiB
C#
using Adam;
|
||
using Login;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author #AUTHOR#
|
||
//@create #CREATEDATE#
|
||
//@company #COMPANY#
|
||
//
|
||
//@description:
|
||
//============================================================
|
||
|
||
public class LoginController : MonoBehaviour
|
||
{
|
||
//public string url;
|
||
public string loginUrl;
|
||
public InputField user;
|
||
public InputField password;
|
||
public Text errorInfo;
|
||
public Button loginBtn;
|
||
public GameObject modelChangePlane;
|
||
public GameObject loginPlane;
|
||
|
||
public Button onTrain;
|
||
public string userName;
|
||
public string PassWord;
|
||
public Text nameTex;
|
||
[SerializeField] Image im;
|
||
private void Awake()
|
||
{
|
||
GetLoginInfo();
|
||
Debug.Log(GlobalFlag.currentSceneName);
|
||
UIManager.Instance.Init(GlobalFlag.currentSceneName);
|
||
}
|
||
// Use this for initialization
|
||
public void Start()
|
||
{
|
||
|
||
//var res = await AsyncWebReq.Get<LineLossData>(url);
|
||
//Debug.Log(res == null);
|
||
loginBtn.onClick.AddListener(() =>
|
||
{
|
||
loginBtn.interactable = false;
|
||
OnLogin();
|
||
});
|
||
|
||
onTrain.onClick.AddListener(() =>
|
||
{
|
||
OnTrain();
|
||
});
|
||
//SwitchPanel(0);
|
||
loginBtn.onClick?.Invoke();
|
||
onTrain.onClick?.Invoke();
|
||
}
|
||
|
||
|
||
public void GetLoginInfo()
|
||
{
|
||
string info = FileUtil.ReadFromLocal("info.ini");
|
||
string[] tempInfo = info.Split("//;");
|
||
string[] currentModelInfo = tempInfo[1].Split(";");
|
||
string[] data = currentModelInfo[0].Split(",");
|
||
|
||
|
||
GlobalFlag.currentSceneName = GlobalFlag.sceneName(data[0]);
|
||
GlobalFlag.systemUserId = data[3];
|
||
GlobalFlag.userName = data[4];
|
||
UIManager.Instance.time.SetTime(int.Parse(data[6]));
|
||
//foreach (var item in data)
|
||
//{
|
||
// Debug.Log(item);
|
||
//}
|
||
}
|
||
|
||
public void OnLogin()
|
||
{
|
||
//loginUrl = WebIPAdress.Instance.dicAdresses["登录接口"];
|
||
//if (string.IsNullOrEmpty(user.text) || string.IsNullOrEmpty(password.text))
|
||
//{
|
||
// StartCoroutine(WaitCloseErrorPlane("姓名和身份证不能为空"));
|
||
// loginBtn.interactable = true;
|
||
// return;
|
||
//}
|
||
|
||
//LoginData msgData = await AsyncWebReq.Post<LoginData>(loginUrl + user.text + "&login_card=" + password.text, null);
|
||
|
||
//GlobalFlag.userCardId = password.text;
|
||
//GlobalFlag.userName = user.text;
|
||
//GlobalFlag.isRecord = msgData.record;
|
||
//if (msgData.state == "Fail")
|
||
//{
|
||
// string _msg = "";
|
||
// if (string.IsNullOrEmpty(msgData.msg))
|
||
// _msg = "错误";
|
||
// else
|
||
// _msg = msgData.msg;
|
||
// StartCoroutine(WaitCloseErrorPlane(_msg));
|
||
// loginBtn.interactable = true;
|
||
// return;
|
||
//}
|
||
|
||
|
||
SwitchPanel(1);
|
||
loginBtn.interactable = true;
|
||
userName = user.text;
|
||
PassWord = password.text;
|
||
UIManager.Instance.assignmentController.Init();
|
||
|
||
//if (msgData.code.Equals(1))
|
||
//{
|
||
// if (!string.IsNullOrEmpty(msgData.msg))
|
||
// {
|
||
// //Debug.Log("走断点续存");
|
||
// im.gameObject.SetActive(true);
|
||
// UIManager.Instance.Reconnection.init(msgData.msg);
|
||
// UIManager.Instance.Reconnection.ison = true;
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// //Debug.Log("不走断点续存");
|
||
//}
|
||
}
|
||
|
||
public void OnTrain()
|
||
{
|
||
nameTex.text = "考生姓名:" + GlobalFlag.userName;
|
||
SceneLoad.Instance.SceneChange("02_MapScene");
|
||
SwitchPanel(-1);
|
||
}
|
||
|
||
public void SwitchPanel(int index)
|
||
{
|
||
loginPlane.SetActive(index == 0);
|
||
modelChangePlane.SetActive(index == 1);
|
||
}
|
||
|
||
private IEnumerator WaitCloseErrorPlane(string msg)
|
||
{
|
||
errorInfo.text = msg;
|
||
yield return new WaitForSeconds(2f);
|
||
errorInfo.text = "";
|
||
}
|
||
}
|
||
|
||
|