| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/3/14 17:28:31
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Model.Bank;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class MotifyPhoneViewModel : IdentifyCodeTimerViewModel
- {
- private IBankService _bankService;
- private bool _isBusy;
- /// <summary>
- /// 是否忙,显示等待控件
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- public MotifyPhoneViewModel(SigningBank bankSign)
- {
- CurrentSigningBank = bankSign;
- MobilePhone = bankSign.BankMobile;
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- }
- private string _mobilePhone;
- /// <summary>
- /// 手机号码
- /// </summary>
- public string MobilePhone
- {
- get { return _mobilePhone; }
- set { Set(() => MobilePhone, ref _mobilePhone, value); }
- }
- private SigningBank _currentSigningBank;
- public SigningBank CurrentSigningBank
- {
- get { return _currentSigningBank; }
- set { _currentSigningBank = value; }
- }
- private Window _window;
- public RelayCommand<Window> OKCommand
- {
- get
- {
- return new RelayCommand<Window>((view) =>
- {
- if (CurrentSigningBank == null)
- {
- return;
- }
- IsBusy = true;
- if (Validate())
- {
- _window = view;
- CurrentSigningBank.MobilePhone = MobilePhone;
- CurrentSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
- CurrentSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
-
- _bankService.SignUpdate(CurrentSigningBank, SignUpdateCallback, ErrorCallback);
- }
- });
- }
- }
- private void SignUpdateCallback(int result)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (result == 0)
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChangeBankInfoSuccess_Wait, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- if (_window != null)
- {
- _window.Close();
- }
- }
- else
- {
- ErrorManager.ShowReturnError(result, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
- }
- }));
- }
- public void ErrorCallback(ErrorEntity error)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
- }));
- }
- /// <summary>
- /// 验证
- /// </summary>
- /// <returns>是否通过</returns>
- private bool Validate()
- {
- if (string.IsNullOrWhiteSpace(MobilePhone))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputMobilePhone, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (string.IsNullOrEmpty(CurrentSigningBank.IdentifyCode))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputIdentifyCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- //if (this.NewBankAccount.Trim() == this.BankAccount.Trim())
- //{
- // MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NewAndOldAccountSame, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- // return false;
- //}
- return true;
- }
- /// <summary>
- /// 获取手机验证码
- /// </summary>
- public RelayCommand IdentifyCodeCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- if (CurrentSigningBank == null)
- {
- return;
- }
- if (string.IsNullOrWhiteSpace(MobilePhone))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputMobilePhone, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return ;
- }
- var IndentityReq = new IdentifyCodeReq()
- {
- AccountCode = CurrentSigningBank.AccountCode,
- CusBankID = CurrentSigningBank.CusBankID + string.Empty,
- TradeType = BankTradeType.UpdateSign,
- Amount = 0,
- CustomerSignId = CurrentSigningBank.CustomerSignId,
- CustomerName = CurrentSigningBank.CustomerName,
- BankCode = CurrentSigningBank.BankId,
- AccountType = CurrentSigningBank.AccountType,
- BankAccountNo = CurrentSigningBank.BankAccount,
- CardNum = CurrentSigningBank.CredentialNumber,
- CardType = CurrentSigningBank.CredentialType,
- MobilePhone = MobilePhone,
- Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- };
- _bankService.BankGetIdentifyCode(IndentityReq, null, ErrorCallback);
- this.Start();
- }, (() => IsGetIdentifyCodeEnable()));
- }
- }
- private bool IsGetIdentifyCodeEnable()
- {
- if (string.IsNullOrWhiteSpace(MobilePhone))
- {
- return false;
- }
- if (!IsNumberString(MobilePhone))
- {
- return false;
- }
- if (MobilePhone.Length!=11)
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// /字符串是否只包括数字
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- private bool IsNumberString(string str)
- {
- char[] chArr = str.ToCharArray();
- foreach (var ch in chArr)
- {
- if (!char.IsDigit(ch))
- {
- return false;
- }
- }
- return true;
- }
-
- }
- }
|