51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using System;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using DI_Electrical.Model;
|
|
using EasyEncryption;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace DI_Electrical.Services
|
|
{
|
|
public class LoginService : HttpService
|
|
{
|
|
public LoginService() : base()
|
|
{
|
|
|
|
}
|
|
|
|
public async Task<string> Login(string userName, string passwordOrigin)
|
|
{
|
|
|
|
var password = MD5.ComputeMD5Hash(passwordOrigin); //B156525AFDB610B9D6830A1E9D0A1024
|
|
try
|
|
{
|
|
var res = await this.GetAsync<object>($"LoginApi/CheckLogin?username={userName}&password={password}");
|
|
//OnRefresh();
|
|
if (res.code == 200)
|
|
{
|
|
GlobalObject.userInfo = JsonConvert.DeserializeObject<loginRes>(res.data.ToString());// as loginRes;
|
|
GlobalObject.userInfo.userPs = passwordOrigin;
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
return res.info;//ERROR INFO
|
|
}
|
|
|
|
}
|
|
catch (HttpRequestException EX)
|
|
{
|
|
return "http错误。无法连接上服务器。请检查服务器 和 端口。" + EX.Message;
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
return E.Message;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|