lixiaojun
2025-02-17 92437d69a32c79cebf0708c147c0f3c0a24f2e23
WinFrmUI/HStation.WinFrmUI.Auth.Core/06-user-info/UserInfoPage.cs
@@ -25,19 +25,32 @@
            InitializeComponent();
            this.PageTitle.Caption = "个人中心";
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.Load += UserInfoPage_Load;
        }
        private const string _smsTemplate = "hzkw_sms_template";//手机号登录模板
        private const string _vxTemplate = "hzkw_vx_template";//微信登录模板
        private const string _vxTemplate = "hzkw_wx_template";//微信登录模板
        private const string _software = "HStation_XHS_DESKTOP";//软件编码
        //修改密码
        private void BtnEditPwd_Click(object sender, EventArgs e)
        {
            var dlg = new UpdatePwdDlg();
            dlg.SetBindingData(GlobalParas._GlobalParas.LoginID);
            dlg.ShowDialog();
        }
        //初始化
        private void UserInfoPage_Load(object? sender, EventArgs e)
        {
            this.txtEditUserName.Text = GlobalParas._GlobalParas.LoginName;
            this.txtEditAdminType.Text = GlobalParas._GlobalParas.AdminType;
            this.txtAccountName.Text = GlobalParas._GlobalParas.AccountName;
            this.textAccountType.Text = GlobalParas._GlobalParas.LoginType;
        }
        //手机绑定
        private async void BtnPhoneBinding_Click(object sender, EventArgs e)
        private async void PhoneBinding()
        {
            if (!IsValidMobileNumber(this.txtMobileNumber.Text.Trim()))
            {
@@ -60,13 +73,15 @@
                    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 vmo = new Yw.Vmo.AddUserLoginAccountVmo
                {
                    CorpID = GlobalParas._GlobalParas.CorpID,
                    UserID = GlobalParas._GlobalParas.UserID,
                    LoginTypeID = loginType.ID,
                    Identifier = _smsTemplate,
                    Credential = this.txtMobileNumber.Text.Trim(),
                    IfVerified = true
                };
                var bol = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.Insert(vmo);
                if (bol > 0)
                {
@@ -86,14 +101,12 @@
        }
        //微信绑定
        private void btnWechatBinding_Click(object sender, EventArgs e)
        private void WechatBinding()
        {
            var dlg = new WechatBindingDlg();
            dlg.SetBindingData();
            dlg.CodeReloadData += async (code) =>
            {
                // Yw.Dto.InternalException 报错类
                var loginType = await BLLFactory<Yw.BLL.UserLoginType>.Instance.GetByIdentifier(LoginType.Wechat);
                if (loginType != null)
                {
@@ -132,5 +145,33 @@
            };
            dlg.ShowDialog();
        }
        //重置密码
        private async void BtnResetPwd_Click(object sender, EventArgs e)
        {
            if (XtraMessageBox.Show($"确认重置密码吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                return;
            if (!await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.ResetSystemLoginPwd(GlobalParas._GlobalParas.LoginID))
            {
                MessageBoxHelper.ShowError("重置失败!");
                return;
            }
            MessageBoxHelper.ShowSuccess("重置成功!");
        }
        private void buttonEditBinding_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var tag_obj = e.Button.Tag;
            switch (tag_obj)
            {
                case "Phone":
                    PhoneBinding();
                    break;
                case "Wechat":
                    WechatBinding();
                    break;
            }
        }
    }
}