2021-08-23 09:28:14 +08:00
|
|
|
|
using Assets.Scripts;
|
2021-09-13 17:33:58 +08:00
|
|
|
|
using Assets.Scripts.Mobile.Interface;
|
2021-08-24 17:50:14 +08:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
using System;
|
2021-08-23 09:28:14 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
2021-08-24 17:50:14 +08:00
|
|
|
|
using UnityEngine.UI;
|
2021-08-23 09:28:14 +08:00
|
|
|
|
|
2021-09-13 17:33:58 +08:00
|
|
|
|
public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
|
2021-08-23 09:28:14 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Start is called before the first frame update
|
2021-08-24 17:50:14 +08:00
|
|
|
|
ScrollRect loginScrollView;
|
|
|
|
|
|
Transform thirdLoginPage;
|
2021-08-26 15:08:02 +08:00
|
|
|
|
|
|
|
|
|
|
public WeChatController weChat { get; private set; }
|
|
|
|
|
|
|
2021-08-24 17:50:14 +08:00
|
|
|
|
void Awake()
|
2021-08-23 09:28:14 +08:00
|
|
|
|
{
|
2021-08-24 17:50:14 +08:00
|
|
|
|
loginScrollView = transform.Find("Panel/LoginContainer/LoginScrollView").GetComponent<ScrollRect>();
|
|
|
|
|
|
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());
|
2021-08-23 09:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-24 17:50:14 +08:00
|
|
|
|
|
2021-08-26 15:08:02 +08:00
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.Find("MobileInfo/BatteryText").GetComponent<Text>().text =
|
|
|
|
|
|
$"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%";
|
|
|
|
|
|
transform.Find("MobileInfo/TimeText").GetComponent<Text>().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());
|
|
|
|
|
|
}
|
2021-08-23 09:28:14 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ShowThirdLoginPage()
|
|
|
|
|
|
{
|
2021-08-24 17:50:14 +08:00
|
|
|
|
thirdLoginPage.DOLocalMoveY(0, 0.3f);
|
2021-08-23 09:28:14 +08:00
|
|
|
|
}
|
2021-08-24 17:50:14 +08:00
|
|
|
|
public void HideThirdLoginPage()
|
2021-08-23 09:28:14 +08:00
|
|
|
|
{
|
2021-08-24 17:50:14 +08:00
|
|
|
|
thirdLoginPage.DOLocalMoveY(-301, 0.3f);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void goWxLogin()
|
|
|
|
|
|
{
|
|
|
|
|
|
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
|
|
|
|
|
|
if (weChat.IsWeChatAppInstalled())
|
|
|
|
|
|
{
|
|
|
|
|
|
weChat.WxLogin("snsapi_userinfo", "");
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2021-08-23 09:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从ios或者安卓接收code,在c#里不建议调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="res"></param>
|
|
|
|
|
|
public void OnMobileWxLoginResp(string res)
|
|
|
|
|
|
{
|
2021-09-13 17:33:58 +08:00
|
|
|
|
if (res.Contains("true;"))
|
|
|
|
|
|
{
|
|
|
|
|
|
GetComponent<LoginController>().goWxLoginWithCode(res.Replace("true;", ""), "mobile");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.showToast(null, res.Replace("false;", ""));
|
|
|
|
|
|
}
|
2021-08-23 09:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|