30 lines
865 B
C#
30 lines
865 B
C#
using Demo.Common;
|
|
using Demo.Common.Dtos;
|
|
using Demo.Services.Interfaces;
|
|
using RestSharp;
|
|
using System.Windows;
|
|
|
|
namespace Demo.Services
|
|
{
|
|
public class AuthService : BaseService, IAuthService
|
|
{
|
|
public async Task<string> LoginAsync()
|
|
{
|
|
var restRequest = new RestRequest("auth/login");
|
|
restRequest.AddBody(new
|
|
{
|
|
account = "2",
|
|
pwd = "c81e728d9d4c2f636f067f89cc14862c"
|
|
});
|
|
var response = await BaseRestClient.ExecutePostAsync<BaseApiResult<LoginApiResponse>>(restRequest);
|
|
if (!response.IsSuccessful || response.Data == null || response.Data.code != 200)
|
|
{
|
|
MessageBox.Show("登录失败");
|
|
return string.Empty;
|
|
}
|
|
return response.Data.Data.token;
|
|
}
|
|
|
|
}
|
|
}
|