using AntDesign;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Net.Http;
using System.Net.Http.Json;
using wispro.sp.share.webViewObject;
using wispro.sp.web.Services;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel.Tokens;
using System.Linq;
using System.Security.Claims;
using Blazored.LocalStorage;
using System;
using System.Text.Json;

namespace wispro.sp.web.Pages
{
    public partial class LoginPages
    {
        [Inject] public HttpClient Http { get; set; }
        [Inject] public MessageService MsgSvr { get; set; }
        //[Inject] public AuthenticationStateProvider AuthProvider { get; set; }
        [Inject] public IUserService _UserService { get; set; }
        [Inject] public IAuthService authService { get; set; }

        [Inject] public NavigationManager navigation { get; set; }

        loginDto model = new loginDto();
        bool isLoading;

        async void OnLogin()
        {
            isLoading = true;

            
            bool result = await authService.LoginAsync(model);
            
            if (result)
            {
                navigation.NavigateTo("/Home");
            }
            else
            {
                _ = MsgSvr.Error($"用户名或密码错误");
                
            }
            
            isLoading = false;
        }
    }
}
