using CommunityToolkit.Mvvm.Messaging; using DotNet4.Utilities; using LiveTools.Data; using Microsoft.VisualBasic.ApplicationServices; using ryCommon; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Threading; namespace LiveTools { public class API { /// /// 检查登录 /// /// /// public static int CheckedLogin(out string ErrorMsg) { try { ErrorMsg = ""; Config.UserInfo.NickName = ""; Config.UserInfo.isOut = 1; HttpResult html = Config.ry_api.Post(Config.Api_Url + "user.aspx", "api=login&userid=" + RyWeb.WebDecode.Escape(Config.UserInfo.UserId) + "&soft_id=" + RyWeb.WebDecode.Escape(Config.SoftId) + "&pwd=" + RyWeb.WebDecode.Escape(Config.UserInfo.Pwd) + "&ver=" + RyWeb.WebDecode.Escape(RySoft.VersionStr) + "&hdid=" + RyWeb.WebDecode.Escape(Config.GetMac()) + "&login=1"); string jsonText = 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.NickName = json.GetJsonValue("nickname"); 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", "邮箱:1017848709@qq.com"); //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"); Config.UserInfo.Ads_id = json.GetJsonValue("ads_id"); return 1; } else if (result == Data.ResultVar.json_UserOutDate.ToString()) { Config.UserInfo.isOut = 1; ErrorMsg = "当前账号需要续费才能使用,请续费。"; return -1000;//需要续费 } else { ErrorMsg = json.GetJsonValue(ConstVar.json_ResultText); //HandyControl.Controls.MessageBox.Show(json.GetJsonValue(ConstVar.json_ResultText), "错误代码:" + result); return -1; } } else { ErrorMsg ="服务器异常,请检查网络连接"; return -100;//服务器异常 } } catch { ErrorMsg = "检查登录过程中发生错误。"; return -2; } } public static bool IsJson(string result) { if (result.Length <= 6) { return false; } else if (result.Substring(0, 1) == "1") { return true; } else { return false; } } public static string GetJson(string result) { if (IsJson(result)) { return result.Substring(6); } else { return ""; } } /// /// 获取相对路径 /// /// /// public static string GetRelativePath(string fullPath) { return fullPath.Replace(Config.GetCurrentFolder,"{app}",true, System.Globalization.CultureInfo.CurrentCulture); } /// /// 获取相对路径 /// /// /// public static string GetTruePath(string fullPath) { return fullPath.Replace("{app}", Config.GetCurrentFolder); } } }