google 登录暂存

This commit is contained in:
Caiyanpeng committed 2022-01-19 13:42:12 +08:00
1 parent 45b3ee5bbc
commit 58a8233697
21 files changed
+355 -102

No files matched your search

+2 -27
View File
@@ -95,8 +95,7 @@ namespace Assets.Scripts.Apis.Models
public bool IsFav { get; set; }
}
public class MapRouteAreaDetail
public class MapRouteAreaDetail : MapRouteAreaItem
{
/// <summary>
///
@@ -114,35 +113,11 @@ namespace Assets.Scripts.Apis.Models
///
/// </summary>
public int RideCount { get; set; }
/// <summary>
/// 环徐州
/// </summary>
public string Name { get; set; }
/// <summary>
///
/// </summary>
public string Description { get; set; }
/// <summary>
///
/// </summary>
public string BannerImage { get; set; }
/// <summary>
///
/// </summary>
public string CoverImage { get; set; }
/// <summary>
///
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
///
/// </summary>
public DateTime UpdateTime { get; set; }
public bool IsFav { get; set; }
public string CreateUserHead { get; set; }
public string CreateUserName { get; set; }
public List<MapRouteAreaDetailUser> UserList { get; set; }
}
public class MapRouteAreaDetailUser
{
public int Id { get; set; }
@@ -77,5 +77,6 @@ namespace Assets.Scripts.Apis.Models
//第三方userid
public string AppleUserId { get; set; }
public string FacebookUserId { get; set; }
public string GoogleUserId { get; set; }
}
}
+12 -1
View File
@@ -310,6 +310,18 @@ namespace Assets.Scripts.Apis
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnFacebookLogin", new { faceBookUserId, token, phone, pwd, Captcha });
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnGoogleIdLoginCheck(string googleUserId, string token)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnGoogleIdLoginCheck", new { googleUserId, token });
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnGoogleIdLogin(string googleUserId, string token, string phone, string pwd, string Captcha)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnGoogleIdLogin", new { googleUserId, token, phone, pwd, Captcha });
return GetDataAfterSetCookie(r);
}
private JsonResult<object> GetDataAfterSetCookie(JsonResult<object> r)
{
if (r.result)
@@ -329,6 +341,5 @@ namespace Assets.Scripts.Apis
return r;
}
}
}
+17 -11
View File
@@ -42,11 +42,11 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
DateTime.Now.ToString("HH:mm");
weChat = App.weChatController;
weChat.Init(App.WxAppId);
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Google")
.gameObject.SetActive(Utils.CheckGooglePlayServices());
#if UNITY_IOS
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Wechat")
.gameObject.SetActive(App.weChatController.IsWeChatAppInstalled());
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Google")
.gameObject.SetActive(false);
#endif
#if UNITY_IOS
UIManager.AddEvent(transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Apple").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
@@ -68,7 +68,11 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
});
UIManager.AddEvent(transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Google").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
#if UNITY_EDITOR
OnMobileGoogleLoginResp("true;105370187704207825625|eyJhbGciOiJSUzI1NiIsImtpZCI6ImNhMDA2MjBjNWFhN2JlOGNkMDNhNmYzYzY4NDA2ZTQ1ZTkzYjNjYWIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI0OTI0NDAyMDA3NjYtMGZxc2toYjZlYnRhZzFobHFwbzdmbzkzY3VhYXJzbDYuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI0OTI0NDAyMDA3NjYtZjE0Yjl0OXRtcmF1bGg2N2dxb2JhYTlpc3EzN2cwbmMuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDUzNzAxODc3MDQyMDc4MjU2MjUiLCJlbWFpbCI6ImNhaXlhbnBlbmcwNjE5QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoi6JSh5Lil6bmPIiwicGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FBVFhBSnhjeWVkS05iZkcwZ3lIbkRhMXpWemVZRGVpdXI3OHUtNWZfbnVWPXM5Ni1jIiwiZ2l2ZW5fbmFtZSI6IuS4pem5jyIsImZhbWlseV9uYW1lIjoi6JShIiwibG9jYWxlIjoiemgtQ04iLCJpYXQiOjE2NDI0ODUxNzEsImV4cCI6MTY0MjQ4ODc3MX0.ZX-9jmB9GaWQEgcv8jbd4Ojy33DiVvl7m_PQZudJEQaLC1S5C6QJOaZRJEHNQ44mWmfSPlHPEhgsEoP-Qn7lKx7r609OuzMYGUE266bdbYer2KzztMtZIUKrI3i0UGLlybQm8YVGJh4vTvtaLZ3Fi2h2aKlDjx4MvFDaQKIwTDsOXzkCmhidYJ4KOhCToZsGIWmR8OhtwhL531p1oV3kOW28nXSbPhl0GalEbu-n970TtpxxQRvJeK61V8R3F29U71pn9PI863xQQ4itWsvQaFNz03pC8RRBGEKN8dvrmTqbKMuoo44fV4pLiY66EqUUoKYST7dOl15zUGfC-ckq5g");
#else
Utils.CallAndroidMethod("signInWithGoogle");
#endif
});
//App.weChatController.Init(App.WxAppId);
//var s = App.weChatController.isApplicationAvilible("com.gugoumainapp","powerfun").ToString();
@@ -203,16 +207,18 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
public void OnMobileGoogleLoginResp(string res)
{
Utils.showToast(null, res);
Debug.Log(res);
//if (res.Contains("true;"))
//{
// GetComponent<LoginController>().goWxLoginWithCode(res.Replace("true;", ""), "mobile");
//}
//else
//{
// Utils.showToast(null, res.Replace("false;", ""));
//}
#if UNITY_ANDROID
var sp = res.Replace("true;", "").Split('|');
if (sp.Length == 2)
{
GetComponent<LoginController>().OnGoogleIdLoginCheck(sp[0], sp[1]);
}
else
{
Utils.showToast(null, res.Replace("false;",""));
}
#endif
}
public void OnAppleResp(string res)
+40 -1
View File
@@ -501,6 +501,37 @@ public class LoginController : BaseScene
transform.Find("Panel").Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#endif
}
private string ggUserId = "";
private string ggToken = "";
public async void OnGoogleIdLoginCheck(string userId, string token)
{
ggUserId = userId;
ggToken = token;
signType = 4;
var res = await ConfigHelper.userApi.OnGoogleIdLoginCheck(userId, token);
if (res.result) //判断是否成功登录
{
var data = JObject.FromObject(res.data);
if (data.ContainsKey("success") && data.Value<string>("success") == "False")
{
goSign();
}
else
{
RefreshWx3(data.ToObject<UserResultModel>(), 1);
wxLogin3.gameObject.SetActive(true);
signContainer.gameObject.SetActive(false);
pageNums = 3;
StartScrollPanel(2);
}
}
else
{
Utils.showToast(null, res.errMsg);
}
}
private string fbUserId = "";
private string fbToken = "";
@@ -909,10 +940,14 @@ public class LoginController : BaseScene
{
r = await ConfigHelper.userApi.OnAppleIdLogin(appleUserId, appleToken, Email.text, Password.text, Captcha.text);
}
else
else if (signType == 3)
{
r = await ConfigHelper.userApi.OnFacebookLogin(fbUserId, fbToken, Email.text, Password.text, Captcha.text);
}
else if (signType == 4)
{
r = await ConfigHelper.userApi.OnGoogleIdLogin(ggUserId, ggToken, Email.text, Password.text, Captcha.text);
}
if (r != null && r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
@@ -942,6 +977,10 @@ public class LoginController : BaseScene
{
r = await ConfigHelper.userApi.OnFacebookLogin(fbUserId, fbToken, Email.text, "", Captcha.text);
}
else if (signType == 4)
{
r = await ConfigHelper.userApi.OnGoogleIdLogin(ggUserId, ggToken, Email.text, "", Captcha.text);
}
else
{
r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
+1 -1
View File
@@ -358,7 +358,7 @@ public class MainController : BaseScene
}
if (App.MainSceneParam["Name"] == "NewRouteDetail" && App.currentArea != null)
{
UIManager.ShowNewRouteDetailPanel(App.currentArea);
UIManager.ShowNewRouteDetailPanel(App.currentArea.Id);
}
if (App.MainSceneParam["Name"] == "UserInfoPanel")
{
@@ -27,7 +27,7 @@ public class NewRouteItemController : MonoBehaviour
GetComponent<Button>().onClick.RemoveAllListeners();
GetComponent<Button>().onClick.AddListener(() =>
{
UIManager.ShowNewRouteDetailPanel(area);
UIManager.ShowNewRouteDetailPanel(area.Id);
});
StartCoroutine(displayImage(area, caches));
}
@@ -292,6 +292,10 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
string.IsNullOrEmpty(currentUser.AppleUserId)
? Resources.Load<Sprite>("Images/link-apple")
: Resources.Load<Sprite>("Images/Login_Apple");
linkContainer.Find("Gg").GetComponent<Image>().sprite =
string.IsNullOrEmpty(currentUser.GoogleUserId)
? Resources.Load<Sprite>("Images/link-google")
: Resources.Load<Sprite>("Images/Login_Google");
}
// Start is called before the first frame update
protected override void Start()
@@ -116,6 +116,7 @@ public class HomeController : PFUIPanel
// }
//},
};
}
private void GoRide(BaseEventData e)
{
@@ -299,7 +300,7 @@ public class HomeController : PFUIPanel
if (maxt <= 0)
{
GetMaxRanking();
maxt += 60f;
maxt += 60f * 5;
}
if (maxdataTime > 0)
{
@@ -372,5 +373,6 @@ public class HomeController : PFUIPanel
base.Show();
transform.MyDOFade();
GetSummary();
//transform.Find("Panel (1)").GetComponent<test>().startPage();
}
}
@@ -130,14 +130,13 @@ public class NewRouteDetailController : PFUIPanel
// timer += 1f;
//}
}
MapRouteAreaItem area;
MapRouteAreaDetail area;
int pageIndex = 0, pageSize = 10;
bool isEnd = false, startMouse = false;
public async void Initial(MapRouteAreaItem area)
public async void Initial(int areaId)
{
isEnd = false;
pageIndex = 0;
this.area = area;
var left = transform.Find("Container/Left");
left.Find("Icon").GetComponent<RawImage>().texture = null;
scroll.content.DestroyChildren();
@@ -151,46 +150,9 @@ public class NewRouteDetailController : PFUIPanel
.text = string.Empty;
transform.Find("Container/Left/DescScroll/Viewport/Content/Desc").GetComponent<Text>()
.text = string.Empty;
if (area.CoverImage != null)
{
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.CoverImage, caches
, b =>
{
// if (b != null)
// {
// cacheByte.Add(area.CoverImage, b);
// }
// else if(cacheByte.ContainsKey(area.CoverImage))
// {
// b = cacheByte[area.CoverImage];
// }
//#if UNITY_EDITOR
// var _t = new Texture2D(4, 4, TextureFormat.DXT5, false);
//#else
//#if UNITY_IOS
// var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
// Debug.Log("使用了壓縮");
//#elif UNITY_ANDROID
// var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
// Debug.Log("使用了壓縮");
//#else //pc
// var _t = new Texture2D(4, 4, TextureFormat.DXT5,false);
//#endif
//#endif
// _t.LoadImage(b);
// //Graphics.CopyTexture(t, _t);
// //Debug.Log($"{t.width},{t.height}");
// left.Find("Thumbnail").GetComponent<RawImage>().texture =
// ScaleTextureCutOut(_t, 0, _t.height / 2, _t.width / 3, _t.height / 3);
});
//Utils.DisplayImageTempDict(left.Find("Thumbnail").GetComponent<RawImage>(), area.CoverImage, caches);
}
Debug.Log(153 + area.IsFav.ToString());
left.Find("Name").GetComponent<Text>().text = area.Name;
GetData();
GetData(areaId);
GetList();
}
@@ -243,11 +205,13 @@ public class NewRouteDetailController : PFUIPanel
GetList();
}
}
private async void GetData()
private async void GetData(int areaId)
{
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id);
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(areaId);
if (res.result)
{
this.area = res.data;
transform.Find("Container/Left/Name").GetComponent<Text>().text = res.data.Name;
transform.Find("Container/Left/RideContainer/Text").GetComponent<Text>()
.text = res.data.RideCount.ToString();
transform.Find("Container/Left/Infos/DistanceContainer/Text").GetComponent<Text>()
@@ -264,6 +228,41 @@ public class NewRouteDetailController : PFUIPanel
transform.Find("Container/Left/Fav").GetComponent<Image>().sprite = FavDict[res.data.IsFav];
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.Find("Container/Left/RideContainer").GetComponent<RectTransform>());
var userinfo = Resources.Load<GameObject>("UI/Prefab/NewRoute/UserInfo");
if (res.data.CoverImage != null)
{
Utils.DisplayImageTempDict(transform.Find("Container/Left/Icon").GetComponent<RawImage>(), area.CoverImage, caches
, b =>
{
// if (b != null)
// {
// cacheByte.Add(area.CoverImage, b);
// }
// else if(cacheByte.ContainsKey(area.CoverImage))
// {
// b = cacheByte[area.CoverImage];
// }
//#if UNITY_EDITOR
// var _t = new Texture2D(4, 4, TextureFormat.DXT5, false);
//#else
//#if UNITY_IOS
// var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
// Debug.Log("使用了壓縮");
//#elif UNITY_ANDROID
// var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
// Debug.Log("使用了壓縮");
//#else //pc
// var _t = new Texture2D(4, 4, TextureFormat.DXT5,false);
//#endif
//#endif
// _t.LoadImage(b);
// //Graphics.CopyTexture(t, _t);
// //Debug.Log($"{t.width},{t.height}");
// left.Find("Thumbnail").GetComponent<RawImage>().texture =
// ScaleTextureCutOut(_t, 0, _t.height / 2, _t.width / 3, _t.height / 3);
});
//Utils.DisplayImageTempDict(left.Find("Thumbnail").GetComponent<RawImage>(), area.CoverImage, caches);
}
#if !(UNITY_ANDROID || UNITY_IOS)
transform.Find("Container/Left/NOData").gameObject.SetActive(res.data.UserList.Count == 0);
transform.Find("Container/Left/Users").DestroyChildren();
+2 -2
View File
@@ -332,10 +332,10 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("NewRouteDetailPanel", ref this.mNewRouteDetailController);
}
}
public static void ShowNewRouteDetailPanel(MapRouteAreaItem area)
public static void ShowNewRouteDetailPanel(int areaId)
{
UIManager.Show(UIManager.Instance.NewRouteDetailPanel, UIManager.Instance.MainPanel);
UIManager.Instance.NewRouteDetailPanel.GetComponent<NewRouteDetailController>().Initial(area);
UIManager.Instance.NewRouteDetailPanel.GetComponent<NewRouteDetailController>().Initial(areaId);
}
#endregion
private CountDownAnimation mCountDownAnimation;
+14
View File
@@ -274,6 +274,20 @@ namespace Assets.Scripts
#endif
}
public static bool CheckGooglePlayServices()
{
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
return activity.Call<bool>("CheckGooglePlayServices");
#elif UNITY_EDITOR
return true;
#else
return false;
#endif
}
public static void showLoadingExtension(this GameObject game)
{
game.SetActive(true);