using LYFZ.Software.MainBusiness.MicroApplet; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace LYFZ.Software.MainBusiness.SelfService { public class frmPersonalCenter:LYFZ.Software.SelfService.frmPersonalCenter { frmAdminPage frmPage = null; string gotoUrl = "http://dear.lyfz.net/#/customer/center/product"; public frmPersonalCenter() { this.UcNavigationTool.LabTitle = "自助中心"; if (Environment.OSVersion.Version.Major >= 6) { try { frmPage = new frmAdminPage(); this.btnRefresh.Click += btnRefresh_Click; this.frmPage.ContextMenuHandler.RunContextMenu += ContextMenuHandler_RunContextMenu; this.Shown += FrmPersonalCenter_Shown; this.frmPage.LoadHandler.OnLoadEnd += LoadHandler_OnLoadEnd; this.frmPage.LoadHandler.OnLoadStart += LoadHandler_OnLoadStart; } catch { MessageBoxCustom.Show("您的系统不支持自助功能,请使用 Win7 或以上系统。"); this.Enabled = false; } } else { MessageBoxCustom.Show("您的系统不支持自助序功能,请使用 Win7 或以上系统。"); this.Enabled = false; } } private void FrmPersonalCenter_Shown(object sender, EventArgs e) { this.LoadMicroAppletPage(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.SDomainName); } void LoadMicroAppletPage(string dongleDomainName) { if (String.IsNullOrEmpty(tokenPermission)) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在验证授权..."); //_ContentType: "form-data" if (!String.IsNullOrEmpty(dongleDomainName)) { string timestamp = SDateTime.Now.ToJavaScriptTimeStamp().ToString(); //=md5(domain+timestamp+lyfz2398865) string sign = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(String.Format("{0}{1}lyfz2398865", dongleDomainName, timestamp)).ToLower(); string postData = String.Format("domain={0}&sign={1}×tamp={2}", dongleDomainName, sign, timestamp); string jsonData =LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestPOST("http://mcrm.lyfz.net/api.php/plugin/CustomerAuthByDomain", postData, Encoding.UTF8); if (jsonData.IndexOf("{") == 0) { dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonData); if (Convert.ToInt32(postReturnObj["code"]) == 0) { tokenPermission = postReturnObj["data"]["token"]; } else { MessageBoxCustom.Show(String.Format("自助中心登录时失败:{0}", postReturnObj["info"])); } } else { MessageBoxCustom.Show(String.Format("自助中心登录时出错:{0}", jsonData)); } } if (String.IsNullOrEmpty(tokenPermission)) { MessageBoxCustom.Show(String.Format("您还没有开通“利亚方舟自助服务中心,请联系客服开通”"), backgroundWorker: backgroundWorker); } } catch (Exception ex) { MessageBoxCustom.Show(String.Format("获取授权时错误:{0}", ex.Message), backgroundWorker: backgroundWorker); } }); } if (this.plExMainContainer.Controls.Count <= 0) { this.frmPage.SetEmbeddedWindows(this.plExMainContainer); } if (!String.IsNullOrEmpty(tokenPermission)) { SetSetLocalStorage(); frmPage.LoadUrl(gotoUrl); // frmPage.LoadUrl("http://lyfz.app.local/H5UI/index.html"); // frmPage.LoadUrl("http://res.app.local/H5UI/index.html"); // frmPage.LoadUrl("https://html5test.com/"); // frmPage.LoadUrl("http://www.baidu.com/"); //frmPage.LoadUrl("http://benediktmeurer.de/ARES-6/"); //frmPage.LoadUrl("https://react-md.mlaursen.com/components/pickers/date"); } else { frmPage.LoadUrl("http://www.lyfz.net/index/miniapp_desc"); } } private void ContextMenuHandler_RunContextMenu(object sender, Chromium.Event.CfxRunContextMenuEventArgs e) { e.SetReturnValue(true); } void btnRefresh_Click(object sender, EventArgs e) { myRefresh(this.cbDelHuanChun.Checked); } void myRefresh(bool isDelHuanChun) { if (isDelHuanChun) { this.frmPage.Browser.ReloadIgnoreCache(); } else { this.frmPage.Browser.Reload(); } } private void LoadHandler_OnLoadStart(object sender, Chromium.Event.CfxOnLoadStartEventArgs e) { SetSetLocalStorage(); } private void LoadHandler_OnLoadEnd(object sender, Chromium.Event.CfxOnLoadEndEventArgs e) { SetSetLocalStorage(); } static string tokenPermission = "";//"120f472f357ab3e1a9188e47710b56fb"; void SetSetLocalStorage() { this.frmPage.Chromium.ExecuteJavascript(String.Format("localStorage.setItem('login-token','{0}');", tokenPermission)); } } }