using Assets.Scripts; using Assets.Scripts.Mobile.Interface; using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp { // Start is called before the first frame update ScrollRect loginScrollView; Transform thirdLoginPage; public WeChatController weChat { get; private set; } void Awake() { loginScrollView = transform.Find("Panel/LoginContainer/LoginScrollView").GetComponent(); thirdLoginPage = loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third"); UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer/BtnThirdLogin").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b)=> ShowThirdLoginPage()); UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third/BtnReturn").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) => HideThirdLoginPage()); UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third/otherContainer/Wechat").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) => goWxLogin()); } private void Start() { transform.Find("MobileInfo/BatteryText").GetComponent().text = $"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%"; transform.Find("MobileInfo/TimeText").GetComponent().text = DateTime.Now.ToString("HH:mm"); weChat = App.weChatController; weChat.Init(App.WxAppId); //App.weChatController.Init(App.WxAppId); //var s = App.weChatController.isApplicationAvilible("com.gugoumainapp","powerfun").ToString(); //Utils.showToast(null, SystemInfo.batteryLevel.ToString()); } // Update is called once per frame void Update() { } private void ShowThirdLoginPage() { thirdLoginPage.DOLocalMoveY(0, 0.3f); } public void HideThirdLoginPage() { thirdLoginPage.DOLocalMoveY(-301, 0.3f); } private void goWxLogin() { #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS) if (weChat.IsWeChatAppInstalled()) { weChat.WxLogin("snsapi_userinfo", ""); } #endif } /// /// 从ios或者安卓接收code,在c#里不建议调用 /// /// public void OnMobileWxLoginResp(string res) { if (res.Contains("true;")) { GetComponent().goWxLoginWithCode(res.Replace("true;", ""), "mobile"); } else { Utils.showToast(null, res.Replace("false;", "")); } } }