|
|
|
@ -40,39 +40,46 @@ namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
/// <param name="passWord">密码</param>
|
|
|
|
|
public void Login(BaseTeamMembers team, string userName, string passWord,object parameter)
|
|
|
|
|
{
|
|
|
|
|
//获取Token
|
|
|
|
|
string url = $"http://10.100.72.10:8080/login";
|
|
|
|
|
var content = new
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
username = userName,
|
|
|
|
|
password = passWord
|
|
|
|
|
};
|
|
|
|
|
//获取Token
|
|
|
|
|
string url = $"http://10.100.72.10:8080/login";
|
|
|
|
|
var content = new
|
|
|
|
|
{
|
|
|
|
|
username = userName,
|
|
|
|
|
password = passWord
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var loginResult = HttpHelper.Post(url, content.ToJson());//发送用户名密码给API
|
|
|
|
|
Result result = JsonSerializer.Deserialize<Result>(loginResult);
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("登录失败!","系统提醒");
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
if (result.code == 200)
|
|
|
|
|
{
|
|
|
|
|
// 存储账号信息
|
|
|
|
|
appConfig.TeamCode = team.TeamCode;
|
|
|
|
|
appConfig.TeamName = team.TeamName;
|
|
|
|
|
appConfig.Account = userName;
|
|
|
|
|
//跳转
|
|
|
|
|
var window = parameter as LoginPageView;
|
|
|
|
|
if (window == null) return;
|
|
|
|
|
window.Hide();
|
|
|
|
|
MainWindow indexPage = new MainWindow();
|
|
|
|
|
indexPage.Show();
|
|
|
|
|
window.Close();
|
|
|
|
|
var loginResult = HttpHelper.Post(url, content.ToJson());//发送用户名密码给API
|
|
|
|
|
Result result = JsonSerializer.Deserialize<Result>(loginResult);
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("登录失败!", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (result.code == 200)
|
|
|
|
|
{
|
|
|
|
|
// 存储账号信息
|
|
|
|
|
appConfig.TeamCode = team.TeamCode;
|
|
|
|
|
appConfig.TeamName = team.TeamName;
|
|
|
|
|
appConfig.Account = userName;
|
|
|
|
|
//跳转
|
|
|
|
|
var window = parameter as LoginPageView;
|
|
|
|
|
if (window == null) return;
|
|
|
|
|
window.Hide();
|
|
|
|
|
MainWindow indexPage = new MainWindow();
|
|
|
|
|
indexPage.Show();
|
|
|
|
|
window.Close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"登录失败!{result.msg}", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"登录失败!{result.msg}", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
log.Error($"登录异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|