using DevExpress.XtraEditors; using DevExpress.XtraReports.Templates; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Yw; using Yw.Auth; using Yw.Dto; using Yw.WinFrmUI; using Timer = System.Windows.Forms.Timer; namespace HStation.WinFrmUI { public partial class UserInfoPage : DocumentPage { public UserInfoPage() { InitializeComponent(); this.PageTitle.Caption = "个人中心"; this.PageTitle.SvgImageSize = new Size(24, 24); } private const string _smsTemplate = "hzkw_sms_template";//手机号登录模板 private const string _vxTemplate = "hzkw_wx_template";//微信登录模板 private const string _software = "HStation_XHS_DESKTOP";//软件编码 //修改密码 private void BtnEditPwd_Click(object sender, EventArgs e) { } //手机绑定 private async void BtnPhoneBinding_Click(object sender, EventArgs e) { if (!IsValidMobileNumber(this.txtMobileNumber.Text.Trim())) { TipFormHelper.ShowError("手机号有误!"); return; } var loginType = await BLLFactory.Instance.GetByIdentifier(LoginType.SMS); if (loginType != null) { var isExist = await BLLFactory.Instance.IsExist(new IsExistUserLoginAccountInput { CorpID = GlobalParas._GlobalParas.CorpID, LoginTypeID = loginType.ID, Identifier = _smsTemplate, Credential = this.txtMobileNumber.Text.Trim() }); if (isExist) { TipFormHelper.ShowError("账户已存在!"); return; } var vmo = new Yw.Vmo.AddUserLoginAccountVmo(); vmo.CorpID = GlobalParas._GlobalParas.CorpID; vmo.UserID = GlobalParas._GlobalParas.UserID; vmo.LoginTypeID = loginType.ID; vmo.Identifier = _smsTemplate; vmo.Credential = this.txtMobileNumber.Text.Trim(); vmo.IfVerified = true; var bol = await BLLFactory.Instance.Insert(vmo); if (bol > 0) { TipFormHelper.ShowSucceed("绑定成功!"); } else { TipFormHelper.ShowError("绑定失败!"); } } } private bool IsValidMobileNumber(string mobile) { var regex = new System.Text.RegularExpressions.Regex(@"^1\d{10}$"); return regex.IsMatch(mobile); } //微信绑定 private void btnWechatBinding_Click(object sender, EventArgs e) { var dlg = new WechatBindingDlg(); dlg.SetBindingData(); dlg.CodeReloadData += async (code) => { var loginType = await BLLFactory.Instance.GetByIdentifier(LoginType.Wechat); if (loginType != null) { var tokenInfo = await BLLFactory.Instance.GetTokenInfo(code, _vxTemplate); if (tokenInfo == null) return; var isExist = await BLLFactory.Instance.IsExist(new IsExistUserLoginAccountInput { CorpID = GlobalParas._GlobalParas.CorpID, LoginTypeID = loginType.ID, Identifier = _vxTemplate, Credential = tokenInfo.openid }); if (isExist) { TipFormHelper.ShowError("账户已存在!"); return; } var vmo = new Yw.Vmo.AddUserLoginAccountVmo(); vmo.CorpID = GlobalParas._GlobalParas.CorpID; vmo.UserID = GlobalParas._GlobalParas.UserID; vmo.LoginTypeID = loginType.ID; vmo.Identifier = _vxTemplate; vmo.Credential = tokenInfo.openid; vmo.IfVerified = true; var bol = await BLLFactory.Instance.Insert(vmo); if (bol > 0) { TipFormHelper.ShowSucceed("绑定成功!"); } else { TipFormHelper.ShowError("绑定失败!"); } } }; dlg.ShowDialog(); } } }