------ #### V1.0.2404.1201 - 新增支持手动运行规则。 - 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。 - 修复规则中播放文件夹可能导致无法执行的BUG。 - 修复规则不勾选礼物和点赞,则无法执行的BUG。
249 lines
10 KiB
C#
249 lines
10 KiB
C#
using CommunityToolkit.Mvvm.Messaging;
|
|
using DotNet4.Utilities;
|
|
using LiveTools.Data;
|
|
using Newtonsoft.Json.Linq;
|
|
using ryCommon;
|
|
using ryCommonDb;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace LiveTools
|
|
{
|
|
/// <summary>
|
|
/// FrmLogin.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class FrmLogin : UserControl
|
|
{
|
|
public FrmLogin()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
Json json = new Json(RyFiles.ReadAllText(Config.AllUserDbFolder + "\\Setting.json"));
|
|
TxtUserId.Text = json.GetJsonValue("UserId", "");
|
|
string pwd = rySafe.AES.Decode(json.GetJsonValue("Pwd", ""), Config.GetMac() + "|" + TxtUserId.Text);
|
|
if (pwd.IndexOf("121") == 0) { pwd = pwd.Substring(3); } else { pwd = ""; }
|
|
TxtPwd.Password = pwd;
|
|
if (pwd != "")
|
|
{
|
|
ChkAutoLogin_On.IsChecked = true;
|
|
TxtUserId.IsEnabled = false;
|
|
TxtPwd.IsEnabled = false;
|
|
BtnOK_Click(this,new RoutedEventArgs());
|
|
}
|
|
else
|
|
{
|
|
TxtUserId.SelectionLength = 0;
|
|
TxtUserId.SelectionStart = 0;
|
|
if (TxtUserId.Text == "")
|
|
{ TxtUserId.Focus(); }
|
|
else
|
|
{
|
|
TxtPwd.Focus();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BtnOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!TxtUserId.Text.Length.IsInRange(1, 20))
|
|
{
|
|
HandyControl.Controls.MessageBox.Show("请输入有效的用户id", "提示");
|
|
return;
|
|
}
|
|
if (!TxtPwd.Password.Length.IsInRange(1, 25))
|
|
{
|
|
HandyControl.Controls.MessageBox.Show("请输入有效的密码", "提示");
|
|
return;
|
|
}
|
|
TxtUserId.IsEnabled = false;
|
|
TxtPwd.IsEnabled = false;
|
|
BtnOK.IsEnabled = false;
|
|
BtnQuit.IsEnabled = false;
|
|
BtnOK.IsChecked = true;
|
|
LblUseSN.IsEnabled = false;
|
|
UserId = TxtUserId.Text;
|
|
Pwd = TxtPwd.Password;
|
|
AutoLogin_On = ChkAutoLogin_On.IsChecked??false;
|
|
RememberUserId_On = ChkRememberUserId_On.IsChecked ?? false;
|
|
Thread th = new Thread(Login);
|
|
th.Start();
|
|
}
|
|
private string UserId { get; set; } = "";
|
|
private string Pwd { get; set; } = "";
|
|
private bool AutoLogin_On { get; set; } = false;
|
|
private bool RememberUserId_On { get; set; } = false;
|
|
private void Login()
|
|
{
|
|
try
|
|
{
|
|
Config.UserInfo.Cookie = "";
|
|
Config.UserInfo.UserId = "";
|
|
Config.UserInfo.NickName = "";
|
|
Config.UserInfo.isOut = 1;
|
|
HttpResult html = Config.ry_api.Post(Config.Api_Url + "user.aspx", "api=login&userid=" + RyWeb.WebDecode.Escape(UserId) +
|
|
"&soft_id=" + RyWeb.WebDecode.Escape(Config.SoftId) + "&pwd=" + RyWeb.WebDecode.Escape(Pwd)
|
|
+ "&ver=" + RyWeb.WebDecode.Escape(RySoft.VersionStr) + "&hdid=" + RyWeb.WebDecode.Escape(Config.GetMac()) + "&login=1");
|
|
string jsonText = API.GetJson(html.Html);
|
|
if (jsonText != "")
|
|
{
|
|
Json json = new Json(jsonText);
|
|
string result = json.GetJsonValue(Data.ConstVar.json_Result);
|
|
if (result == Data.ResultVar.json_Success.ToString())
|
|
{
|
|
Config.UserInfo.UserId=UserId;
|
|
//Config.UserInfo.
|
|
Config.UserInfo.NickName = json.GetJsonValue("nickname");
|
|
Config.UserInfo.Pwd = Pwd;
|
|
Config.UserInfo.OutDateStr = json.GetJsonValue("out_date");
|
|
Config.UserInfo.OutTime = Config.UserInfo.OutDateStr.ToDateTime().ToInt64();
|
|
Config.UserInfo.isOut = json.GetJsonValue("isout").ToInt();
|
|
Config.UserInfo.PriceAds = json.GetJsonValue("PriceAds", "月卡59元,季卡99元,年卡199元,永久卡299元");
|
|
Config.UserInfo.BuyContact = json.GetJsonValue("BuyContact", "QQ1017848709");
|
|
//ClsPram.ZZ_Op = json.GetJsonValue("zz_op").ToInt();
|
|
Config.UserInfo.Media_id = json.GetJsonValue("media_id");
|
|
Config.UserInfo.Setting = json.GetJsonValue("setting");
|
|
Config.UserInfo.Sys_Setting = json.GetJsonValue("sys_setting");
|
|
Config.UserInfo.Parent_Setting = json.GetJsonValue("parent_setting");
|
|
//SysPram.LoadPram();
|
|
Config.UserInfo.Ads_id = json.GetJsonValue("ads_id");
|
|
//string notice = json.GetJsonValue("notice");
|
|
//if (notice != "")
|
|
//{
|
|
// JArray jar = JArray.Parse(json.GetJsonValue("notice"));
|
|
// for (int i = 0; i < jar.Count; i++)
|
|
// {
|
|
// JObject j = JObject.Parse(jar[i].ToString());
|
|
// ClsPram.notice_list.Add(new Notice()
|
|
// {
|
|
// title = j["title"].ToString(),
|
|
// link = j["link"].ToString(),
|
|
// ishot = j["ishot"].ToString().ToInt()
|
|
// });
|
|
// }
|
|
//}
|
|
Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
if (Config.UserInfo.OutTime<=DateTime.Now.Date.AddDays(3).ToInt64())
|
|
{
|
|
HandyControl.Controls.MessageBox.Show("当前账号VIP有效期即将过期,请及时续费。", "提示");
|
|
}
|
|
Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder+ "\\Setting.json"));
|
|
if (AutoLogin_On || RememberUserId_On)
|
|
{
|
|
json.jo["UserId"] = UserId;
|
|
if (AutoLogin_On)
|
|
{
|
|
Config.isAutoLogin = 2;
|
|
json.jo["Pwd"] = rySafe.AES.Encode("121" + Pwd, Config.GetMac() + "|" + UserId);
|
|
}
|
|
else
|
|
{
|
|
Config.isAutoLogin = 1;
|
|
json.jo["Pwd"]="";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
json.jo["UserId"] = "";
|
|
Config.isAutoLogin = 0;
|
|
}
|
|
RyFiles.WriteAllText(Config.AllUserDbFolder + "\\Setting.json", json.Text);
|
|
WeakReferenceMessenger.Default.Send<string>("login");
|
|
WeakReferenceMessenger.Default.Send<MsgToken>(new MsgToken("") { ID = MsgTokenId.Login, From = "LeftMain", Msg = "222" });
|
|
}));
|
|
}
|
|
else if (result ==Data.ResultVar.json_UserOutDate.ToString())
|
|
{
|
|
HandyControl.Controls.MessageBox.Show("当前账号需要续费才能使用,请续费。", "提示");
|
|
FrmUseSN frm = new FrmUseSN();
|
|
frm.TxtUserId.Text = UserId;
|
|
frm.ShowDialog();
|
|
EndLoginUI();
|
|
}
|
|
else
|
|
{
|
|
HandyControl.Controls.MessageBox.Show(json.GetJsonValue(ConstVar.json_ResultText), "错误代码:" + result);
|
|
EndLoginUI();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
EndLoginUI();
|
|
Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
HandyControl.Controls.MessageBox.Show("服务器异常,请联系管理员", "错误代码:-100000");
|
|
}));
|
|
}
|
|
}
|
|
catch { EndLoginUI(); }
|
|
}
|
|
private void EndLoginUI()
|
|
{
|
|
Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
TxtUserId.IsEnabled = true;
|
|
TxtPwd.IsEnabled = true;
|
|
BtnOK.IsEnabled = true;
|
|
BtnQuit.IsEnabled = true;
|
|
BtnOK.IsChecked = false;
|
|
LblUseSN.IsEnabled = true;
|
|
}));
|
|
}
|
|
|
|
private void TxtPwd_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
BtnOK_Click(this, new RoutedEventArgs());
|
|
}
|
|
}
|
|
|
|
private void BtnQuit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Application.Current.MainWindow.Close() ;
|
|
}
|
|
|
|
private void BtnOK_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void LblUseSN_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Config.UserInfo.UserId = TxtUserId.Text;
|
|
FrmUseSN frm = new FrmUseSN();
|
|
frm.Owner = Application.Current.MainWindow;
|
|
if (frm.ShowDialog() == true)
|
|
{
|
|
|
|
}
|
|
Config.UserInfo.UserId = "";
|
|
}
|
|
|
|
private void LblRegUser_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
FrmRegUser frm = new FrmRegUser();
|
|
frm.Owner = Application.Current.MainWindow;
|
|
if (frm.ShowDialog() == true)
|
|
{
|
|
TxtUserId.Text = frm.TxtUserId.Text;
|
|
}
|
|
}
|
|
}
|
|
}
|