苹果登录暂存

This commit is contained in:
Caiyanpeng committed 2021-12-21 09:58:07 +08:00
1 parent ebcc83ed6a
commit 05d2c74efa
18 files changed
+1651 -1197

No files matched your search

+10
View File
@@ -314,5 +314,15 @@ namespace Assets.Scripts.Apis
{
return await PostAsync<JsonResult<JObject>>("NoAuth/v1/ResetPassword", new {phone,captcha,newPwd });
}
public async Task<JsonResult<JObject>> OnAppleIdLoginCheck(string userId,string token)
{
return await PostAsync<JsonResult<JObject>>("NoAuth/v1/OnAppleIdLoginCheck", new { appleUserId = userId,token });
}
public async Task<JsonResult<object>> OnAppleIdLogin(string appleUserId, string token, string phone, string pwd, string Captcha)
{
return await PostAsync<JsonResult<object>>("NoAuth/v1/OnAppleIdLogin", new { appleUserId, token, phone, pwd, Captcha });
}
}
}
+1 -1
View File
@@ -191,7 +191,7 @@ public static class App
Host = "http://192.168.0.101:5085/";
UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
Debug.unityLogger.logEnabled = false;
//Debug.unityLogger.logEnabled = false;
#endif
var isRower = PlayerPrefs.GetString("IsRowerMode");
if (!string.IsNullOrEmpty(isRower))
+30 -2
View File
@@ -41,6 +41,20 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
DateTime.Now.ToString("HH:mm");
weChat = App.weChatController;
weChat.Init(App.WxAppId);
#if UNITY_IOS
UIManager.AddEvent(transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer-third/otherContainer/Apple").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
#if UNITY_EDITOR
GetComponent<LoginController>()
.OnAppleIdLoginCheck("000515.7d1f47f5171b4d66a4bb4a4e7e2c6899.0830", "eyJraWQiOiJZdXlYb1kiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLlpoaVhpbmdQYWkuUG93ZXJGdW4iLCJleHAiOjE2NDAwNDk3NzEsImlhdCI6MTYzOTk2MzM3MSwic3ViIjoiMDAwNTE1LjdkMWY0N2Y1MTcxYjRkNjZhNGJiNGE0ZTdlMmM2ODk5LjA4MzAiLCJjX2hhc2giOiJhekhJdTZNVE1OVGs4Q3RxNndIeHlRIiwiYXV0aF90aW1lIjoxNjM5OTYzMzcxLCJub25jZV9zdXBwb3J0ZWQiOnRydWV9.WM23STabsJqSV1FjPvYRXo3kOB2Cfo7HsPDUuJx8UlqTUthbif1uvhEFpFMF8G5B5_yl3kkmaDtv0nQA25DkDiYowfPVV8gkLx2IMMOm6rVqV5E7kA6xNa64pwgIHDnTSjnn862_DEb4QVkAfi-rXsbkZ1q-EpH5MG-5GLR3Ktq_1n59kQcJrvuvUEpbv8IbSzRLh4VVZLY5rmaoddZ2kg5hw234cwGCmiMxHi55tVHAiGnqgq74IY7HXz3udwRGufaFXpkYbdBuL5-wqAp1SQlQhwpTzhZ5JKr2y4ukejYPFZzLfnkUX0xhLmH8uooKb-TjOa5qaFKGXT0hXh4NHw");
#else
App.weChatController.SignWithApple();
#endif
});
#else
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer-third/otherContainer/Apple").gameObject.SetActive(false);
#endif
//App.weChatController.Init(App.WxAppId);
//var s = App.weChatController.isApplicationAvilible("com.gugoumainapp","powerfun").ToString();
//Utils.showToast(null, SystemInfo.batteryLevel.ToString());
@@ -68,9 +82,11 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
}
App.WorkoutsUrl = r.data.Value<JObject>("Apk").Value<string>("Url");
#elif UNITY_IOS
var sw = r.data.Value<string>("ThirdPartSwitch");
//var sw = r.data.Value<string>("ThirdPartSwitch");
//transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
// .gameObject.SetActive(sw.Equals("on") && App.weChatController.IsWeChatAppInstalled());
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
.gameObject.SetActive(sw.Equals("on") && App.weChatController.IsWeChatAppInstalled());
.gameObject.SetActive(true);
var info = r.data.Value<JObject>("UnityIos");
if (Utils.isUpdate(App.AppVersion, info.Value<string>("Version")))
{
@@ -140,4 +156,16 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
Utils.showToast(null, res.Replace("false;", ""));
}
}
public void OnAppleResp(string res)
{
#if UNITY_IOS
var sp = res.Replace("true;", "").Split(',');
if (sp.Length == 2)
{
GetComponent<LoginController>().OnAppleIdLoginCheck(sp[0],sp[1]);
}
//Utils.showToast(null, "苹果返回"+res);
#endif
}
}
+21 -4
View File
@@ -30,6 +30,12 @@ public class WeChatController
[DllImport("__Internal")]
private static extern void ShareImgToWX(int scene, byte[] msgByteArrayData, int arrayLength);
[DllImport("__Internal")]
private static extern void ShareUrlToWX(int scene, string url, string title, string description);
[DllImport("__Internal")]
private static extern void authorizationAppleID();
#endif
#endregion
/// <summary>
@@ -70,10 +76,17 @@ public class WeChatController
#endif
}
public void SignWithApple()
{
#if UNITY_IOS
authorizationAppleID();
#endif
}
/// <summary>
/// 判断是否是否安装了微信
/// </summary>
/// <returns></returns>
/// 判断是否是否安装了微信
/// </summary>
/// <returns></returns>
public bool IsWeChatAppInstalled()
{
#if UNITY_ANDROID
@@ -109,7 +122,11 @@ public class WeChatController
/// <param name="description">描述</param>
public void ShareWebpageToWX(int scene, string url, string title, string description,byte[] image)
{
mainActivityClass.CallStatic("ShareWebpageToWX", scene, url, title, description,image);
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareWebpageToWX", scene, url, title, description, image);
#else
ShareUrlToWX(scene, url, title, description);
#endif
}
/// <summary>
+65 -14
View File
@@ -150,7 +150,7 @@ public class LoginController : BaseScene
var content = signScrollView.transform.Find("Viewport").Find("Content");
signPage1 = content.Find("FirstPage");
UIManager.AddEvent(signPage1.Find("next").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegNext());
EventTriggerType.PointerClick, (b) => goRegNext(signType));
UIManager.AddEvent(signPage1.Find("BtnModiPass").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goResetPassword());
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
@@ -507,6 +507,38 @@ public class LoginController : BaseScene
transform.Find("Panel").Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#endif
}
private string appleUserId = "";
private string appleToken = "";
private int signType { get; set; }
public async void OnAppleIdLoginCheck(string userId,string token)
{
appleUserId = userId;
appleToken = token;
signType = 2;
var res = await ConfigHelper.userApi.OnAppleIdLoginCheck(userId, token);
if (res.result) //判断是否成功登录
{
var data = res.data;
if (res.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;
MobileAni(true);
StartScrollPanel(2);
}
}
else
{
}
}
public void Test(string key)
{
@@ -514,8 +546,6 @@ public class LoginController : BaseScene
}
async void Init()
{
Debug.Log(535);
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
userInfos = UIManager.Instance.userInfos;
App.DefaultRotateTexture = Utils.ReadTextureFromPlayerPrefs("rotateImage");
@@ -697,6 +727,7 @@ public class LoginController : BaseScene
JObject data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
signType = 1;
wxInfoJson = data;
wxLogin2.gameObject.SetActive(true);
Utils.DisplayImage(wxLogin2.Find("Avatar").GetComponent<RawImage>(),
@@ -759,7 +790,7 @@ public class LoginController : BaseScene
//Timer t = new Ti
if (r.result)
{
if (pageNums == 5)
if (signType == 1 || signType == 2)
{
if (r.data.Value<bool>("isExist"))
{
@@ -820,7 +851,7 @@ public class LoginController : BaseScene
signForm.cpassword.text = "";
StartScrollSign(0);
}
//0-普通 1-微信
//0-普通 1-微信 2-苹果
private async void goRegNext(int signType = 0)
{
var Email = signForm.email;
@@ -851,6 +882,10 @@ public class LoginController : BaseScene
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
}
else if (signType == 2)
{
r = await ConfigHelper.userApi.OnAppleIdLogin(appleUserId,appleToken,Email.text,Password.text,Captcha.text);
}
if (r != null && r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
@@ -870,21 +905,33 @@ public class LoginController : BaseScene
{
var Email = signForm.email;
var Captcha = signForm.captcha;
var r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
JsonResult<object> r = null;
if (signType == 2)
{
//苹果登录
r = await ConfigHelper.userApi.OnAppleIdLogin(appleUserId, appleToken, Email.text, "", Captcha.text);
}
else
{
r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
Captcha.text,
"",
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u, 1);
MobileAni(true);
StartScrollPanel(4);
}
else
if (r != null)
{
Utils.showToast(gameObject, r.errMsg);
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u, 1);
MobileAni(true);
StartScrollPanel(4);
}
else
{
Utils.showToast(gameObject, r.errMsg);
}
}
}
/// <summary>
@@ -1201,6 +1248,10 @@ public class LoginController : BaseScene
if (type == 0)
{
pageNums = 4;
if (signType != 2)
{
signType = 0;
}
signContainer.Find("signText").GetComponent<Text>().text = App.GetLocalString("SIGN UP");
wxLogin2.gameObject.SetActive(false);
signPage1.Find("next").gameObject.SetActive(true);
+6 -2
View File
@@ -22,6 +22,7 @@ public class MainController : BaseScene
protected override void Awake()
{
base.Awake();
Debug.Log("执行25");
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
Version.text = "V"+App.AppVersion;
DeviceCache.Init(PFConstants.DeviceCacheFolder);
@@ -176,9 +177,12 @@ public class MainController : BaseScene
void FinishMessageLeft()
{
msgIndex = 0;
foreach (var item in msgs)
if (msgs != null)
{
item.DOFade(0, 0.3f);
foreach (var item in msgs)
{
item.DOFade(0, 0.3f);
}
}
}
@@ -381,15 +381,15 @@ public class DeviceView : MonoBehaviour
break;
case SensorType.SpeedCadence:
case SensorType.Cadence:
return "Cadence Sensor";
return App.GetLocalString("Cadence Sensor");
case SensorType.HeartRate:
return "Heart Rate Monitor";
return App.GetLocalString("Heart Rate Monitor");
case SensorType.Power:
return "Power Meter";
return App.GetLocalString("Power Meter");
case SensorType.Speed:
return "Speed Meter";
return App.GetLocalString("Speed Meter");
case SensorType.Trainer:
return "Smart Trainer";
return App.GetLocalString("Smart Trainer");
case SensorType.Rower:
return "Rower Machine";
case SensorType.VirtualPower:
@@ -181,7 +181,15 @@ public class RouteItem : MonoBehaviour
UIManager.AddEvent(left.Find("Main/ShareContainer/Wx").gameObject, EventTriggerType.PointerClick, b =>
{
Debug.Log(App.CurrentUser.WebHost);
App.weChatController.ShareWebpageToWX(0, "http://192.168.0.101:3081/RoutesRecords/" + result.RankingId, result.RouteName, "By " + App.CurrentUser.Nickname, null);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, "http://192.168.0.101:3081/RoutesRecords/" + result.RankingId, result.RouteName, "By " + App.CurrentUser.Nickname, null);
}
else
{
Utils.showToast(null, "未安装微信");
}
});
UIManager.AddEvent(btnDelete.gameObject, EventTriggerType.PointerClick, (b) => Detail());
#else