一、新用户注册界面设计:

        注册时采用手机号注册,客户端发送新号注册申请由后台做审核,后台审核通过后向注册的手机号发送注册成功的消息。注册过的手机号不能再二次注册。

期货量化交易客户端开源教学第九节——新用户注册-LMLPHP

界面验证代码

private
    { Private declarations }
    FVerf: AnsiString; {验证码}
    FPhone: AnsiString; {手机号}
    FTime: Integer;
  public
    { Public declarations }
    FClientSocket: TClientSocket;
    procedure logindone(returnstr: AnsiString); {处理返回结构 }
  end;

var
  FrmReg: TFrmReg;

implementation
uses
  uGlobalvariable, uTCP_Client_Service, md5jm, uLogin;

{$R *.fmx}

procedure TFrmReg.BtnOKClick(Sender: TObject);
var
  Vtcp_client_service : TTCP_client_service;
  data_stream : TMemoryStream;
  data_strstrea : TStringStream;
  restr,cmd_id: AnsiString;
begin
  if (Length(Trim(EdtPhone.Text)) <> 11) or (Trim(EdtPhone.Text) <> FPhone) then
  begin
    MessageBox(0,'手机号输入错误','提示',MB_OK + MB_ICONHAND);
    Exit;
  end;
  if Trim(EdtPWD.Text) <> Trim(EdtPWD2.Text) then
  begin
    MessageBox(0,'两次输入的密码不一致','提示',MB_OK + MB_ICONHAND);
    Exit;
  end;
  if Length(Trim(EdtName.Text)) > 4 then
  begin
    MessageBox(0,'姓名长度错误','提示',MB_OK + MB_ICONHAND);
    Exit;
  end;
  if (Trim(EdtPhone.Text) = '') or (Trim(EdtPWD.Text) = '') or
     (Trim(EdtPWD2.Text) = '') or (Trim(EdtVerf.Text) = '') or
     (Trim(EdtName.Text) = '') then
  begin
    MessageBox(0,'内容不能为空','提示',MB_OK + MB_ICONHAND);
    Exit;
  end;

  if Trim(EdtVerf.Text) <> FVerf then
  begin
    MessageBox(0,'验证码错误','提示',MB_OK + MB_ICONHAND);
    Exit;
  end;

二、新用户注册接口协议

1、 向服务端发送指令
  {用户注册(301)(实盘数据库注册指令)

发送:300;用户bh;md5密码;姓名;
      返回:300;0;错误提示;
            300;1;注册成功!;}
  {用户注册(301)(模拟数据库注册指令)
      发送:301;用户bh;md5密码;姓名;
      返回:301;0;错误提示;
            301;1;}

2、注册发送协议:

BtnOK.Enabled := False;
  data_stream := TMemoryStream.Create;
  data_strstrea := TStringStream.Create;
  try
    cmd_id := '300';
    restr := cmd_id + ';' + Trim(EdtPhone.Text) + ';' +
             md5jm.MD5Print( MD5String( Trim(EdtPWD.Text) ) ) + ';' +
             Trim(EdtName.Text) + ';';
    data_strstrea.WriteString(restr);
    data_stream.LoadFromStream( data_strstrea );

    {创建TCP连接对象}
    Vtcp_client_service := TTCP_client_service.Create(nil);
    Vtcp_client_service.Socket_LB := 2;
    Vtcp_client_service.FCMD_data.LoadFromStream( data_stream ); {业务指令数据流}
    {开始连接}
    if not Vtcp_client_service.open_service then
    begin
      {启动TCP连接失败}
      ShowMessage('连接失败!');
    end;
07-15 05:27