diff --git a/Assets/Plugins/SDK/NativeBridgeUtil.cs b/Assets/Plugins/SDK/NativeBridgeUtil.cs index 53e7989..f28b246 100644 --- a/Assets/Plugins/SDK/NativeBridgeUtil.cs +++ b/Assets/Plugins/SDK/NativeBridgeUtil.cs @@ -1,11 +1,7 @@ using UnityEngine; using System.Collections; using ETHotfix.com.commsdk.unity3d; -using System.Text.RegularExpressions; using System; -using System.Collections.Generic; -using ETModel; -using ETModel.com.commsdk.unity3d; diff --git a/Assets/Scripts/LoginAndPay/LoginView.cs b/Assets/Scripts/LoginAndPay/LoginView.cs index c40f642..7ac0249 100644 --- a/Assets/Scripts/LoginAndPay/LoginView.cs +++ b/Assets/Scripts/LoginAndPay/LoginView.cs @@ -34,7 +34,7 @@ public class LoginView : MonoBehaviour string cachedPhoneNumber = PlayerPrefs.GetString("CachedPhoneNumber", ""); string cachedWxUnionId = PlayerPrefs.GetString("CachedWxUnionId", ""); - if (!string.IsNullOrEmpty(cachedPhoneNumber) || !string.IsNullOrEmpty(cachedWxUnionId)) + if (!string.IsNullOrEmpty(cachedPhoneNumber) && !string.IsNullOrEmpty(cachedWxUnionId)) { HttpManager.Instance.phoneNum = cachedPhoneNumber; HttpManager.Instance.wxUnionID = cachedWxUnionId; @@ -128,22 +128,45 @@ public class LoginView : MonoBehaviour } } + async UniTask WxAndPhoneLoginTask() + { + string phonenum = PhoneNumberInputField.text; + WxAndPhoneLoginResponse wxAndPhoneLoginResponse = await HttpManager.Instance.RequestPost("wx-login", new WxAndPhoneLoginRequest() { uinid = HttpManager.Instance.wxUnionID, iphone_num = HttpManager.Instance.phoneNum }); + if (wxAndPhoneLoginResponse.code == 0) + { + SceneManager.LoadScene("LoadingScreen"); + } + else + { + PlayerPrefs.DeleteKey("CachedPhoneNumber"); + PlayerPrefs.DeleteKey("CachedWxUnionId"); + PlayerPrefs.Save(); + + HttpManager.Instance.wxUnionID = ""; + HttpManager.Instance.phoneNum = ""; + isWeChatAuthorized = false; + isPhoneAuthorized = false; + CheckAuthorized(); + } + } + private void CheckAuthorized() { if (isWeChatAuthorized && isPhoneAuthorized) { - SceneManager.LoadScene("LoadingScreen"); + //SceneManager.LoadScene("LoadingScreen"); + WxAndPhoneLoginTask().Forget(); } else if (isWeChatAuthorized && !isPhoneAuthorized) { - WxBindButton.gameObject.SetActive(true); - PhoneTrans.SetActive(false); + WxBindButton.gameObject.SetActive(false); + PhoneTrans.SetActive(true); loginBthTrans.SetActive(false); } else if (isPhoneAuthorized && !isWeChatAuthorized) { - WxBindButton.gameObject.SetActive(false); - PhoneTrans.SetActive(true); + WxBindButton.gameObject.SetActive(true); + PhoneTrans.SetActive(false); loginBthTrans.SetActive(false); } if (!isPhoneAuthorized && !isWeChatAuthorized) @@ -172,9 +195,9 @@ public class LoginView : MonoBehaviour NativeBridgeUtil.Instance.WeChatLogin(1); } - void ClickWxBindButton() - { - NativeBridgeUtil.Instance.WeChatLogin(1); + void ClickWxBindButton() + { + NativeBridgeUtil.Instance.WeChatLogin(1); } } diff --git a/Assets/Scripts/LoginAndPay/http/LoginRequest.cs b/Assets/Scripts/LoginAndPay/http/LoginRequest.cs index 5055713..660eb7a 100644 --- a/Assets/Scripts/LoginAndPay/http/LoginRequest.cs +++ b/Assets/Scripts/LoginAndPay/http/LoginRequest.cs @@ -65,3 +65,17 @@ public class PaymentStatusResponse : WWWResponse public string data; public string message; } + +[Serializable] +public class WxAndPhoneLoginRequest : WWWRequest +{ + public string uinid; + public string iphone_num; +} + +[Serializable] +public class WxAndPhoneLoginResponse : WWWResponse +{ + public int code; + public string message; +} \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 0bc3ea6..c0677f8 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -157,7 +157,7 @@ PlayerSettings: buildNumber: {} AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 16 - AndroidTargetSdkVersion: 0 + AndroidTargetSdkVersion: 28 AndroidPreferredInstallLocation: 1 aotOptions: stripEngineCode: 1 @@ -244,7 +244,7 @@ PlayerSettings: AndroidTargetArchitectures: 1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} - AndroidKeystoreName: G:/work/unity/unity2018/ZhenShiXunYouJi3/zsmxj.keystore + AndroidKeystoreName: H:/Work/unityWork/unity2018workGit/ZhenShiXunYouJi2/zsmxj.keystore AndroidKeyaliasName: zsmxj AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 0