E_ElecCompetition/Electrical_inspectionCompet.../Assets/Adam/Scripts/LoginController.cs

87 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
// Use this for initialization
private void Start()
{
//var res = await AsyncWebReq.Get<LineLossData>(url);
//Debug.Log(res == null);
loginBtn.onClick.AddListener(() =>
{
OnLogin();
});
onTrain.onClick.AddListener(() =>
{
OnTrain();
});
SwitchPanel(0);
}
public async void OnLogin()
{
//Debug.Log(loginUrl + "/Handler/Login.ashx?login_name=" + user.text + "&login_card=" + password.text);
//if (string.IsNullOrEmpty(user.text) || string.IsNullOrEmpty(password.text))
//{
// StartCoroutine(WaitCloseErrorPlane("姓名和身份证不能为空"));
// return;
//}
//LoginData msg = await AsyncWebReq.Post<LoginData>(loginUrl + "/Handler/Login.ashx?login_name=" + user.text + "&login_card=" + password.text, null);
//Debug.Log(msg.state);
//if (msg.state == "Fail")
//{
// StartCoroutine(WaitCloseErrorPlane(msg.data[0].msg));
// return;
//}
SwitchPanel(1);
}
public void OnTrain()
{
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 = "";
}
}