123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using ShadowKit;
- using Engine.Http;
- using System.Text.RegularExpressions;
- public class PopLoginBase : PopBase
- {
- protected override void Start() {
- }
- public override void Show(object data)
- {
- base.Show(data);
- AccountText = GameDataSetting.Instance.DefaultUserAccount;
- PasswordText = GameDataSetting.Instance.DefaultUserPassword;
- }
- protected virtual string AccountText { get; set; }
- protected virtual string PasswordText { get; set; }
- protected virtual string CodeText { get; set; }
- protected void LoginClick()
- {
- if(isLoading)
- {
- return;
- }
- isLoading = true;
- GameDataSetting.Instance.DefaultUserAccount = AccountText;
- GameDataSetting.Instance.DefaultUserPassword = PasswordText;
- string pattern = @"\s";
- AccountText = Regex.Replace(AccountText, pattern, "");
- PasswordText = Regex.Replace(PasswordText, pattern, "");
- HttpStaticMessage.SendHttpLogin(AccountText, PasswordText, CodeText, HttpDataBackOK);
- HideKeyBoard();
- }
- protected void VisitorLogin()
- {
- Hide();
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.DeviceLogin, null));
-
- }
- protected virtual void Update()
- {
- if(Input.GetKeyDown(KeyCode.A))
- {
- SendVistorLogin();
- }
- }
- protected void SendVistorLogin()
- {
-
- if (isLoading)
- {
- return;
- }
- isLoading = true;
- if (CheckNameSafe())
- {
- HttpStaticMessage.HttpVisitorLogin(AccountText, HttpDataBackOK);
- HideKeyBoard();
- }
- else
- {
- isLoading = false;
- }
- }
- protected void RegisterClick()
- {
- }
- protected virtual void HideKeyBoard()
- {
- }
- private bool CheckNameSafe()
- {
- if (AccountText.Length == 0)
- {
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_MSG_POP, "游客ID不能为空");
- return false;
- }
- if (AccountText.Length > GameEnum.VISTOR_NAME_MAX_LENGHT)
- {
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_MSG_POP, "游客ID字符超过" + GameEnum.VISTOR_NAME_MAX_LENGHT);
- return false;
- }
- return true;
- }
- private bool isLoading;
- private void HttpDataBackOK(HttpResponse backHttpResponse)
- {
- isLoading = false;
-
- if (backHttpResponse.isSuccess)
- {
- this.Hide();
- if (backHttpResponse.Code == MsgConst.HTTP_MSG_AUTO_LOGIN)
- {
- GamePlayerData.Instance.user_name = AccountText;
- }
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.ServerList, null));
- }
- }
-
- }
|