protected override void InitComponents() { var inputUsername = FindWidget <InputField>("inputUsername"); if (!string.IsNullOrEmpty(CachedUsername)) { inputUsername.text = CachedUsername; } var inputPassword = FindWidget <InputField>("inputPassword"); var btnLogin = FindWidget <Button>("btnLogin"); btnLogin.onClick.AddListener(() => { if (string.IsNullOrEmpty(inputUsername.text)) { return; } if (string.IsNullOrEmpty(inputPassword.text)) { return; } btnLogin.enabled = false; var username = inputUsername.text; var password = inputPassword.text; UStaticWebRequests.DoLogin(username, Utils.MD5Hash(password), (jres) => { btnLogin.enabled = true; CachedUsername = jres["username"].ToString(); token = jres["token"].ToString(); UnloadThis(); LoadAnother <UIMain>(); } , (err) => { btnLogin.enabled = true; UIAlert.Show("登录失败," + err); } , (error) => { btnLogin.enabled = true; UIAlert.Show("登录失败,网络错误:" + error); }); }); var btnRegister = FindWidget <Button>("btnRegister"); btnRegister.onClick.AddListener(() => { UnloadThis(); LoadAnother <UIRegister>(); }); }
protected override void InitComponents() { var inputUsername = FindWidget <InputField>("inputUsername"); if (!string.IsNullOrEmpty(CachedUsername)) { inputUsername.text = CachedUsername; } var inputPassword = FindWidget <InputField>("inputPassword"); var btnLogin = FindWidget <Button>("btnLogin"); btnLogin.onClick.AddListener(() => { if (string.IsNullOrEmpty(inputUsername.text)) { return; } if (string.IsNullOrEmpty(inputPassword.text)) { return; } btnLogin.enabled = false; var username = inputUsername.text; var password = inputPassword.text; UStaticWebRequests.DoLogin(username, Utils.MD5Hash(password), (jres) => { btnLogin.enabled = true; CachedUsername = jres["username"].ToString(); token = jres["token"].ToString(); UStaticWebRequests.DoSelectAvatar(UILogin.CachedUsername, UILogin.token , (jsel) => { var data = new UMRemoteAvatarData(); data.OnFormat(jsel); UMRemoteDataManager.Instance.OnAdd(data); UnloadThis(); LoadAnother <UIMain>(); }, (err) => { if (err == "3") { UnloadThis(); LoadAnother <UMUICreateAvatar>(); } else { UIAlert.Show("选择角色失败," + err); } }, (err) => { UIAlert.Show("选择角色失败," + err); }); } , (err) => { btnLogin.enabled = true; UIAlert.Show("登录失败," + err); } , (error) => { btnLogin.enabled = true; UIAlert.Show("登录失败,网络错误:" + error); }); }); var btnRegister = FindWidget <Button>("btnRegister"); btnRegister.onClick.AddListener(() => { UnloadThis(); LoadAnother <UIRegister>(); }); }
protected override void InitComponents() { var inputUsername = FindWidget <InputField>("inputUsername"); if (!string.IsNullOrEmpty(CachedUsername)) { inputUsername.text = CachedUsername; } var inputPassword = FindWidget <InputField>("inputPassword"); var btnLogin = FindWidget <Button>("btnLogin"); btnLogin.onClick.AddListener(() => { if (string.IsNullOrEmpty(inputUsername.text)) { return; } if (string.IsNullOrEmpty(inputPassword.text)) { return; } btnLogin.enabled = false; var username = inputUsername.text; var password = inputPassword.text; UStaticWebRequests.DoLogin(username, Utils.MD5Hash(password), (jres) => { btnLogin.enabled = true; CachedUsername = username; token = jres["token"].ToString(); OnSelectAvatar(); } , (err) => { btnLogin.enabled = true; UIAlert.Show("登录失败," + err); } , (error) => { btnLogin.enabled = true; UIAlert.Show("登录失败,网络错误:" + error); }); }); var btnRegister = FindWidget <Button>("btnRegister"); btnRegister.onClick.AddListener(() => { OnUnloadThis(); LoadAnotherUI <UIRegister>(); }); if (!string.IsNullOrEmpty(token)) { inputPassword.text = "******"; btnLogin.enabled = false; UStaticWebRequests.OnWebRequest("Login/CheckToken", "username="******"&token=" + token, jobj => { OnSelectAvatar(); }, jfail => { btnLogin.enabled = true; inputPassword.text = ""; token = ""; }); } }