This commit is contained in:
Caiyanpeng committed 2021-04-19 14:11:53 +08:00
1 parent f4cbad819b
commit 0346b650aa
64 files changed
+12634 -12935

No files matched your search

+136 -37
View File
@@ -1,6 +1,7 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.Apis.Models;
using Assets.Scripts.UI.Control;
using Assets.Scripts.UI.Prefab.Login;
using DG.Tweening;
using Newtonsoft.Json;
@@ -11,6 +12,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Timers;
using UnityEngine;
using UnityEngine.Events;
@@ -75,7 +77,7 @@ public class LoginController : MonoBehaviour
private ScrollRect scrollPanel;
private ScrollRect scrollSign;
private ScrollRect scrollAvatar;
private Transform imagexf;
private Transform imagexf,imagedf;
//注册主页面
private UserResultModel userResult;
/*微信相关*/
@@ -99,14 +101,13 @@ public class LoginController : MonoBehaviour
// Start is called before the first frame update
void Start()
{
App.FromLogin = true;
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
var userInfosJson = PlayerPrefs.GetString("UserInfos");
userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
if (userInfos == null) userInfos = new List<QUserInfo>();
userInfos = UIManager.Instance.userInfos;
//userInfos.RemoveAt(0);
//PlayerPrefs.SetString("UserInfos", "");
//transform.Find("RawImage").DOMove(new Vector3(0.5f,0.5f,0),1);
//if (loginForm.Length == 2 && loginForm[0] != null && loginForm[1] != null)
//{
// foreach (var ipt in loginForm)
@@ -120,17 +121,17 @@ public class LoginController : MonoBehaviour
// }
// //loginForm[0].
//}
if (loading != null)
{
loading.texture.wrapMode = TextureWrapMode.Repeat;
//loading.texture.wrapMode = TextureWrapMode.Mirror;
}
if (loginScrollView != null)
{
scrollPanel = loginScrollView.GetComponent<ScrollRect>();
mainContent = loginScrollView.transform.Find("Viewport").Find("Content");
quickContainer = mainContent.Find("FormContainer-Quick");
loginContainer = mainContent.Find("FormContainer-Login").Find("FormContainer");
quickContainer = mainContent.Find("Empty").Find("FormContainer-Quick");
loginContainer = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer");
signContainer = mainContent.Find("FormContainer-Sign");
}
if (signScrollView != null)
@@ -214,7 +215,7 @@ public class LoginController : MonoBehaviour
foreach (var user in userInfos)
{
var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
info.GetComponent<QuickLoginUser>().Initial(user);
info.GetComponent<QuickLoginUser>().Initial(user,transform);
info.parent = content;
info.localScale = new Vector3(1, 1, 1);
}
@@ -255,9 +256,10 @@ public class LoginController : MonoBehaviour
wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
wxBrowser.Url = $"https://open.weixin.qq.com/connect/qrconnect?appid={App.WxAppId}&redirect_uri=https%3A%2F%2Fwx.powerfun.com.cn%2FNoAuth%2Fv1%2FWxWebLogin&response_type=code&scope=snsapi_login&state={wxState}#wechat_redirect";
//AdjustWxQrCode();
var wx1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
var wx1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
wx1.gameObject.SetActive(true);
Debug.Log(178 + "已经开启" + wx1.gameObject.activeSelf);
//wx1.GetComponent<CanvasGroup>().DOFade(1, 0.8f).onComplete = () => { wxLock = false; };
wx1.DOLocalMoveY(0, 0.3f).onComplete = () => { wxLock = false; };
});
var login = loginContainer.Find("login").GetComponent<Button>();
@@ -282,14 +284,14 @@ public class LoginController : MonoBehaviour
exit.onClick.AddListener(() => Application.Quit());
}
wxLogin1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
wxLogin1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
if (wxLogin1 != null)
{
wxLogin1.Find("Image").GetComponent<Button>().onClick.AddListener(() =>
{
wxLock = true;
wxBrowser.Url = "chrome://version/";
wxLogin1.DOMoveY(-573, 0.8f).onComplete = () =>
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
{
wxLock = false;
wxLogin1.gameObject.SetActive(false);
@@ -361,6 +363,7 @@ public class LoginController : MonoBehaviour
});
}
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
imagedf = transform.Find("Panel").Find("LoginContainer").Find("Imagedf");
toolContainer = transform.Find("Panel").Find("ToolContainer");
if (toolContainer != null)
{
@@ -368,6 +371,10 @@ public class LoginController : MonoBehaviour
{
UIManager.ShowSettingModal();
});
toolContainer.Find("Msg").GetComponent<Button>().onClick.AddListener(() =>
{
UIManager.ShowNewsModal();
});
}
}
private void AdjustWxQrCode()
@@ -581,7 +588,15 @@ public class LoginController : MonoBehaviour
}
if (r!=null && r.result)
{
RefreshWx3(r.data);
if (signType == 1)
{
RefreshWx3(r.data);
}
else
{
userResult = r.data;
}
LoadInfo();
StartScrollSign(1);
}
else
@@ -619,15 +634,68 @@ public class LoginController : MonoBehaviour
wxLogin3.Find("NickName").GetComponent<Text>().text = data.Nickname;
userResult = data;
}
private void goRegEnd()
async void goRegEnd()
{
if(!await UpdateInfo()) return;
if (pageNums == 5)
{
this.StartScrollPanel(4);
}
else
{
App.CurrentUser = userResult;
SceneManager.LoadScene("MainScene");
}
//throw new NotImplementedException();
}
void LoadInfo()
{
var _days = signForm.days.GetComponent<PFUIDropdown>();
var _months = signForm.months.GetComponent<PFUIDropdown>();
var _years = signForm.years.GetComponent<PFUIDropdown>();
var _genders = signForm.genders.GetComponent<PFUIDropdown>();
var _countrys = signForm.countrys.GetComponent<PFUIDropdown>();
var _units = signForm.units.GetComponent<PFUIDropdown>();
var _weight = signForm.weight.GetComponent<PFUIInputField>();
var _height = signForm.height.GetComponent<PFUIInputField>();
if (userResult.Birthday.HasValue)
{
_days.SelectValue(userResult.Birthday.Value.Day.ToString());
_months.SelectValue(userResult.Birthday.Value.Month.ToString());
_years.SelectValue(userResult.Birthday.Value.Year.ToString());
}
_genders.SelectIndex(userResult.Sex-1);
_countrys.SelectIndex(UIManager.Instance.loginRegOptions.GetCountryIndexByName(userResult.Country));
_units.SelectIndex(userResult.Unit);
_weight.Text = userResult.Weight.ToString();
_height.Text = userResult.Height.ToString();
}
async Task<bool> UpdateInfo()
{
if (userResult == null) return false;
var _days = signForm.days.GetComponent<PFUIDropdown>();
var _months = signForm.months.GetComponent<PFUIDropdown>();
var _years = signForm.years.GetComponent<PFUIDropdown>();
var _genders = signForm.genders.GetComponent<PFUIDropdown>();
var _countrys = signForm.countrys.GetComponent<PFUIDropdown>();
var _units = signForm.units.GetComponent<PFUIDropdown>();
var _weight = signForm.weight.GetComponent<PFUIInputField>();
var _height = signForm.height.GetComponent<PFUIInputField>();
if (signForm.years.value != -1 && signForm.months.value != -1 && signForm.days.value != -1)
{
userResult.Birthday = new DateTime(int.Parse(_years.SelectedItem), int.Parse(_months.SelectedItem), int.Parse(_days.SelectedItem));
}
userResult.Sex = _genders.SelectedIndex + 1;
userResult.Country = UIManager.Instance.loginRegOptions.GetCountryName(_countrys.SelectedIndex);
userResult.Unit = _units.SelectedIndex;
userResult.Weight = int.Parse(_weight.Text);
userResult.Height = int.Parse(_height.Text);
userResult.Nickname = userResult.Phone;
var r = await ConfigHelper.userApi.Update(userResult);
return r.result;
//userResult.Birthday.v
}
private void goLoginReturn2()
{
if (wxLogin2.gameObject.activeSelf) wxLogin2.gameObject.SetActive(false);
@@ -641,7 +709,11 @@ public class LoginController : MonoBehaviour
{
if (imagexf != null)
{
imagexf.DOLocalMove(new Vector3(0, -447, 0), 0.3f);
imagexf.DOLocalMoveY(-575, 0.3f);
}
if (imagedf != null)
{
imagedf.DOLocalMoveY(-128, 0.3f);
}
this.StartScrollPanel(0);
}
@@ -649,7 +721,11 @@ public class LoginController : MonoBehaviour
{
if (imagexf != null)
{
imagexf.DOLocalMove(new Vector3(0, -635, 0), 0.3f);
imagexf.DOLocalMoveY(-669, 0.3f);
}
if (imagedf != null)
{
imagedf.DOLocalMoveY(-34, 0.3f);
}
this.StartScrollPanel(1);
}
@@ -678,7 +754,6 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(2);
this.StartScrollSign(0);
}
}
void goMain(Transform gou)
{
@@ -686,26 +761,18 @@ public class LoginController : MonoBehaviour
if (data == null) return;
//ConfigHelper.CurrentUser = res.data;
if (gou != null && gou.gameObject.activeSelf)
{
SaveInfo(data);
//PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
}
else
{
var u = userInfos.Find(x => x.Id == data.Id);
if (u == null)
if (u != null)
{
userInfos.Add(new QUserInfo
{
Id = data.Id,
NickName = data.Nickname,
Avatar = data.WxHeadImg,
Cookie = data.cookie
});
userInfos.Remove(u);
}
else
{
u.Id = data.Id;
u.NickName = data.Nickname;
u.Avatar = data.WxHeadImg;
u.Cookie = data.cookie;
}
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
UIManager.Instance.userInfos = userInfos;
}
App.CurrentUser = data;
//App.CurrentUser = new UserModel
@@ -721,6 +788,32 @@ public class LoginController : MonoBehaviour
//};
SceneManager.LoadScene("MainScene");
}
public void SaveInfo(UserResultModel data)
{
var u = userInfos.Find(x => x.Id == data.Id);
if (u == null)
{
userInfos.Add(new QUserInfo
{
Id = data.Id,
NickName = data.Nickname,
Avatar = data.WxHeadImg,
Cookie = data.cookie
});
}
else
{
userInfos.Insert(0, new QUserInfo
{
Id = data.Id,
NickName = data.Nickname,
Avatar = data.WxHeadImg,
Cookie = data.cookie
});
userInfos.Remove(u);
}
UIManager.Instance.userInfos = userInfos;
}
async void Submit()
{
if (loginForm.email == null || loginForm.password == null)
@@ -744,7 +837,7 @@ public class LoginController : MonoBehaviour
}
else
{
Utils.showToast(gameObject, res.errMsg);
}
}
// Update is called once per frame
@@ -855,8 +948,14 @@ public class LoginController : MonoBehaviour
var country = wxInfoJson.Value<string>("country");
signForm.countrys.value = regOptions.GetCountryIndexByCode(country);
}
signForm.weight.text = "";
signForm.height.text = "";
//if (string.IsNullOrEmpty(signForm.weight.text))
//{
// signForm.weight.text = "";
//}
//if (!string.IsNullOrEmpty(signForm.height.text))
//{
// signForm.height.text = "";
//}
}
signScrollBar.DOLocalMoveX((index-1) *160, 0.2f);
}