846 lines
34 KiB
C#
846 lines
34 KiB
C#
using System;
|
||
using System.Security.Cryptography;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using AllBase;
|
||
using NaiBa.Util.Extension;
|
||
|
||
namespace Work
|
||
{
|
||
public class UserLogin
|
||
{
|
||
public string Mobile;
|
||
public string Password;
|
||
public static bool Logining = false, NoRegedit = false, NoFindPass = false, NoBuy = false;
|
||
/// <summary>
|
||
/// 登录
|
||
/// </summary>
|
||
/// <param name="message"></param>
|
||
/// <returns></returns>
|
||
public bool Get(ref string message, out int lockUserName, out int weakPassword, out string messageInfo)
|
||
{
|
||
bool IsLoginDef = false;
|
||
Logining = true;
|
||
string mobile = Mobile;
|
||
string password = Password;
|
||
string passwordMd5;
|
||
if (password == "******")
|
||
passwordMd5 = BaseClass.PassWord;
|
||
else
|
||
passwordMd5 = Md5Base.GetMd5(password).ToLower();
|
||
BaseClass.PassWord = passwordMd5;
|
||
BaseClass.PassWordBak = BaseClass.PassWord;
|
||
BaseClass.UserName = Mobile;
|
||
Random r = new Random();
|
||
int r2 = r.Next(100000000, 899999999); //生成随机码
|
||
string url = BaseClass.BuildObjString("user/user_login");
|
||
for (int j = 0; j < 100 && string.IsNullOrEmpty(BaseClass.MacInfo); j++)
|
||
{
|
||
Thread.Sleep(10);
|
||
}
|
||
Agian:
|
||
string data = "mobile=" + mobile + "&r2=" + r2 + "&password=" + passwordMd5 + "&" + GetSignature() + "&mac=" + BaseClass.MacInfo + "&version=" + BaseClass.VersionCount;
|
||
data += "&from_tool=" + GetHtml.UrlEncodeUtf8(BaseClass.AgentName) + "&client_ip=" + GetHtml.UrlEncodeUtf8(BaseClass.IPAddress) + "+&client_addr=" + GetHtml.UrlEncodeUtf8(BaseClass.IPAddressName);
|
||
string html = GetHtml.PostUtf8(url, data);
|
||
lockUserName = -1;
|
||
weakPassword = -1;
|
||
messageInfo = "";
|
||
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
|
||
{
|
||
if (!IsLoginDef)
|
||
{
|
||
IsLoginDef = true;
|
||
url = BaseClass.BuildObjString("user/user_login", true);
|
||
goto Agian;
|
||
}
|
||
|
||
message = "链接服务器失败\r\n" +
|
||
"如有问题请联系官方QQ:" + BaseClass.ServiceQQ;
|
||
return false;
|
||
}
|
||
if (!html.Contains("\"code\":200"))
|
||
{
|
||
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
|
||
if (string.IsNullOrEmpty(errMsg))
|
||
errMsg = html;
|
||
message = errMsg;
|
||
return false;
|
||
}
|
||
string code = BaseRegex.GetStringJson(ref html, "c");
|
||
string codex = Encryption(r2);
|
||
if (code != codex)
|
||
{
|
||
message = "登录失败\r\n链接异常请重试";
|
||
return false;
|
||
}
|
||
|
||
BaseClass.UserId = BaseRegex.GetStringJson(ref html, "id").ParseToInt();
|
||
BaseClass.UserKey = BaseRegex.GetStringJson(ref html, "user_key").ParseToInt();
|
||
BaseClass.NickName = BaseRegex.GetStringJson(ref html, "nick_name");
|
||
BaseClass.UserName = BaseRegex.GetStringJson(ref html, "user_name");
|
||
BaseClass.ParentUserName = BaseRegex.GetStringJson(ref html, "parent_user_name");
|
||
BaseClass.SaLevel = BaseRegex.GetIntJson(ref html, "sa_level").ParseToInt();
|
||
BaseClass.UserAuthority = BaseRegex.GetStringJson(ref html, "authority").ParseToString();
|
||
BaseClass.ParentAuthority = BaseRegex.GetStringJson(ref html, "parent_authority").ParseToString();
|
||
BaseClass.Mobile = BaseRegex.GetStringJson(ref html, "mobile");
|
||
BaseClass.UserVersion = BaseRegex.GetStringJson(ref html, "version").ParseToInt();
|
||
BaseClass.UserVersionString = BaseRegex.GetStringJson(ref html, "version_s");
|
||
BaseClass.CompanyId = BaseRegex.GetStringJson(ref html, "company_Id").ParseToInt();
|
||
BaseClass.GroupId = BaseRegex.GetStringJson(ref html, "group_id").ParseToInt();
|
||
BaseClass.AuthorizedAmount = BaseRegex.GetNullableDecimalJson(ref html, "authorized_amount");
|
||
BaseClass.Points = BaseRegex.GetStringJson(ref html, "points").ParseToInt();
|
||
|
||
if (BaseClass.GroupId != 3 && BaseClass.GroupId != 4 && BaseClass.GroupId != 9 && BaseClass.GroupId != 10 && BaseClass.GroupId != 11)
|
||
{
|
||
BaseClass.UserId = 0;
|
||
BaseClass.UserKey = 0;
|
||
return false;
|
||
}
|
||
|
||
BaseClass.EndDate = BaseRegex.GetStringJson(ref html, "end");
|
||
BaseClass.CompanyName = BaseRegex.GetStringJson(ref html, "company_name");
|
||
if (BaseClass.UserVersion == 3)
|
||
{
|
||
BaseClass.QqGroupNum = BaseRegex.GetStringJson(ref html, "qq_group_num");
|
||
BaseClass.QqGroupUrl = BaseRegex.GetStringJson(ref html, "qq_group_url");
|
||
BaseClass.WechatUrl = BaseRegex.GetStringJson(ref html, "wechat_url");
|
||
}
|
||
if (BaseClass.UserVersion == 3 || BaseClass.UserVersion == 4 || BaseClass.UserVersion == 5 || BaseClass.UserVersion == 10 || BaseClass.UserVersion == 9)
|
||
{
|
||
BaseClass.IsPinduoduo = BaseRegex.GetStringJson(ref html, "pinduoduo") == "1";
|
||
BaseClass.AlimamaDomain = BaseRegex.GetStringJson(ref html, "alimama_domain");
|
||
BaseClass.AlimamaPid = BaseRegex.GetStringJson(ref html, "alimama_pid");
|
||
}
|
||
if (!BaseClass.UserApi && BaseClass.UserVersion != 110)
|
||
BaseClass.UserVersion = 100;
|
||
if (BaseClass.UserVersion == 110)
|
||
BaseClass.ClientId = BaseSpecialConfig.ToolClientId; // 特别版本,使用指定ClientId
|
||
|
||
string islock = BaseRegex.GetStringJson(ref html, "is_lock");
|
||
int.TryParse(islock, out lockUserName);
|
||
string isweak = BaseRegex.GetStringJson(ref html, "is_weak_password");
|
||
int.TryParse(isweak, out weakPassword);
|
||
messageInfo = BaseRegex.GetStringJson(ref html, "message");
|
||
|
||
// 代理权限列表
|
||
string agent_auth = BaseRegex.GetStringJson(ref html, "agent_auth");
|
||
if (!string.IsNullOrEmpty(agent_auth) && agent_auth != "0")
|
||
{
|
||
var strArr = agent_auth.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||
foreach (var item in strArr)
|
||
{
|
||
var itemArr = item.Split(',');
|
||
if (itemArr.Length == 2)
|
||
{
|
||
BaseClass.AgentAuth[itemArr[0]] = itemArr[1];
|
||
}
|
||
}
|
||
}
|
||
|
||
BaseClass.IsLoginSuccess = true;
|
||
|
||
Initialization i = new Initialization();
|
||
i.SaveConfig();
|
||
///new Thread(i.GetBaiduCookies).Start();
|
||
//new Thread(IdFessionTaobao.SaveHtmlToSereve).Start(); // 开启一个线程用于写入商品详情缓存数据
|
||
return true;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 注册账户
|
||
/// </summary>
|
||
/// <param name="mobile">手机</param>
|
||
/// <param name="password">密码</param>
|
||
/// <param name="code">验证码</param>
|
||
/// <param name="nickname">昵称</param>
|
||
/// <param name="email">邮箱</param>
|
||
/// <param name="message"></param>
|
||
/// <returns></returns>
|
||
public bool Regedit(string mobile, string password, string code, string nickname, string email, out string message)
|
||
{
|
||
string passwordMd5 = Md5Base.GetMd5(password).ToLower();
|
||
string url = BaseClass.BuildObjString("regedit");
|
||
string data = "mobile=" + mobile + "&password=" + passwordMd5 + "&sms_code=" + code + "&nickname=" + GetHtml.UrlEncodeUtf8(nickname) +
|
||
"&email=" + email + "&" + GetSignature();
|
||
string html = GetHtml.PostUtf8(url, data);
|
||
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
|
||
{
|
||
message = "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
|
||
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
|
||
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
|
||
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
|
||
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
|
||
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
|
||
return false;
|
||
}
|
||
if (!html.Contains("\"code\":200"))
|
||
{
|
||
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
|
||
if (string.IsNullOrEmpty(errMsg))
|
||
errMsg = html;
|
||
message = errMsg;
|
||
if (message.Contains("手机号码已被注册"))
|
||
{
|
||
message = message.Replace("手机号码已被注册", "手机号码已被注册,请直接登录或找回密码");
|
||
}
|
||
if (message.Contains("短信验证码错误"))
|
||
{
|
||
message = "短信验证码错误,请重新输入\r\n如果接收不到,请联系客服QQ:" + BaseClass.ServiceQQ + "";
|
||
}
|
||
return false;
|
||
}
|
||
message = "";
|
||
return true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 重置密码
|
||
/// </summary>
|
||
/// <param name="mobile"></param>
|
||
/// <param name="code"></param>
|
||
/// <param name="password"></param>
|
||
/// <param name="message"></param>
|
||
/// <returns></returns>
|
||
public bool ResetPassword(string mobile, string code, string password, out string message)
|
||
{
|
||
string passwordMd5 = Md5Base.GetMd5(password).ToLower();
|
||
string url = BaseClass.BuildObjString("reset_password");
|
||
string data = "mobile=" + mobile + "&password=" + passwordMd5 + "&sms_code=" + code + "&" + GetSignature();
|
||
string html = GetHtml.PostUtf8(url, data);
|
||
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
|
||
{
|
||
message = "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
|
||
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
|
||
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
|
||
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
|
||
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
|
||
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
|
||
return false;
|
||
}
|
||
if (!html.Contains("\"code\":200"))
|
||
{
|
||
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
|
||
if (string.IsNullOrEmpty(errMsg))
|
||
errMsg = html;
|
||
message = errMsg;
|
||
return false;
|
||
}
|
||
message = "";
|
||
return true;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取签名字符串
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static string GetSignature()
|
||
{
|
||
int time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
|
||
string s = Encryption(time);
|
||
//string s = GetMd5(time1);
|
||
return "time=" + time + "&code=" + s + "&NbCodeVersion=1";
|
||
}
|
||
|
||
public static bool IsPinduoduo = false;
|
||
|
||
/// <summary>
|
||
/// 获取签名字符串,新版
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static string GetSignaturex()
|
||
{
|
||
return GetSignaturex(BaseClass.ShopId, BaseClass.ShopName);
|
||
}
|
||
|
||
public static string GetSignaturex(string shopId, string shopName)
|
||
{
|
||
if (string.IsNullOrEmpty(shopId))
|
||
shopId = BaseClass.ShopId;
|
||
if (string.IsNullOrEmpty(shopName))
|
||
shopName = BaseClass.ShopName;
|
||
int time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
|
||
string time1 = Encryption(time);
|
||
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount +
|
||
"&company_id=" + BaseClass.CompanyId + "&company=" + GetHtml.UrlEncodeUtf8(BaseClass.CompanyName) +
|
||
"&user_name=" + BaseClass.UserName + "&user_key=" + BaseClass.UserKey + "&mobile=" + BaseClass.Mobile +
|
||
"&sid=" + shopId + "&shop=" + GetHtml.UrlEncodeUtf8(shopName);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 签名算法
|
||
/// </summary>
|
||
/// <param name="s">随机数</param>
|
||
/// <returns>加密签名结果</returns>
|
||
public static string Encryptionxx(int s)
|
||
{
|
||
string ss = s.ToString();
|
||
if (ss.Length > 8)
|
||
{
|
||
ss = ss.Substring(ss.Length - 8);
|
||
s = int.Parse(ss);
|
||
if (s < 100000000)
|
||
s += 100000000;
|
||
}
|
||
byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
|
||
if (BaseClass.NewSignatureAuth)
|
||
{
|
||
double y = s * 1.6081825125;
|
||
y += 4582095.48659959;
|
||
y += kb[3] * 934579.486548;
|
||
y += kb[7] + 4889894.30184;
|
||
byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
y -= 478735.48548;
|
||
y -= k[6] * 426720.454545;
|
||
y -= k[2] * 5667826.96889;
|
||
byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
y += 56979810.2455;
|
||
y -= k1[1] * 58742.0564845;
|
||
y -= k1[5] * 1528.487866;
|
||
string c = ((int)y).ToString();
|
||
return GetMd5(c); //返回签名的MD5结果
|
||
}
|
||
else
|
||
{
|
||
double y = s * 1.8061825125;
|
||
y += 4852095.48659959;
|
||
y += kb[3] * 943579.486548;
|
||
y += kb[7] + 4889894.30184;
|
||
byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
y -= 458735.48548;
|
||
y -= k[6] * 458720.454545;
|
||
y -= k[2] * 5447826.96889;
|
||
byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
y += 34779810.2455;
|
||
y -= k1[1] * 57942.0564845;
|
||
y -= k1[5] * 1548.487866;
|
||
string c = ((int)y).ToString();
|
||
return GetMd5(c); //返回签名的MD5结果
|
||
}
|
||
//double y = s * 1.8061825125;
|
||
//y += 4852095.48659959;
|
||
//y += kb[3] * 943579.486548;
|
||
//y += kb[7] + 4889894.30184;
|
||
//byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
//y -= 458735.48548;
|
||
//y -= k[6] * 458720.454545;
|
||
//y -= k[2] * 5447826.96889;
|
||
//byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
//y += 34779810.2455;
|
||
//y -= k1[1] * 57942.0564845;
|
||
//y -= k1[5] * 1548.487866;
|
||
//string c = ((int)y).ToString();
|
||
//return GetMd5(c); //返回签名的MD5结果
|
||
}
|
||
|
||
/// <summary>
|
||
/// 签名算法
|
||
/// </summary>
|
||
/// <param name="s">随机数</param>
|
||
/// <returns>加密签名结果</returns>
|
||
//public static string Encryption(int s)
|
||
//{
|
||
// string ss = s.ToString();
|
||
// if (ss.Length > 8)
|
||
// {
|
||
// ss = ss.Substring(ss.Length - 8);
|
||
// s = int.Parse(ss);
|
||
// if (s < 100000000)
|
||
// s += 100000000;
|
||
// }
|
||
// byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
|
||
// if (BaseClass.NewSignatureAuth)
|
||
// {
|
||
// double y = s * 1.6081825125;
|
||
// y += 4582095.48659959;
|
||
// y += kb[3] * 934579.486548;
|
||
// y += kb[7] + 4889894.30184;
|
||
// byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
// y -= 478735.48548;
|
||
// y -= k[6] * 426720.454545;
|
||
// y -= k[2] * 5667826.96889;
|
||
// byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
// y += 56979810.2455;
|
||
// y -= k1[1] * 58742.0564845;
|
||
// y -= k1[5] * 1528.487866;
|
||
// string c = ((int)y).ToString();
|
||
// return GetMd5(c); //返回签名的MD5结果
|
||
// }
|
||
// else
|
||
// {
|
||
// double y = s * 1.8061825125;
|
||
// y += 4852095.48659959;
|
||
// y += kb[3] * 943579.486548;
|
||
// y += kb[7] + 4889894.30184;
|
||
// byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
// y -= 458735.48548;
|
||
// y -= k[6] * 458720.454545;
|
||
// y -= k[2] * 5447826.96889;
|
||
// byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
// y += 34779810.2455;
|
||
// y -= k1[1] * 57942.0564845;
|
||
// y -= k1[5] * 1548.487866;
|
||
// string c = ((int)y).ToString();
|
||
// return GetMd5(c); //返回签名的MD5结果
|
||
// }
|
||
// //string ss = s.ToString();
|
||
// //if (ss.Length > 8)
|
||
// //{
|
||
// // ss = ss.Substring(ss.Length - 8);
|
||
// // s = int.Parse(ss);
|
||
// // if (s < 100000000)
|
||
// // s += 100000000;
|
||
// //}
|
||
// //byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
|
||
// //double y = s * 1.8061825125;
|
||
// //y += 4852095.48659959;
|
||
// //y += kb[3] * 943579.486548;
|
||
// //y += kb[7] + 4889894.30184;
|
||
// //byte[] k = Encoding.ASCII.GetBytes(y.ToString());
|
||
// //y -= 458735.48548;
|
||
// //y -= k[6] * 458720.454545;
|
||
// //y -= k[2] * 5447826.96889;
|
||
// //byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
|
||
// //y += 34779810.2455;
|
||
// //y -= k1[1] * 57942.0564845;
|
||
// //y -= k1[5] * 1548.487866;
|
||
// //string c = ((int)y).ToString();
|
||
// //return GetMd5(c); //返回签名的MD5结果
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// 加密算法
|
||
/// </summary>
|
||
/// <param name="s">加密字符串</param>
|
||
/// <returns></returns>
|
||
public static string Encryption(int s)
|
||
{
|
||
string sign = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
|
||
return GetMd5(sign);
|
||
|
||
//if (BaseClass.NewSignatureAuth)
|
||
//{
|
||
// long s1 = 0;
|
||
// int j = 6712;
|
||
// while (s1 < 10000000)
|
||
// {
|
||
// string st = s1.ToString();
|
||
// if (s1 == 0)
|
||
// st = s;
|
||
// for (int i = 0; i < st.Length; i++)
|
||
// {
|
||
// j = j * (55 + i * 6) + i;
|
||
// if (j > 100000)
|
||
// j = j % 3267;
|
||
// int ai = (int)char.Parse(st.Substring(i, 1));
|
||
// if (ai < 128)
|
||
// {
|
||
// s1 += ai * (i + 3) * j;
|
||
// }
|
||
// }
|
||
// }
|
||
// return s1.ToString(); //返回签名的MD5结果
|
||
//}
|
||
//else
|
||
//{
|
||
// long s1 = 0;
|
||
// int j = 7684;
|
||
// while (s1 < 10000000)
|
||
// {
|
||
// string st = s1.ToString();
|
||
// if (s1 == 0)
|
||
// st = s;
|
||
// for (int i = 0; i < st.Length; i++)
|
||
// {
|
||
// j = j * (55 + i * 6) + i;
|
||
// if (j > 100000)
|
||
// j = j % 2367;
|
||
// int ai = (int)char.Parse(st.Substring(i, 1));
|
||
// if (ai < 128)
|
||
// {
|
||
// s1 += ai * (i + 3) * j;
|
||
// }
|
||
// }
|
||
// }
|
||
// return s1.ToString(); //返回签名的MD5结果
|
||
//}
|
||
//long s1 = 0;
|
||
//int j = 7684;
|
||
//while (s1 < 10000000)
|
||
//{
|
||
// string st = s1.ToString();
|
||
// if (s1 == 0)
|
||
// st = s;
|
||
// for (int i = 0; i < st.Length; i++)
|
||
// {
|
||
// j = j * (55 + i * 6) + i;
|
||
// if (j > 100000)
|
||
// j = j % 2367;
|
||
// int ai = (int)char.Parse(st.Substring(i, 1));
|
||
// if (ai < 128)
|
||
// {
|
||
// s1 += ai * (i + 3) * j;
|
||
// }
|
||
// }
|
||
//}
|
||
//return s1.ToString(); //返回签名的MD5结果
|
||
}
|
||
public string Get(string key)
|
||
{
|
||
if (string.IsNullOrEmpty(key))
|
||
return "";
|
||
byte[] inArray = Convert.FromBase64String(key.Replace("/", "="));
|
||
string html = Encoding.UTF8.GetString(inArray);
|
||
|
||
html = html.Replace("C", "1");
|
||
html = html.Replace("Q", "6");
|
||
html = html.Replace("I", "2");
|
||
html = html.Replace("L", "0");
|
||
html = html.Replace("Z", "9");
|
||
html = html.Replace("O", "5");
|
||
html = html.Replace("P", "8");
|
||
html = html.Replace("D", "7");
|
||
html = html.Replace("R", "b");
|
||
html = html.Replace("S", "c");
|
||
html = html.Replace("J", "a");
|
||
return html;
|
||
}
|
||
/// <summary>
|
||
/// MD5加密
|
||
/// </summary>
|
||
/// <param name="instring"></param>
|
||
/// <returns></returns>
|
||
public static string GetMd5(string instring)
|
||
{
|
||
byte[] result = Encoding.Default.GetBytes(instring.Trim());
|
||
MD5 md5 = new MD5CryptoServiceProvider();
|
||
byte[] output = md5.ComputeHash(result);
|
||
return BitConverter.ToString(output).Replace("-", "");
|
||
}
|
||
/// <summary>
|
||
/// 获取验证码
|
||
/// </summary>
|
||
/// <param name="mobile"></param>
|
||
/// <param name="success"></param>
|
||
/// <returns></returns>
|
||
public static string SendCode(string mobile, out bool success)
|
||
{
|
||
string url = BaseClass.BuildObjString("sms_gate");
|
||
string data = "mobile=" + mobile + "&" + GetSignature();
|
||
string html = GetHtml.PostUtf8(url, data);
|
||
success = false;
|
||
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
|
||
{
|
||
return "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
|
||
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
|
||
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
|
||
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
|
||
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
|
||
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
|
||
}
|
||
if (!html.Contains("\"code\":200"))
|
||
{
|
||
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
|
||
if (string.IsNullOrEmpty(errMsg))
|
||
errMsg = html;
|
||
return errMsg;
|
||
}
|
||
success = true;
|
||
return "";
|
||
}
|
||
|
||
|
||
public static string JsCode = @"var auth = {
|
||
getPublicKey: function() {
|
||
var _this = this;
|
||
Helper.get(""earth/api/queryPasswordEncrypt"", {}).then(function(d) {
|
||
if (d.success) {
|
||
_this.passwordEncrypt = d.result.passwordEncrypt;
|
||
_this.publicKey = d.result.publicKey;
|
||
_this.authCode();
|
||
}
|
||
});
|
||
},
|
||
authCode: function() {
|
||
var _this = this;
|
||
Helper.post(""earth/api/merchant/getCaptchaCode"", {
|
||
sceneId: 15
|
||
}).then(function(t) {
|
||
if (t.success) {
|
||
$img = document.querySelector('#tuxing').nextElementSibling;
|
||
$img.setAttribute('src', t.result.picture);
|
||
_this.captChaCodeUrl = t.result.picture;
|
||
_this.token = t.result.sign;
|
||
_this.__callback && _this.__callback.apply(_this);
|
||
}
|
||
})
|
||
},
|
||
setStartTime: function(e) {
|
||
var t = (new Date).getTime();
|
||
if (e == 'usernameId') {
|
||
this.mobileInputEditStartTime = t;
|
||
} else if (e == 'passwordId') {
|
||
this.passwordInputEditStartTime = t;
|
||
} else if (e == 'authCode') {
|
||
this.captureInputEditStartTime = t;
|
||
}
|
||
},
|
||
setEndTime: function(e) {
|
||
var t = (new Date).getTime();
|
||
if (e == 'usernameId') {
|
||
this.mobileInputEditFinishTime = t;
|
||
} else if (e == 'passwordId') {
|
||
this.passwordInputEditFinishTime = t;
|
||
} else if (e == 'authCode') {
|
||
this.captureInputEditFinishTime = t;
|
||
}
|
||
},
|
||
setKeyboardEvent: function(e, t, n) {
|
||
for (var r = """", i = 0, a = 0, o = 0, s = """", l = 0; l < t.length; l++)
|
||
""9"" == t[l].keyCode ? i = 1 : ""17"" == t[l].keyCode || ""91"" == t[l].keyCode ? a = 1 : ""86"" == t[l].keyCode && (o = 1),
|
||
r += 0 == l ? t[l].time - e : t[l].time - t[l - 1].time,
|
||
l < t.length - 1 && (r += ""-"");
|
||
s += i + ""|"" + a + ""|"" + o + ""|"" + r;
|
||
this[n] = s;
|
||
},
|
||
getKeyCode: function(e, t) {
|
||
var n = this,
|
||
r = this.mobileInputKeyboardEventList,
|
||
i = this.passwordInputKeyboardEventList,
|
||
a = this.captureInputKeyboardEventList,
|
||
o = (new Date).getTime(),
|
||
s = {
|
||
time: o,
|
||
keyCode: t.keyCode
|
||
};
|
||
|
||
if (e == 'usernameId') {
|
||
r.push(s);
|
||
r = r.filter(function(e, t) {
|
||
return null != e.keyCode;
|
||
});
|
||
this.mobileInputKeyboardEventList = r;
|
||
this.setKeyboardEvent(this.mobileInputEditStartTime, r, 'mobileInputKeyboardEvent');
|
||
}
|
||
|
||
if (e == 'passwordId') {
|
||
i.push(s);
|
||
i = i.filter(function(e, t) {
|
||
return null != e.keyCode
|
||
});
|
||
this.passwordInputKeyboardEventList = i;
|
||
this.setKeyboardEvent(this.passwordInputEditStartTime, i, 'passwordInputKeyboardEvent');
|
||
}
|
||
|
||
if (e == 'authCode') {
|
||
a.push(s);
|
||
a = a.filter(function(e, t) {
|
||
return null != e.keyCode
|
||
});
|
||
this.captureInputKeyboardEventList = a;
|
||
this.setKeyboardEvent(this.captureInputEditStartTime, i, 'captureInputKeyboardEvent');
|
||
}
|
||
},
|
||
UIEvents: function() {
|
||
var _this = this;
|
||
|
||
// 模拟键盘输入
|
||
var username = new Promise(function(resolve, reject) {
|
||
var keys = _this.options.username.split('');
|
||
var quque = function() {
|
||
if (!keys.length) {
|
||
resolve();
|
||
return;
|
||
}
|
||
|
||
var key = keys[0].charCodeAt(0),
|
||
event = {keyCode: key};
|
||
|
||
setTimeout(function() {
|
||
_this.setEndTime('usernameId');
|
||
_this.getKeyCode('usernameId', event);
|
||
keys.shift();
|
||
quque();
|
||
}, 10);
|
||
};
|
||
|
||
_this.setStartTime('usernameId');
|
||
quque();
|
||
});
|
||
|
||
var password = new Promise(function(resolve, reject) {
|
||
var keys = _this.options.password.split('');
|
||
var quque = function() {
|
||
if (!keys.length) {
|
||
resolve();
|
||
return;
|
||
}
|
||
|
||
var key = keys[0].charCodeAt(0),
|
||
event = {keyCode: key};
|
||
|
||
setTimeout(function() {
|
||
_this.setEndTime('passwordId');
|
||
_this.getKeyCode('passwordId', event);
|
||
keys.shift();
|
||
quque();
|
||
}, 10);
|
||
};
|
||
|
||
_this.setStartTime('passwordId');
|
||
quque();
|
||
});
|
||
|
||
var authCode = new Promise(function(resolve, reject) {
|
||
var keys = _this.options.verifyCode.split('');
|
||
var quque = function() {
|
||
if (!keys.length) {
|
||
resolve();
|
||
return;
|
||
}
|
||
|
||
var key = keys[0].charCodeAt(0),
|
||
event = {keyCode: key};
|
||
|
||
setTimeout(function() {
|
||
_this.setEndTime('authCode');
|
||
_this.getKeyCode('authCode', event);
|
||
keys.shift();
|
||
quque();
|
||
}, 10);
|
||
};
|
||
|
||
_this.setStartTime('authCode');
|
||
quque();
|
||
});
|
||
|
||
Promise.all([username, password, authCode]).then(function(values) {
|
||
_this.login();
|
||
});
|
||
},
|
||
|
||
login: function() {
|
||
var _this = this,
|
||
params = {}
|
||
$btn = document.querySelector('#loginBtnId')
|
||
offset = $btn.getBoundingClientRect(),
|
||
btnPoint = parseInt(offset.x + (offset.width / 2)) + ',' + parseInt(offset.y + (offset.height / 2));
|
||
|
||
params = {
|
||
username: this.options.username,
|
||
password: this.options.password,
|
||
verifyCode: this.options.verifyCode,
|
||
verificationCode: """",
|
||
sign: this.token,
|
||
touchevent: {
|
||
mobileInputEditStartTime: this.mobileInputEditStartTime,
|
||
mobileInputEditFinishTime: this.mobileInputEditFinishTime,
|
||
mobileInputKeyboardEvent: this.mobileInputKeyboardEvent,
|
||
passwordInputEditStartTime: this.passwordInputEditStartTime,
|
||
passwordInputEditFinishTime: this.passwordInputEditFinishTime,
|
||
passwordInputKeyboardEvent: this.passwordInputKeyboardEvent,
|
||
captureInputEditStartTime: this.captureInputEditStartTime,
|
||
captureInputEditFinishTime: this.captureInputEditFinishTime,
|
||
captureInputKeyboardEvent: this.captureInputKeyboardEvent,
|
||
loginButtonTouchPoint: btnPoint,
|
||
loginButtonClickTime: (new Date).getTime()
|
||
},
|
||
fingerprint: {
|
||
innerHeight: window.innerHeight,
|
||
innerWidth: window.innerWidth,
|
||
devicePixelRatio: window.devicePixelRatio,
|
||
availHeight: screen.availHeight,
|
||
availWidth: screen.availWidth,
|
||
height: screen.height,
|
||
width: screen.width,
|
||
colorDepth: screen.colorDepth,
|
||
locationHref: location.href,
|
||
navigator: {
|
||
appCodeName: navigator.appCodeName,
|
||
appName: navigator.appName,
|
||
hardwareConcurrency: navigator.hardwareConcurrency,
|
||
language: navigator.language,
|
||
cookieEnabled: navigator.cookieEnabled,
|
||
platform: navigator.platform,
|
||
doNotTrack: navigator.doNotTrack,
|
||
ua: navigator.ua,
|
||
vendor: navigator.vendor,
|
||
product: navigator.product,
|
||
productSub: navigator.productSub
|
||
},
|
||
referer: document.referrer,
|
||
timezoneOffset: (new Date).getTimezoneOffset()
|
||
}
|
||
}
|
||
|
||
if (this.passwordEncrypt) {
|
||
var p = new JSEncrypt;
|
||
p.setPublicKey(this.publicKey);
|
||
params.password = p.encrypt(params.password);
|
||
params.passwordEncrypt = true;
|
||
}
|
||
|
||
Helper.post(""nomallid/auth"", params).then(function(e) {
|
||
if (e.error_msg) {
|
||
console.log(e);
|
||
//alert('login error');
|
||
return;
|
||
}
|
||
|
||
localStorage.setItem(""PASSID"", e.pass_id);
|
||
Helper.saveToSessionStorage(""old_easy_psd"", { old_easy_psd: params.password});
|
||
_this.handerAfterAjax(e.userInfo, params.username);
|
||
}, function() {
|
||
//alert('login Error');
|
||
});
|
||
},
|
||
handerAfterAjax: function(e, n) {
|
||
Helper.saveToLocalStorage(""old_username"", {
|
||
username: n
|
||
});
|
||
window.mall_id = e.mallId;
|
||
Pdd.saveToLocalStorage(""username"", n);
|
||
Helper.queryUserinfo(function(e) {
|
||
window.g_mall_id = e.mallId;
|
||
e.error_msg || Helper.saveToLocalStorage(""userinfo"", e);
|
||
window.location.href = location.origin + location.pathname + '#/index?pre=log_page';
|
||
});
|
||
},
|
||
|
||
send(options) {
|
||
this.options = Object.assign({}, options);
|
||
this.UIEvents();
|
||
},
|
||
|
||
/**/
|
||
init: function(callback) {
|
||
this.passwordEncrypt = null;
|
||
this.publicKey = null;
|
||
this.captChaCodeUrl = null;
|
||
this.token = null;
|
||
|
||
this.mobileInputEditStartTime = """";
|
||
this.mobileInputEditFinishTime = """";
|
||
this.mobileInputKeyboardEvent = """";
|
||
this.mobileInputKeyboardEventList = [];
|
||
this.passwordInputEditStartTime = """";
|
||
this.passwordInputEditFinishTime = """";
|
||
this.passwordInputKeyboardEvent = """";
|
||
this.passwordInputKeyboardEventList = [];
|
||
this.captureInputEditStartTime = """";
|
||
this.captureInputEditFinishTime = """";
|
||
this.captureInputKeyboardEvent = """";
|
||
this.captureInputKeyboardEventList = [];
|
||
this.loginButtonTouchPoint = """";
|
||
this.loginButtonClickTime = """";
|
||
this.__callback = callback || null;
|
||
|
||
this.getPublicKey();
|
||
}
|
||
};auth.init();";
|
||
|
||
}
|
||
}
|