店铺登录逻辑处理
This commit is contained in:
1 parent
311971ca21
commit
89eb9ce9d4
8 files changed
+139
-75
No files matched your search
@@ -10,6 +10,7 @@ using Microsoft.Win32;
|
||||
using NaiBa.CefHelper;
|
||||
using NaiBa.CefHelper.Handler;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -42,6 +43,7 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms
|
||||
private string shopMainUrl = "https://seller.kuajingmaihuo.com";
|
||||
private ChromiumWebBrowser cefWebBrowser = null;
|
||||
private DouShopLoginInfo shop = null;
|
||||
private List<ShopCompany> lstShopCompany = new List<ShopCompany>();
|
||||
private string currentUrl = "";
|
||||
|
||||
public ShopLoginForm(DouShopLoginInfo shopInfo)
|
||||
@@ -109,17 +111,10 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms
|
||||
if (openType!= EnumOpenType.login)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrEmpty(shop.ShopAccountId) || string.IsNullOrEmpty(shop.ShopAccount))
|
||||
if (!lstShopCompany.Any(c => c.LoginName == shop.LoginName))
|
||||
continue;
|
||||
|
||||
//var jsStr = "function getShopName() { return document.getElementsByClassName('headerShopName')[0].innerHTML; } getShopName();";
|
||||
//var response = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr);
|
||||
//response.Wait(5000);
|
||||
//var res = response.Result.Result?.ToString();
|
||||
//if (res != null && res.Contains("</span>"))
|
||||
{
|
||||
//shop.ShopAccount = res.Substring(res.IndexOf("</span>") + 7);
|
||||
//shop.ShopAccount = BaseRegex.FliterHtmlTag(shop.ShopAccount);
|
||||
string cookies = "";
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.RequestContext.GetCookieManager(null));
|
||||
if (cookieList != null && cookieList.Count > 0)
|
||||
@@ -133,37 +128,69 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms
|
||||
}
|
||||
cookies = cookies.Trim().TrimEnd(';');
|
||||
}
|
||||
shop.Cookies = cookies;
|
||||
//if (isMultiLogin)
|
||||
//{
|
||||
// shop.DictMultiCookies[MultiLoginCookieName] = cookies;
|
||||
//}
|
||||
|
||||
if (!string.IsNullOrEmpty(shop.Cookies)
|
||||
&& !string.IsNullOrEmpty(shop.ShopAccount)
|
||||
&& !string.IsNullOrEmpty(shop.ShopAccountId)
|
||||
//&& !string.IsNullOrEmpty(shop.Mobile)
|
||||
//&& !string.IsNullOrEmpty(shop.ShopToken)
|
||||
)
|
||||
if (!string.IsNullOrEmpty(cookies)
|
||||
&& lstShopCompany.Any(c => c.LoginName == shop.LoginName))
|
||||
{
|
||||
shop.LoginStatus = "登录成功";
|
||||
var lstShopCompanyCopy = lstShopCompany.ToList();
|
||||
//var shopCompany = lstShopCompany.FirstOrDefault(c=>c.LoginName==shop.LoginName);
|
||||
//if (shopCompany == null)
|
||||
// shopCompany = new ShopCompany();
|
||||
|
||||
shop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
|
||||
var shopInfo = GlobalConfig.DouShopLoginList.FirstOrDefault(v => v.ShopAccountId == shop.ShopAccountId);
|
||||
if (shopInfo != null)
|
||||
//shop.LoginStatus = "登录成功";
|
||||
//shop.ShopAccountId = shopCompany.AccountId;
|
||||
//shop.ShopAccount = shopCompany.AccountName;
|
||||
//shop.Cookies = cookies;
|
||||
|
||||
//shop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
|
||||
//var shopInfo = GlobalConfig.DouShopLoginList.FirstOrDefault(v => v.ShopAccountId == shop.ShopAccountId);
|
||||
//if (shopInfo != null)
|
||||
//{
|
||||
// shopInfo.Cookies = shop.Cookies;
|
||||
// shopInfo.Password = shop.Password;
|
||||
// shopInfo.ShopAccountId = shop.ShopAccountId;
|
||||
// shopInfo.ShopAccount = shop.ShopAccount;
|
||||
//}
|
||||
//else
|
||||
// GlobalConfig.DouShopLoginList.Add(shop);
|
||||
//StartUp.SaveLocalShopLoginInfo();
|
||||
////ShopListForm.AddServerDouShop(shop); // 店铺写入到服务端
|
||||
//ShopListForm.UpdateServerShopCookies(shop, shop.Cookies); // cookie写入到服务端
|
||||
|
||||
foreach (ShopCompany sc in lstShopCompanyCopy)
|
||||
{
|
||||
//shopInfo.ShopToken = shop.ShopToken;
|
||||
//shopInfo.Mobile = shop.Mobile;
|
||||
shopInfo.Cookies = shop.Cookies;
|
||||
shopInfo.Password = shop.Password;
|
||||
shopInfo.ShopAccountId = shop.ShopAccountId;
|
||||
shopInfo.ShopAccount = shop.ShopAccount;
|
||||
DouShopLoginInfo newShop = new DouShopLoginInfo()
|
||||
{
|
||||
LoginName = shop.LoginName,
|
||||
Password = shop.Password,
|
||||
Group = shop.Group,
|
||||
LoginStatus = "登录成功",
|
||||
ShopAccount = sc.AccountName,
|
||||
ShopAccountId = sc.AccountId,
|
||||
Cookies = cookies,
|
||||
};
|
||||
|
||||
var oldShop = GlobalConfig.DouShopLoginList.FirstOrDefault(l =>
|
||||
l.LoginName == newShop.LoginName && l.ShopAccountId == newShop.ShopAccountId);
|
||||
if (oldShop == null)
|
||||
{
|
||||
GlobalConfig.DouShopLoginList.Add(newShop);
|
||||
ShopListForm.AddServerDouShop(newShop); // 店铺写入到服务端
|
||||
}
|
||||
else
|
||||
{
|
||||
oldShop.LoginName = shop.LoginName;
|
||||
oldShop.Password = shop.Password;
|
||||
oldShop.Group = shop.Group;
|
||||
oldShop.LoginStatus = "登录成功";
|
||||
oldShop.ShopAccount = sc.AccountName;
|
||||
oldShop.ShopAccountId = sc.AccountId;
|
||||
oldShop.Cookies = cookies;
|
||||
}
|
||||
StartUp.SaveLocalShopLoginInfo();
|
||||
ShopListForm.UpdateServerShopCookies(newShop, newShop.Cookies);
|
||||
}
|
||||
else
|
||||
GlobalConfig.DouShopLoginList.Add(shop);
|
||||
StartUp.SaveDouShopLoginInfo();
|
||||
//ShopListForm.AddServerDouShop(shop); // 店铺写入到服务端
|
||||
ShopListForm.AddServerShopCookies(shop, shop.Cookies); // cookie写入到服务端
|
||||
|
||||
OnSaveComplete(shop);
|
||||
if (this.Created && this.chkCloseAfterLogin.Checked)
|
||||
{
|
||||
@@ -359,10 +386,24 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms
|
||||
var maskMobile = BaseRegex.GetStringJson(ref data, "maskOwnerMobile");
|
||||
if (shop.LoginName.EndsWith(maskMobile))
|
||||
{
|
||||
shop.ShopAccountId = BaseRegex.GetStringJson(ref data, "mallId");
|
||||
shop.ShopAccount = BaseRegex.GetStringJson(ref data, "mallName");
|
||||
//shop.ShopToken = BaseRegex.GetStringJson(ref data, "token");
|
||||
//shop.Mobile = BaseRegex.GetStringJson(ref data, "mobile");
|
||||
lstShopCompany.Clear();
|
||||
var jObj = JObject.Parse(data);
|
||||
var jArr = jObj["result"]?["companyList"]?[0]?["malInfoList"] as JArray;
|
||||
if (jArr == null)
|
||||
jArr = new JArray();
|
||||
foreach (var productObj in jArr)
|
||||
{
|
||||
var prod = JsonHelper.SerializeObject(productObj);
|
||||
ShopCompany sc = new ShopCompany()
|
||||
{
|
||||
AccountId = BaseRegex.GetStringJson(ref prod, "mallId"),
|
||||
AccountName = BaseRegex.GetStringJson(ref prod, "mallName"),
|
||||
LoginName = shop.LoginName,
|
||||
UserName = BaseClass.UserName,
|
||||
LoginStatus = "登录成功",
|
||||
};
|
||||
this.lstShopCompany.Add(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -716,7 +757,7 @@ function fireKeyEvent(el, evtType, keyCode) {
|
||||
if (shop != null)
|
||||
{
|
||||
shop.DictMultiCookies.Remove(cmbMultiCookieName.Text);
|
||||
StartUp.SaveDouShopLoginInfo();
|
||||
StartUp.SaveLocalShopLoginInfo();
|
||||
|
||||
InitMultiLoginCookies();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user