powerfun-unity/Assets/Scripts/Mobile/LoginControllerMobile.cs

64 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Assets.Scripts;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoginControllerMobile : MonoBehaviour
{
// Start is called before the first frame update
ScrollRect loginScrollView;
Transform thirdLoginPage;
void Awake()
{
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());
}
// 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)
var weChat = App.weChatController;
weChat.Init(App.WxAppId);
if (weChat.IsWeChatAppInstalled())
{
weChat.WxLogin("snsapi_userinfo", "");
}
#endif
}
/// <summary>
/// 从ios或者安卓接收code在c#里不建议调用
/// </summary>
/// <param name="res"></param>
public void OnMobileWxLoginResp(string res)
{
Utils.showToast(gameObject, res, type: 1);
}
}