2021-03-26 16:36:31 +08:00
using Assets.Scripts ;
2021-04-06 15:30:36 +08:00
using Assets.Scripts.Apis ;
using Assets.Scripts.Apis.Models ;
2021-09-13 18:21:43 +08:00
using Assets.Scripts.Scenes ;
2021-04-16 17:49:11 +08:00
using Assets.Scripts.UI.Control ;
2021-04-06 15:30:36 +08:00
using Assets.Scripts.UI.Prefab.Login ;
2021-03-26 16:36:31 +08:00
using DG.Tweening ;
2021-03-25 16:55:36 +08:00
using Newtonsoft.Json ;
using Newtonsoft.Json.Linq ;
using System ;
using System.Collections ;
using System.Collections.Generic ;
2021-04-21 11:19:31 +08:00
using System.Linq ;
2021-03-25 16:55:36 +08:00
using System.Reflection ;
using System.Text ;
2021-04-06 15:30:36 +08:00
using System.Text.RegularExpressions ;
2021-04-26 16:25:52 +08:00
using System.Threading ;
2021-04-16 17:49:11 +08:00
using System.Threading.Tasks ;
2021-04-06 15:30:36 +08:00
using System.Timers ;
2021-03-25 16:55:36 +08:00
using UnityEngine ;
2021-09-13 18:21:43 +08:00
using UnityEngine.Android ;
2021-04-01 11:01:05 +08:00
using UnityEngine.Events ;
using UnityEngine.EventSystems ;
2021-03-25 16:55:36 +08:00
using UnityEngine.SceneManagement ;
using UnityEngine.UI ;
2021-08-09 10:01:17 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-06 15:30:36 +08:00
using ZenFulcrum.EmbeddedBrowser ;
2021-08-09 10:01:17 +08:00
#endif
2021-03-30 14:14:24 +08:00
//记录: 小f 是-457和-681
2021-04-06 15:30:36 +08:00
2021-08-25 10:29:03 +08:00
public class QUserInfo
2021-04-06 15:30:36 +08:00
{
public long Id { get ; set ; }
2021-04-21 16:16:14 +08:00
public string Phone { get ; set ; }
2021-04-06 15:30:36 +08:00
public string NickName { get ; set ; }
public string Avatar { get ; set ; }
public string Cookie { get ; set ; }
}
2021-08-25 10:29:03 +08:00
public class LoginForm
2021-04-09 15:57:50 +08:00
{
public InputField email { get ; set ; }
public InputField password { get ; set ; }
}
2021-08-25 10:29:03 +08:00
public class SignForm
2021-04-01 11:01:05 +08:00
{
2021-04-06 15:30:36 +08:00
//页面1
public InputField email { get ; set ; }
public InputField captcha { get ; set ; }
public InputField password { get ; set ; }
public InputField cpassword { get ; set ; }
//页面2
public Dropdown years { get ; set ; }
public Dropdown months { get ; set ; }
public Dropdown days { get ; set ; }
public Dropdown genders { get ; set ; }
public InputField weight { get ; set ; }
public InputField height { get ; set ; }
public Dropdown countrys { get ; set ; }
public Dropdown units { get ; set ; }
2021-04-01 11:01:05 +08:00
}
2021-09-13 18:21:43 +08:00
public class LoginController : BaseScene
2021-03-25 16:55:36 +08:00
{
2021-09-13 18:21:43 +08:00
public GameObject loadingPanel { get ; set ; }
2021-04-09 15:57:50 +08:00
private Transform mainContent ;
/*初始页面*/
private Transform quickContainer ;
private Transform loginContainer ;
private Transform signContainer ;
2021-04-21 16:16:14 +08:00
//修改高度
Transform LoginBg ;
2021-04-09 15:57:50 +08:00
/*初始页面*/
LoginForm loginForm ;
2021-04-01 11:01:05 +08:00
[SerializeField] Button loginReturn2 ;
2021-04-09 15:57:50 +08:00
private Button remember ;
/*滑动相关*/
2021-03-30 14:14:24 +08:00
[SerializeField] GameObject loginScrollView ;
[SerializeField] GameObject signScrollView ;
2021-04-09 15:57:50 +08:00
[SerializeField] GameObject avatarScrollView ;
/*滑动相关*/
//注册
2021-04-06 15:30:36 +08:00
private Transform signPage1 ;
private Transform signPage2 ;
private Transform signScrollBar ;
private SignForm signForm ;
private LoginRegOptions regOptions ;
2021-04-21 16:16:14 +08:00
2021-03-30 14:14:24 +08:00
private ScrollRect scrollPanel ;
private ScrollRect scrollSign ;
2021-04-01 11:01:05 +08:00
private ScrollRect scrollAvatar ;
2021-04-21 16:16:14 +08:00
private Transform imagexf , imagedf ;
2021-04-06 15:30:36 +08:00
//注册主页面
private UserResultModel userResult ;
/*微信相关*/
2021-08-09 10:01:17 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-06 15:30:36 +08:00
private Browser wxBrowser ;
2021-08-09 10:01:17 +08:00
#endif
2021-04-06 15:30:36 +08:00
private string wxState ;
private Transform wxLogin1 ;
private Transform wxLogin2 ;
private Transform wxLogin3 ;
private JObject wxInfoJson ;
private bool wxLock ;
/*微信相关*/
private List < QUserInfo > userInfos ;
2021-04-09 15:57:50 +08:00
/*退出按钮*/
[SerializeField] Button exit ;
/*退出按钮*/
//其他
[SerializeField] RawImage loading ;
2021-04-15 15:58:37 +08:00
Transform toolContainer ;
2021-08-25 10:29:03 +08:00
Dictionary < string , Selectable > formDict , signFormDict ;
2021-04-15 15:58:37 +08:00
2021-04-21 16:16:14 +08:00
public string avatarName { get ; private set ; }
2021-11-01 11:04:22 +08:00
2021-04-21 16:16:14 +08:00
public Texture avatar ;
2021-03-25 16:55:36 +08:00
// Start is called before the first frame update
void Start ( )
{
2021-09-13 18:21:43 +08:00
#if UNITY_ANDROID | | UNITY_IOS
loadingPanel = transform . Find ( "LoadingPanel" ) . gameObject ;
#endif
#if UNITY_ANDROID
2021-09-16 15:36:36 +08:00
Permission . RequestUserPermission ( Permission . FineLocation ) ;
Permission . RequestUserPermission ( Permission . ExternalStorageRead ) ;
Permission . RequestUserPermission ( Permission . ExternalStorageWrite ) ;
2021-09-15 16:05:27 +08:00
#elif UNITY_IOS
Input . location . Start ( ) ;
2021-09-13 18:21:43 +08:00
#endif
2021-11-02 17:55:49 +08:00
UIManager . SetModalPanel ( transform . Find ( "ModalPanel" ) . GetComponent < PFUIPanel > ( ) ) ;
if ( ! string . IsNullOrEmpty ( App . is401 ) )
{
2021-11-03 13:48:53 +08:00
UIManager . ShowAlert ( "WARNING" , "Your account has been logged in on other devices. If you did not do it yourself, please change your password in time." ) ;
2021-11-02 17:55:49 +08:00
}
2021-04-29 11:36:30 +08:00
Init ( ) ;
2021-03-30 14:14:24 +08:00
if ( loginScrollView ! = null )
{
scrollPanel = loginScrollView . GetComponent < ScrollRect > ( ) ;
2021-04-21 16:16:14 +08:00
LoginBg = loginScrollView . transform . Find ( "Viewport" ) . Find ( "LoginBg" ) ;
2021-04-06 15:30:36 +08:00
mainContent = loginScrollView . transform . Find ( "Viewport" ) . Find ( "Content" ) ;
2021-04-16 17:49:11 +08:00
quickContainer = mainContent . Find ( "Empty" ) . Find ( "FormContainer-Quick" ) ;
loginContainer = mainContent . Find ( "FormContainer-Login" ) . Find ( "Mask" ) . Find ( "FormContainer" ) ;
2021-04-09 15:57:50 +08:00
signContainer = mainContent . Find ( "FormContainer-Sign" ) ;
2021-03-30 14:14:24 +08:00
}
if ( signScrollView ! = null )
{
scrollSign = signScrollView . GetComponent < ScrollRect > ( ) ;
2021-04-06 15:30:36 +08:00
var content = signScrollView . transform . Find ( "Viewport" ) . Find ( "Content" ) ;
signPage1 = content . Find ( "FirstPage" ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( signPage1 . Find ( "next" ) . GetComponent < Button > ( ) . gameObject ,
EventTriggerType . PointerClick , ( b ) = > goRegNext ( ) ) ;
2021-04-26 16:25:52 +08:00
UIManager . AddEvent ( signPage1 . Find ( "BtnModiPass" ) . GetComponent < Button > ( ) . gameObject ,
EventTriggerType . PointerClick , ( b ) = > goResetPassword ( ) ) ;
2021-04-21 16:16:14 +08:00
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
UIManager . AddEvent ( signPage1 . Find ( "Captcha" ) . Find ( "BtnGet" ) . gameObject ,
2021-08-25 10:29:03 +08:00
EventTriggerType . PointerClick , ( b ) = > GetCaptcha ( ) ) ;
2021-04-21 16:16:14 +08:00
//signPage1.Find("Captcha").Find("BtnGet").GetComponent<Button>().onClick.AddListener(GetCaptcha);
2021-04-06 15:30:36 +08:00
var email = signPage1 . Find ( "Email" ) . GetComponent < InputField > ( ) ;
var captcha = signPage1 . Find ( "Captcha" ) . GetComponent < InputField > ( ) ;
var password = signPage1 . Find ( "Password" ) . GetComponent < InputField > ( ) ;
var cpassword = signPage1 . Find ( "CPassword" ) . GetComponent < InputField > ( ) ;
//第三方登录要用的按钮
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( signPage1 . Find ( "previousThird" ) . GetComponent < Button > ( ) . gameObject ,
EventTriggerType . PointerClick , ( b ) = > goThirdPrev ( ) ) ;
//signPage1.Find("previousThird").GetComponent<Button>().onClick.AddListener(goThirdPrev);
UIManager . AddEvent ( signPage1 . Find ( "signThird" ) . GetComponent < Button > ( ) . gameObject ,
EventTriggerType . PointerClick , ( b ) = > goRegNext ( 1 ) ) ;
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
2021-04-06 15:30:36 +08:00
signPage2 = content . Find ( "NextPage" ) ;
2021-08-24 17:50:14 +08:00
//UIManager.AddEvent(signPage2.Find("previous").GetComponent<Button>().gameObject,
// EventTriggerType.PointerClick, (b) => goRegPrev());
//signPage2.Find("previous").GetComponent<Button>().enabled = false;
//signPage2.Find("previous").GetComponent<Button>().interactable = false;
2021-04-21 16:16:14 +08:00
//signPage2.Find("previous").GetComponent<Button>().onClick.AddListener(goRegPrev);
UIManager . AddEvent ( signPage2 . Find ( "sign" ) . GetComponent < Button > ( ) . gameObject ,
EventTriggerType . PointerClick , ( b ) = > goRegEnd ( ) ) ;
//signPage2.Find("sign").GetComponent<Button>().onClick.AddListener(goRegEnd);
2021-04-06 15:30:36 +08:00
//注册2 字段
var years = signPage2 . Find ( "Year" ) . GetComponent < Dropdown > ( ) ;
var months = signPage2 . Find ( "Month" ) . GetComponent < Dropdown > ( ) ;
var days = signPage2 . Find ( "Day" ) . GetComponent < Dropdown > ( ) ;
var genders = signPage2 . Find ( "Gender" ) . GetComponent < Dropdown > ( ) ;
var countrys = signPage2 . Find ( "Country" ) . GetComponent < Dropdown > ( ) ;
var units = signPage2 . Find ( "Unit" ) . GetComponent < Dropdown > ( ) ;
2021-04-15 15:58:37 +08:00
regOptions = new LoginRegOptions ( ) ;
2021-04-06 15:30:36 +08:00
years . options = regOptions . years ;
months . options = regOptions . months ;
days . options = regOptions . days ;
years . captionText . text = "Year" ;
months . captionText . text = "Month" ;
days . captionText . text = "Day" ;
years . onValueChanged . AddListener ( ( int index ) = >
{
2021-04-21 16:16:14 +08:00
if ( index ! = - 1 & & months . value ! = - 1 )
2021-04-06 15:30:36 +08:00
{
days . options = regOptions . GetDayOptions ( int . Parse ( years . captionText . text ) , int . Parse ( months . captionText . text ) ) ;
days . value = 0 ;
}
} ) ;
months . onValueChanged . AddListener ( ( int index ) = >
{
if ( index ! = - 1 & & years . value ! = - 1 )
{
days . options = regOptions . GetDayOptions ( int . Parse ( years . captionText . text ) , int . Parse ( months . captionText . text ) ) ;
days . value = 0 ;
}
} ) ;
genders . options = regOptions . genders ;
genders . captionText . text = "Gender" ;
countrys . options = regOptions . countrys ;
countrys . value = regOptions . countryDefaultValue ;
countrys . onValueChanged . AddListener ( ( int index ) = >
{
countrys . transform . Find ( "RawImage" ) . GetComponent < RawImage > ( ) . texture = regOptions . GetCountryImage ( index ) ;
} ) ;
units . options = regOptions . units ;
units . captionText . text = "Display Units" ;
signForm = new SignForm ( )
{
email = email ,
captcha = captcha ,
password = password ,
cpassword = cpassword ,
weight = signPage2 . Find ( "Weight" ) . GetComponent < InputField > ( ) ,
height = signPage2 . Find ( "Height" ) . GetComponent < InputField > ( ) ,
years = years ,
months = months ,
days = days ,
genders = genders ,
countrys = countrys ,
units = units ,
} ;
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-06 15:30:36 +08:00
signScrollBar = signScrollView . transform . Find ( "Image" ) . Find ( "Image" ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-03-30 14:14:24 +08:00
}
2021-04-06 15:30:36 +08:00
if ( avatarScrollView ! = null )
2021-04-01 11:01:05 +08:00
{
2021-04-06 15:30:36 +08:00
scrollAvatar = avatarScrollView . GetComponent < ScrollRect > ( ) ;
var content = scrollAvatar . transform . Find ( "Viewport" ) . Find ( "Content" ) ;
2021-04-21 16:16:14 +08:00
foreach ( var user in userInfos )
2021-04-06 15:30:36 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-06 15:30:36 +08:00
var info = Instantiate ( Resources . Load < GameObject > ( "UI/Prefab/Login/QuickUserInfo" ) ) . transform ;
2021-08-24 17:50:14 +08:00
#else
var info = Instantiate ( Resources . Load < GameObject > ( "UI/Prefab/Login/Mobile/QuickUserInfo" ) ) . transform ;
#endif
2021-04-21 16:16:14 +08:00
info . GetComponent < QuickLoginUser > ( ) . Initial ( user , transform ) ;
2021-05-10 10:21:46 +08:00
info . SetParent ( content ) ;
2021-04-06 15:30:36 +08:00
info . localScale = new Vector3 ( 1 , 1 , 1 ) ;
}
content . Find ( "empty1" ) . transform . SetSiblingIndex ( 0 ) ;
2021-04-21 16:16:14 +08:00
content . Find ( "empty2" ) . transform . SetSiblingIndex ( content . childCount - 1 ) ;
2021-04-06 15:30:36 +08:00
scrollAvatar . GetComponent < QuickLoginScroll > ( ) . Initial ( ) ;
2021-04-01 11:01:05 +08:00
}
2021-04-21 16:16:14 +08:00
if ( quickContainer ! = null )
2021-03-30 14:14:24 +08:00
{
2021-04-09 15:57:50 +08:00
var loginNewAccount = quickContainer . Find ( "loginNewAccount" ) . GetComponent < Button > ( ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( loginNewAccount . gameObject , EventTriggerType . PointerClick , ( b ) = > goLogin ( ) ) ;
2021-03-30 14:14:24 +08:00
}
2021-04-21 16:16:14 +08:00
if ( loginContainer ! = null )
2021-03-30 14:14:24 +08:00
{
2021-04-09 15:57:50 +08:00
var returnQuick = loginContainer . Find ( "returnQuick" ) . GetComponent < Button > ( ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( returnQuick . gameObject , EventTriggerType . PointerClick , ( b ) = > ReturnQuick ( ) ) ;
2021-04-09 15:57:50 +08:00
var sign = loginContainer . Find ( "reg" ) . GetComponent < Button > ( ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( sign . gameObject , EventTriggerType . PointerClick , ( b ) = > goSign ( ) ) ;
2021-04-09 15:57:50 +08:00
remember = loginContainer . Find ( "rememberButton" ) . GetComponent < Button > ( ) ;
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( remember . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-08-25 10:29:03 +08:00
{
var gou = remember . transform . Find ( "Gou" ) ;
if ( gou . gameObject . activeSelf )
{
gou . gameObject . SetActive ( false ) ;
}
else
{
gou . gameObject . SetActive ( true ) ;
}
} ) ;
UIManager . AddEvent ( loginContainer . Find ( "ForgetPassword" ) . gameObject , EventTriggerType . PointerClick , ( e ) = > goSign ( type : 1 ) ) ;
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-09 15:57:50 +08:00
var wechatLogin = loginContainer . Find ( "otherContainer" ) . Find ( "Wechat" ) . GetComponent < Button > ( ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( wechatLogin . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-06 15:30:36 +08:00
{
2021-08-24 17:50:14 +08:00
2021-04-06 15:30:36 +08:00
if ( wxLock ) return ;
wxLock = true ;
2021-06-07 13:51:13 +08:00
//wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
wxBrowser . Url = $"https://open.weixin.qq.com/connect/qrconnect?appid={App.WxAppId}&redirect_uri=https%3A%2F%2Fwx.powerfun.com.cn%2FNoAuth%2Fv1%2FWxWebLogin&response_type=code&scope=snsapi_login&state=unity#wechat_redirect" ;
2021-04-29 23:45:29 +08:00
AdjustWxQrCode ( ) ;
2021-04-30 10:32:01 +08:00
//wxBrowser.RegisterFunction("isFinish", args =>
//{
// Debug.Log(331);
// startJs = false;
//});
////AdjustWxQrCode();
//startJs = true;
//var wx1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
wxLogin1 . gameObject . SetActive ( true ) ;
//Debug.Log(178 + "已经开启" + wx1.gameObject.activeSelf);
2021-04-16 17:49:11 +08:00
//wx1.GetComponent<CanvasGroup>().DOFade(1, 0.8f).onComplete = () => { wxLock = false; };
2021-04-30 10:32:01 +08:00
wxLogin1 . DOLocalMoveY ( 0 , 0.3f ) . onComplete = ( ) = > { wxLock = false ; } ;
2021-08-24 17:50:14 +08:00
} ) ;
#endif
2021-04-09 15:57:50 +08:00
var login = loginContainer . Find ( "login" ) . GetComponent < Button > ( ) ;
2021-04-21 16:16:14 +08:00
UIManager . AddEvent ( login . gameObject , EventTriggerType . PointerClick , ( b ) = > Submit ( ) ) ;
//login.onClick.AddListener(Submit);
2021-04-09 15:57:50 +08:00
loginForm = new LoginForm ( )
{
email = loginContainer . Find ( "phone" ) . GetComponent < InputField > ( ) ,
password = loginContainer . Find ( "pwd" ) . GetComponent < InputField > ( )
} ;
2021-04-06 15:30:36 +08:00
}
2021-04-09 15:57:50 +08:00
//if (loginReturn2 != null)
//{
// loginReturn2.onClick.AddListener(goLoginReturn2);
//}
2021-04-21 16:16:14 +08:00
if ( signContainer ! = null )
2021-04-09 15:57:50 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-09 15:57:50 +08:00
var loginr2 = signContainer . Find ( "loginr2" ) . GetComponent < Button > ( ) ;
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( loginr2 . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
goLoginReturn2 ( ) ;
} ) ;
2021-08-24 17:50:14 +08:00
#else
UIManager . AddEvent ( signContainer . Find ( "loginr2" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
goLoginReturn2 ( ) ;
} ) ;
#endif
2021-04-09 15:57:50 +08:00
}
if ( exit ! = null )
{
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( exit . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
2021-04-28 15:21:06 +08:00
UIManager . ShowConfirm ( "Quit" , "Do you want to quit PowerFun?" , ( ) = >
{
Application . Quit ( ) ;
2021-08-25 10:29:03 +08:00
} , 2 ) ;
2021-04-21 11:19:31 +08:00
} ) ;
2021-04-09 15:57:50 +08:00
}
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-16 17:49:11 +08:00
wxLogin1 = mainContent . Find ( "FormContainer-Login" ) . Find ( "Mask" ) . Find ( "FormContainer-wx1" ) ;
2021-04-06 15:30:36 +08:00
if ( wxLogin1 ! = null )
{
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( wxLogin1 . Find ( "Image" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
2021-05-20 14:12:43 +08:00
wxReturnLogin ( ) ;
2021-04-21 11:19:31 +08:00
} ) ;
2021-04-06 15:30:36 +08:00
wxBrowser = wxLogin1 . Find ( "Browser (GUI)" ) . GetComponent < Browser > ( ) ;
if ( wxBrowser ! = null )
{
// wxBrowser.EvalJS(@"Object.defineProperties(Navigator.prototype, {
// language: {
// value: 'zh-CN',
// configurable: false,
// enumerable: true,
// writable: false
// },
// languages: {
// value: ['zh-CN','en','zh'],
// configurable: false,
// enumerable: true,
// writable: false
// }
//});");
2021-04-30 10:32:01 +08:00
2021-04-06 15:30:36 +08:00
wxBrowser . onTextureUpdated + = OnUserScan ;
//browser.Zoom = 0.5f;
//browser.
}
2021-08-24 17:50:14 +08:00
2021-04-06 15:30:36 +08:00
}
2021-08-24 17:50:14 +08:00
#endif
2021-04-06 15:30:36 +08:00
wxLogin2 = mainContent . Find ( "FormContainer-wx2" ) ;
2021-04-21 16:16:14 +08:00
if ( wxLogin2 ! = null )
2021-04-06 15:30:36 +08:00
{
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( wxLogin2 . Find ( "return" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-08-25 10:29:03 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-30 10:32:01 +08:00
wxLogin1 . gameObject . SetActive ( false ) ;
wxLogin1 . GetComponent < RectTransform > ( ) . localPosition = new Vector3 ( 0 , - 573 , 0 ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-08-25 10:29:03 +08:00
wxLogin2 . gameObject . SetActive ( false ) ;
//wxLogin3.gameObject.SetActive(false);
pageNums = 4 ;
//Canvas.ForceUpdateCanvases();
StartScrollPanel ( 1 ) ;
} ) ;
2021-04-21 16:16:14 +08:00
wxLogin2 . Find ( "Next" ) . GetComponent < Button > ( ) . onClick . AddListener ( ( ) = >
2021-04-06 15:30:36 +08:00
{
this . goSign ( false ) ;
} ) ;
}
wxLogin3 = mainContent . Find ( "FormContainer-wx3" ) ;
if ( wxLogin3 ! = null )
{
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( wxLogin3 . Find ( "return" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-08-25 10:29:03 +08:00
{
if ( signContainer . gameObject . activeSelf )
{
if ( pageNums = = 5 )
{
2021-10-14 14:04:44 +08:00
#if UNITY_ANDROID | | UNITY_IOS
MobileAni ( false ) ;
#endif
2021-08-25 10:29:03 +08:00
StartScrollPanel ( 3 ) ;
}
else if ( pageNums = = 4 )
{
2021-10-14 14:04:44 +08:00
#if UNITY_ANDROID | | UNITY_IOS
MobileAni ( false ) ;
#endif
2021-08-25 10:29:03 +08:00
StartScrollPanel ( 2 ) ;
}
else
{
StartScrollPanel ( 1 ) ;
}
}
else
{
signContainer . gameObject . SetActive ( true ) ;
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-30 21:09:21 +08:00
wxLogin1 . gameObject . SetActive ( false ) ;
wxLogin1 . GetComponent < RectTransform > ( ) . localPosition = new Vector3 ( 0 , - 573 , 0 ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-08-25 10:29:03 +08:00
pageNums = 4 ;
//wxLogin3.gameObject.SetActive(false);
StartScrollPanel ( 1 ) ;
}
} ) ;
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( wxLogin3 . Find ( "rememberButton" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-08-25 10:29:03 +08:00
{
var gou = wxLogin3 . Find ( "rememberButton" ) . Find ( "Gou" ) . gameObject ;
gou . SetActive ( ! gou . activeSelf ) ;
} ) ;
UIManager . AddEvent ( wxLogin3 . Find ( "Next" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-06 15:30:36 +08:00
{
goMain ( wxLogin3 . Find ( "rememberButton" ) . Find ( "Gou" ) ) ;
} ) ;
}
2021-03-30 14:14:24 +08:00
imagexf = transform . Find ( "Panel" ) . Find ( "LoginContainer" ) . Find ( "Imagexf" ) ;
2021-04-16 17:49:11 +08:00
imagedf = transform . Find ( "Panel" ) . Find ( "LoginContainer" ) . Find ( "Imagedf" ) ;
2021-04-15 15:58:37 +08:00
toolContainer = transform . Find ( "Panel" ) . Find ( "ToolContainer" ) ;
2021-04-21 16:16:14 +08:00
if ( toolContainer ! = null )
2021-04-15 15:58:37 +08:00
{
2021-04-21 11:19:31 +08:00
UIManager . AddEvent ( toolContainer . Find ( "Setting" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-08-25 10:29:03 +08:00
{
UIManager . ShowSettingModal ( ) ;
} ) ;
2021-04-21 11:19:31 +08:00
//toolContainer.Find("Setting").GetComponent<Button>().onClick.AddListener(() =>
//{
// UIManager.ShowSettingModal();
//});
UIManager . AddEvent ( toolContainer . Find ( "Msg" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-16 17:49:11 +08:00
{
UIManager . ShowNewsModal ( ) ;
} ) ;
2021-04-21 11:19:31 +08:00
//toolContainer.Find("Msg").GetComponent<Button>().onClick.AddListener(() =>
//{
// UIManager.ShowNewsModal();
//});
2021-04-15 15:58:37 +08:00
}
2021-04-21 16:16:14 +08:00
if ( userInfos . Count = = 0 ) goLoginImmediately ( ) ;
formDict = new Dictionary < string , Selectable > ( )
{
{ "Phone" , loginForm . email } ,
{ "Pwd" , loginForm . password } ,
} ;
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-21 16:16:14 +08:00
loginForm . email . onEndEdit . AddListener ( async ( s ) = >
{
if ( ! string . IsNullOrEmpty ( s ) & & avatarName ! = s )
{
var r = await ConfigHelper . userApi . GetHeadImg ( s ) ;
if ( ! string . IsNullOrEmpty ( r ) )
{
2021-05-08 14:38:23 +08:00
Utils . DisplayImage ( loginContainer . Find ( "Avatar" ) . GetComponent < RawImage > ( ) , r ) ;
2021-04-21 16:16:14 +08:00
avatarName = s ;
}
else
{
loginContainer . Find ( "Avatar" ) . GetComponent < RawImage > ( ) . texture = avatar ;
}
}
} ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-08-25 10:29:03 +08:00
signFormDict = new Dictionary < string , Selectable >
2021-04-21 16:16:14 +08:00
{
{ "Phone" , signForm . email } ,
{ "Captcha" , signForm . captcha } ,
{ "Pwd" , signForm . password } ,
2021-04-29 11:36:30 +08:00
{ "CPwd" , signForm . cpassword } ,
2021-04-21 16:16:14 +08:00
{ "Years" , signForm . years } ,
{ "Months" , signForm . months } ,
{ "Days" , signForm . days } ,
} ;
avatar = Resources . Load < Texture > ( "Images/New Account" ) ;
2021-08-23 09:28:14 +08:00
#if UNITY_ANDROID | | UNITY_IOS
transform . Find ( "Version" ) . GetComponent < Text > ( ) . text = $"V{App.AppVersion}" ;
#else
2021-04-29 11:36:30 +08:00
transform . Find ( "Panel" ) . Find ( "Version" ) . GetComponent < Text > ( ) . text = $"V{App.AppVersion}" ;
2021-08-23 09:28:14 +08:00
#endif
}
2021-11-02 17:55:49 +08:00
2021-08-25 10:29:03 +08:00
public void Test ( string key )
2021-08-23 09:28:14 +08:00
{
Debug . Log ( key ) ;
2021-04-29 11:36:30 +08:00
}
async void Init ( )
{
2021-11-02 17:55:49 +08:00
2021-11-01 11:04:22 +08:00
Debug . Log ( 535 ) ;
2021-04-29 11:36:30 +08:00
UIManager . Instance . ModalsPanel = this . transform . Find ( "ModalPanel" ) . GetComponent < PFUIPanel > ( ) ;
userInfos = UIManager . Instance . userInfos ;
App . DefaultRotateTexture = Utils . ReadTextureFromPlayerPrefs ( "rotateImage" ) ;
2021-04-30 10:32:01 +08:00
App . firstEnter = PlayerPrefs . GetInt ( "firstEnter" ) ;
PlayerPrefs . SetInt ( "firstEnter" , 1 ) ;
2021-05-10 10:21:46 +08:00
var notifyId = PlayerPrefs . GetInt ( "notifyId" ) ;
2021-08-27 15:06:56 +08:00
2021-04-29 11:36:30 +08:00
var r = await ConfigHelper . userApi . GetNotify ( ) ;
if ( r . result )
{
2021-10-12 20:07:13 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-08-25 10:29:03 +08:00
//#if !UNITY_EDITOR
2021-05-10 10:21:46 +08:00
var ver = r . data . Value < JObject > ( "Version" ) . ToObject < UpdateModel > ( ) ;
2021-08-25 10:29:03 +08:00
if ( ver ! = null & & ver . HasUpdate )
2021-05-10 10:21:46 +08:00
{
App . UpdateObject = ver ;
Debug . Log ( Application . persistentDataPath + "/PowerFun.exe" ) ;
UIManager . ShowDownloadModal ( ) ;
}
2021-08-25 10:29:03 +08:00
//#endif
2021-04-29 11:36:30 +08:00
App . notifyContent = r . data . Value < string > ( "Content" ) ;
2021-08-25 10:29:03 +08:00
2021-08-27 15:06:56 +08:00
if ( r . data . Value < int > ( "Id" ) ! = notifyId ) //r.data.Value<int>("Id") != notifyId
2021-04-29 11:36:30 +08:00
{
UIManager . ShowNewsModal ( ) ;
PlayerPrefs . SetInt ( "notifyId" , r . data . Value < int > ( "Id" ) ) ;
}
2021-10-12 20:07:13 +08:00
#else
var rr = await ConfigHelper . userApi . GetVersions ( ) ;
if ( rr . result )
{
2021-10-12 20:26:25 +08:00
#if UNITY_ANDROID
2021-10-12 20:07:13 +08:00
var info = rr . data . Value < JObject > ( "UnityApk" ) ;
2021-10-12 20:26:25 +08:00
#elif UNITY_IOS
var info = rr . data . Value < JObject > ( "UnityIos" ) ;
#endif
2021-10-13 19:03:14 +08:00
if ( Utils . isUpdate ( App . AppVersion , info . Value < string > ( "Version" ) ) ) return ;
2021-10-12 20:07:13 +08:00
}
2021-10-13 19:03:14 +08:00
Debug . Log ( notifyId ) ;
2021-10-12 20:07:13 +08:00
var ver = r . data . Value < JObject > ( "Version" ) . ToObject < UpdateModel > ( ) ;
2021-10-13 19:03:14 +08:00
if ( ver . UpdateLog . Count + 1 ! = notifyId ) //ver.UpdateLog.Count != notifyId
2021-10-12 20:07:13 +08:00
{
2021-10-13 11:29:09 +08:00
var log = ver . UpdateLog . FirstOrDefault ( ) ;
2021-10-12 20:07:13 +08:00
if ( log ! = null )
{
App . notifyContent = log . Desc ;
}
2021-10-13 19:03:14 +08:00
else
2021-10-12 20:07:13 +08:00
{
App . notifyContent = r . data . Value < string > ( "Content" ) ;
}
2021-10-13 19:03:14 +08:00
PlayerPrefs . SetInt ( "notifyId" , ver . UpdateLog . Count + 1 ) ;
2021-10-12 20:07:13 +08:00
UIManager . ShowNewsModal ( ) ;
}
2021-10-13 19:03:14 +08:00
2021-09-09 16:29:22 +08:00
#endif
2021-10-13 19:03:14 +08:00
}
2021-05-10 10:21:46 +08:00
GetRotateImage ( ) ;
2021-04-06 15:30:36 +08:00
}
2021-04-26 16:25:52 +08:00
async void GetRotateImage ( )
{
if ( ! App . TextureCache . ContainsKey ( "rotateImage" ) )
{
var locationInfo = await ConfigHelper . thirdPartApi . GetLocationInfo ( ) ;
App . latitude = locationInfo . latitude ;
App . longitude = locationInfo . longitude ;
//if (locationInfo.status == 0)
//{
// Debug.Log(locationInfo.address);
// Utils.DownloadImageToLocal(StartCoroutine,
// $"https://api.mapbox.com/styles/v1/mapbox/dark-v10/static/{locationInfo.content.point.x},{locationInfo.content.point.y},12.14,0/1280x1280?access_token=pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA",
// "rotateImage");
//}
//else
//{
// Debug.Log(locationInfo.message);
//}
Debug . Log ( JsonConvert . SerializeObject ( locationInfo ) ) ;
var i = await ConfigHelper . thirdPartApi . GetMapImage ( locationInfo ) ;
var t = new Texture2D ( 2 , 2 ) ;
2021-08-25 10:29:03 +08:00
if ( t . LoadImage ( Utils . StreamToBytes ( i ) ) )
2021-04-26 16:25:52 +08:00
{
Debug . Log ( "成功" ) ;
App . TextureCache [ "rotateImage" ] = t ;
Utils . WriteTextureToPlayerPrefs ( "rotateImage" , t ) ;
}
//Debug.Log(locationInfo.country);
//Utils.DownloadImageToLocal(StartCoroutine,
//$"https://api.mapbox.com/styles/v1/mapbox/dark-v10/static/{locationInfo.longitude},{locationInfo.latitude},12.14,0/1280x1280?access_token=pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA",
//"rotateImage");
}
}
/// <summary>
/// 执行js 修改微信登录页样式
/// </summary>
2021-04-21 16:16:14 +08:00
private void AdjustWxQrCode ( )
2021-04-06 15:30:36 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-30 10:32:01 +08:00
wxBrowser . EvalJSCSP ( @ "
document . getElementsByClassName ( ' qrcode ' ) [ 0 ] . style . marginTop = 0 ;
document . getElementsByClassName ( ' title ' ) [ 0 ] . style . display = ' none ' ;
document . getElementById ( ' wx_default_tip ' ) . childNodes [ 3 ] . innerHTML = ` "" PowerFun "" ` ;
document . body . style . background = ' # 272732 ' ;
document . body . style . overflow = ' hidden ' ;
document . body . style . transformOrigin = ' top left ' ;
document . body . style . transform = ' scale ( 0.85106382978 ) ' ;
2021-05-10 10:21:46 +08:00
document . body . style . padding = '0' ; ").Done();
2021-08-09 10:01:17 +08:00
#endif
2021-04-06 15:30:36 +08:00
}
//浏览器加载回调
2021-08-09 10:01:17 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-06 15:30:36 +08:00
private async void OnUserScan ( )
{
if ( wxBrowser . Url . Contains ( "qrconnect" ) )
{
2021-04-29 23:45:29 +08:00
//AdjustWxQrCode();
2021-04-06 15:30:36 +08:00
}
var rgx = Regex . Match ( wxBrowser . Url , @"https\:\/\/wx.powerfun.com.cn/NoAuth/v1/WxWebLogin\?code=(.*?)&state=(.*?)$" ) ;
var groups = rgx . Groups ;
if ( groups . Count = = 3 )
{
2021-06-07 13:51:13 +08:00
//wxBrowser.LoadHTML("<div />");
2021-04-06 15:30:36 +08:00
var state = groups [ 2 ] . Value ;
2021-06-07 13:51:13 +08:00
if ( state = = "unity" )
2021-04-06 15:30:36 +08:00
{
2021-06-07 13:51:13 +08:00
//wxBrowser.
//var acjson = await ConfigHelper.thirdPartApi.GetWxAccessToken(groups[1].Value);
//var infojson = await ConfigHelper.thirdPartApi.GetWxUserInfo(
// acjson.Value<string>("access_token"), acjson.Value<string>("openid"));
2021-09-13 17:33:58 +08:00
2021-06-07 13:51:13 +08:00
//string unionId = wxInfoJson.Value<string>("unionid"),
// openId = wxInfoJson.Value<string>("openid");
2021-09-13 17:33:58 +08:00
await goWxLoginWithCode ( groups [ 1 ] . Value , groups [ 2 ] . Value ) ;
2021-04-06 15:30:36 +08:00
}
}
2021-08-09 10:01:17 +08:00
}
#endif
2021-09-13 17:33:58 +08:00
public async Task goWxLoginWithCode ( string code , string state )
{
var r = await ConfigHelper . userApi . OnWebWxLoginCheckUnionIdByCode ( code , state ) ;
if ( r . result )
{
JObject data = JObject . FromObject ( r . data ) ;
if ( data . Value < string > ( "success" ) ! = null & & data . Value < string > ( "success" ) = = "False" )
{
wxInfoJson = data ;
wxLogin2 . gameObject . SetActive ( true ) ;
Utils . DisplayImage ( wxLogin2 . Find ( "Avatar" ) . GetComponent < RawImage > ( ) ,
wxInfoJson . Value < string > ( "headimgurl" ) ) ;
wxLogin2 . Find ( "NickName" ) . GetComponent < Text > ( ) . text = wxInfoJson . Value < string > ( "nickname" ) ;
wxLogin3 . gameObject . SetActive ( true ) ;
Utils . DisplayImage ( wxLogin3 . Find ( "Avatar" ) . GetComponent < RawImage > ( ) ,
wxInfoJson . Value < string > ( "headimgurl" ) ) ;
wxLogin3 . Find ( "NickName" ) . GetComponent < Text > ( ) . text = wxInfoJson . Value < string > ( "nickname" ) ;
pageNums = 5 ;
//this.goSign();
StartScrollPanel ( 2 ) ;
}
else
{
RefreshWx3 ( data . ToObject < UserResultModel > ( ) , 1 ) ;
wxLogin3 . gameObject . SetActive ( true ) ;
//Utils.DisplayImage(StartCoroutine,
//wxLogin3.Find("Avatar").GetComponent<RawImage>(),
//wxInfoJson.Value<string>("headimgurl"));
//wxLogin3.Find("NickName").GetComponent<Text>().text = wxInfoJson.Value<string>("nickname");
signContainer . gameObject . SetActive ( false ) ;
pageNums = 3 ;
2021-10-14 14:04:44 +08:00
MobileAni ( true ) ;
2021-09-13 17:33:58 +08:00
//this.goSign();
StartScrollPanel ( 2 ) ;
}
}
else
{
Utils . showToast ( gameObject , r . errMsg ) ;
}
}
2021-04-06 15:30:36 +08:00
private void goThirdNext ( )
{
this . StartScrollPanel ( 4 ) ;
2021-03-30 14:14:24 +08:00
}
2021-04-01 11:01:05 +08:00
2021-04-06 15:30:36 +08:00
private void goThirdPrev ( )
{
this . StartScrollPanel ( 2 ) ;
}
private void OnDestroy ( )
{
}
2021-09-09 16:29:22 +08:00
#region 倒 计 时 获 取 验 证 码
2021-04-06 15:30:36 +08:00
int time = 0 ;
float timer = 0f ;
bool startCaptcha = false ;
async void GetCaptcha ( )
{
var btn = signPage1 . Find ( "Captcha" ) . Find ( "BtnGet" ) ;
2021-05-20 14:12:43 +08:00
btn . GetComponent < Button > ( ) . enabled = false ;
btn . GetComponent < Button > ( ) . interactable = false ;
2021-04-06 15:30:36 +08:00
var btnText = signPage1 . Find ( "Captcha" ) . Find ( "BtnGet" ) . Find ( "Text" ) . GetComponent < Text > ( ) ;
2021-04-21 16:16:14 +08:00
var Email = signForm . email ;
2021-04-06 15:30:36 +08:00
var r = await ConfigHelper . userApi . GetCaptcha ( Email . text ) ;
//Timer t = new Ti
if ( r . result )
{
2021-10-14 14:04:44 +08:00
if ( pageNums = = 5 )
2021-04-09 15:57:50 +08:00
{
2021-10-14 14:04:44 +08:00
if ( r . data . Value < bool > ( "isExist" ) )
{
HidePassword ( ) ;
}
else
{
ShowPassword ( true ) ;
}
2021-04-09 15:57:50 +08:00
}
2021-04-06 15:30:36 +08:00
time = 60 ;
btnText . text = $"Again({time})" ;
System . Timers . Timer timer = new System . Timers . Timer ( ) ;
btn . GetComponent < Button > ( ) . enabled = false ;
2021-04-21 16:16:14 +08:00
btn . GetComponent < Button > ( ) . interactable = false ;
2021-04-06 15:30:36 +08:00
startCaptcha = true ;
//timer.Interval = 1000;
//timer.AutoReset = true;
//timer.Elapsed += new ElapsedEventHandler(CaptchaTimerTick);
//timer.Enabled = true;
//btnGet.
}
2021-04-21 16:16:14 +08:00
else
2021-04-06 15:30:36 +08:00
{
2021-05-20 14:12:43 +08:00
btn . GetComponent < Button > ( ) . enabled = true ;
btn . GetComponent < Button > ( ) . interactable = true ;
2021-04-06 15:30:36 +08:00
Utils . showToast ( gameObject , r . errMsg ) ;
2021-05-20 14:12:43 +08:00
Utils . SetValidate ( signFormDict , r . errFieldMsg ) ;
2021-04-06 15:30:36 +08:00
}
}
2021-09-09 16:29:22 +08:00
#endregion
2021-08-25 10:29:03 +08:00
2021-04-21 16:16:14 +08:00
void CaptchaTimerTick ( )
2021-04-06 15:30:36 +08:00
{
timer - = Time . deltaTime ;
if ( timer < = 0 )
{
var btn = signPage1 . Find ( "Captcha" ) . Find ( "BtnGet" ) ;
var btnText = signPage1 . Find ( "Captcha" ) . Find ( "BtnGet" ) . Find ( "Text" ) . GetComponent < Text > ( ) ;
btnText . text = $"Again({time--})" ;
if ( time < 0 )
{
btnText . text = "Get" ;
btn . GetComponent < Button > ( ) . enabled = true ;
2021-04-21 16:16:14 +08:00
btn . GetComponent < Button > ( ) . interactable = true ;
2021-04-06 15:30:36 +08:00
startCaptcha = false ;
//timer.Stop();
}
timer = 1.0f ;
}
}
2021-04-21 16:16:14 +08:00
2021-04-01 11:01:05 +08:00
private void goRegPrev ( )
{
2021-04-23 15:36:18 +08:00
signForm . email . text = "" ;
signForm . password . text = "" ;
signForm . captcha . text = "" ;
signForm . cpassword . text = "" ;
2021-04-01 11:01:05 +08:00
StartScrollSign ( 0 ) ;
}
2021-04-06 15:30:36 +08:00
//0-普通 1-微信
private async void goRegNext ( int signType = 0 )
2021-04-01 11:01:05 +08:00
{
2021-04-06 15:30:36 +08:00
var Email = signForm . email ;
var Captcha = signForm . captcha ;
var Password = signForm . password ;
var CPassword = signForm . cpassword ;
2021-04-21 16:16:14 +08:00
if ( Password . text ! = CPassword . text )
2021-04-09 15:57:50 +08:00
{
2021-04-29 11:36:30 +08:00
Utils . SetValidate ( signFormDict , JArray . FromObject ( new object [ ]
{
new { Field = "Pwd" } ,
new { Field = "CPwd" } ,
} ) ) ;
2021-04-28 15:21:06 +08:00
Utils . showToast ( gameObject , "Two password entries are inconsistent" ) ; //两次密码输入不一致
2021-04-09 15:57:50 +08:00
return ;
}
2021-04-06 15:30:36 +08:00
//JsonConvert
2021-04-21 16:16:14 +08:00
JsonResult < object > r = null ;
2021-04-06 15:30:36 +08:00
if ( signType = = 0 )
{
r = await ConfigHelper . userApi . Register ( Email . text , Password . text , Captcha . text ) ;
}
else if ( signType = = 1 )
{
r = await ConfigHelper . userApi . OnWebWxLogin ( Email . text ,
Captcha . text ,
2021-06-07 13:51:13 +08:00
Password . text ,
wxInfoJson . Value < string > ( "unionId" ) ,
wxInfoJson . Value < string > ( "openId" ) ) ;
2021-04-06 15:30:36 +08:00
}
2021-04-21 16:16:14 +08:00
if ( r ! = null & & r . result )
2021-04-06 15:30:36 +08:00
{
2021-04-21 16:16:14 +08:00
var u = JObject . FromObject ( r . data ) . ToObject < UserResultModel > ( ) ;
2021-04-28 18:41:54 +08:00
RefreshWx3 ( u , signType ) ;
2021-04-16 17:49:11 +08:00
LoadInfo ( ) ;
2021-04-06 15:30:36 +08:00
StartScrollSign ( 1 ) ;
}
2021-04-21 16:16:14 +08:00
else
2021-04-06 15:30:36 +08:00
{
2021-04-21 16:16:14 +08:00
var errorList = JArray . FromObject ( r . data ) ;
2021-04-23 15:36:18 +08:00
Utils . SetValidate ( signFormDict , errorList ) ;
2021-04-29 11:36:30 +08:00
Utils . showToast ( gameObject , r . errMsg ) ;
2021-04-09 15:57:50 +08:00
}
}
2021-08-25 10:29:03 +08:00
2021-04-09 15:57:50 +08:00
async void goRegNextWithoutPass ( )
{
var Email = signForm . email ;
var Captcha = signForm . captcha ;
var r = await ConfigHelper . userApi . OnWebWxLogin ( Email . text ,
Captcha . text ,
2021-06-07 13:51:13 +08:00
"" ,
wxInfoJson . Value < string > ( "unionId" ) ,
wxInfoJson . Value < string > ( "openId" ) ) ;
2021-04-09 15:57:50 +08:00
if ( r . result )
{
2021-04-21 16:16:14 +08:00
var u = JObject . FromObject ( r . data ) . ToObject < UserResultModel > ( ) ;
2021-08-25 10:29:03 +08:00
RefreshWx3 ( u , 1 ) ;
2021-10-14 14:04:44 +08:00
MobileAni ( true ) ;
2021-04-09 15:57:50 +08:00
StartScrollPanel ( 4 ) ;
2021-04-06 15:30:36 +08:00
}
2021-04-09 15:57:50 +08:00
else
{
Utils . showToast ( gameObject , r . errMsg ) ;
}
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 重置密码逻辑
/// </summary>
2021-08-25 10:29:03 +08:00
async void goResetPassword ( )
2021-04-26 16:25:52 +08:00
{
var Email = signForm . email ;
var Captcha = signForm . captcha ;
var Password = signForm . password ;
var CPassword = signForm . cpassword ;
if ( Password . text ! = CPassword . text )
{
2021-04-29 11:36:30 +08:00
Utils . SetValidate ( signFormDict , JArray . FromObject ( new object [ ]
{
new { Field = "Pwd" } ,
new { Field = "CPwd" } ,
} ) ) ;
2021-04-28 15:21:06 +08:00
Utils . showToast ( gameObject , "Two password entries are inconsistent" ) ; //两次密码输入不一致
2021-04-26 16:25:52 +08:00
return ;
}
var r = await ConfigHelper . userApi . ResetPassword ( Email . text , Captcha . text , Password . text ) ;
if ( r . result )
{
2021-08-25 10:29:03 +08:00
Utils . showToast ( gameObject , "Success" , type : 1 ) ;
2021-04-26 16:25:52 +08:00
goLoginReturn2 ( ) ;
}
2021-08-25 10:29:03 +08:00
else
2021-04-26 16:25:52 +08:00
{
Utils . showToast ( gameObject , r . errMsg ) ;
}
}
2021-08-25 10:29:03 +08:00
void RefreshWx3 ( UserResultModel data , int type )
2021-04-09 15:57:50 +08:00
{
2021-05-20 20:00:33 +08:00
Utils . DisplayHead ( wxLogin3 . Find ( "Avatar" ) . GetComponent < RawImage > ( ) ,
2021-04-09 15:57:50 +08:00
data . WxHeadImg ) ;
2021-04-28 18:41:54 +08:00
wxLogin3 . Find ( "Wx" ) . gameObject . SetActive ( type = = 1 ) ;
2021-04-09 15:57:50 +08:00
wxLogin3 . Find ( "NickName" ) . GetComponent < Text > ( ) . text = data . Nickname ;
userResult = data ;
2021-07-30 20:44:45 +08:00
App . CurrentUser = data ;
2021-04-06 15:30:36 +08:00
}
2021-10-15 09:54:23 +08:00
2021-10-14 14:04:44 +08:00
void MobileAni ( bool flag )
{
2021-10-15 09:54:23 +08:00
#if UNITY_ANDROID | | UNITY_IOS
2021-10-14 14:04:44 +08:00
if ( flag )
{
//顯示pf
imagedf . GetComponent < Image > ( ) . DOFade ( 1 , 0.3f ) ;
imagexf . GetComponent < Image > ( ) . DOFade ( 1 , 0.3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOSizeDelta ( new Vector2 ( 354 , 300 ) , 0.3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOLocalMoveY ( - 35 , 0.3f ) ;
}
else
{
imagedf . GetComponent < Image > ( ) . DOFade ( 0 , . 3f ) ;
imagexf . GetComponent < Image > ( ) . DOFade ( 0 , . 3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOSizeDelta ( new Vector2 ( 354 , 370 ) , . 3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOLocalMoveY ( 0 , . 3f ) ;
}
#endif
2021-10-15 09:54:23 +08:00
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 去最后一页准备进入主场景
/// </summary>
2021-05-12 10:42:26 +08:00
void goRegEnd ( )
2021-04-06 15:30:36 +08:00
{
2021-05-12 10:42:26 +08:00
if ( ! UpdateInfo ( ) ) return ;
2021-08-24 17:50:14 +08:00
#if UNITY_ANDROID | | UNITY_IOS
2021-10-14 14:04:44 +08:00
MobileAni ( true ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-04-21 16:16:14 +08:00
if ( pageNums = = 5 )
2021-04-06 15:30:36 +08:00
{
this . StartScrollPanel ( 4 ) ;
}
2021-04-16 17:49:11 +08:00
else
{
2021-04-19 15:44:11 +08:00
this . StartScrollPanel ( 3 ) ;
2021-04-16 17:49:11 +08:00
}
2021-04-06 15:30:36 +08:00
//throw new NotImplementedException();
2021-04-01 11:01:05 +08:00
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 加载信息
/// </summary>
2021-04-21 16:16:14 +08:00
void LoadInfo ( )
2021-04-16 17:49:11 +08:00
{
var _days = signForm . days . GetComponent < PFUIDropdown > ( ) ;
var _months = signForm . months . GetComponent < PFUIDropdown > ( ) ;
var _years = signForm . years . GetComponent < PFUIDropdown > ( ) ;
2021-04-01 11:01:05 +08:00
2021-04-16 17:49:11 +08:00
var _genders = signForm . genders . GetComponent < PFUIDropdown > ( ) ;
var _countrys = signForm . countrys . GetComponent < PFUIDropdown > ( ) ;
var _units = signForm . units . GetComponent < PFUIDropdown > ( ) ;
var _weight = signForm . weight . GetComponent < PFUIInputField > ( ) ;
var _height = signForm . height . GetComponent < PFUIInputField > ( ) ;
if ( userResult . Birthday . HasValue )
{
_days . SelectValue ( userResult . Birthday . Value . Day . ToString ( ) ) ;
_months . SelectValue ( userResult . Birthday . Value . Month . ToString ( ) ) ;
_years . SelectValue ( userResult . Birthday . Value . Year . ToString ( ) ) ;
}
2021-04-21 16:16:14 +08:00
_genders . SelectIndex ( userResult . Sex - 1 ) ;
2021-04-16 17:49:11 +08:00
_countrys . SelectIndex ( UIManager . Instance . loginRegOptions . GetCountryIndexByName ( userResult . Country ) ) ;
_units . SelectIndex ( userResult . Unit ) ;
_weight . Text = userResult . Weight . ToString ( ) ;
_height . Text = userResult . Height . ToString ( ) ;
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 注册页2 修改信息
/// </summary>
/// <returns></returns>
2021-08-25 10:29:03 +08:00
bool UpdateInfo ( )
2021-04-16 17:49:11 +08:00
{
if ( userResult = = null ) return false ;
var _days = signForm . days . GetComponent < PFUIDropdown > ( ) ;
var _months = signForm . months . GetComponent < PFUIDropdown > ( ) ;
var _years = signForm . years . GetComponent < PFUIDropdown > ( ) ;
var _genders = signForm . genders . GetComponent < PFUIDropdown > ( ) ;
var _countrys = signForm . countrys . GetComponent < PFUIDropdown > ( ) ;
var _units = signForm . units . GetComponent < PFUIDropdown > ( ) ;
var _weight = signForm . weight . GetComponent < PFUIInputField > ( ) ;
var _height = signForm . height . GetComponent < PFUIInputField > ( ) ;
2021-04-21 16:16:14 +08:00
if ( signForm . years . value ! = - 1 & & signForm . months . value ! = - 1 & & signForm . days . value ! = - 1 )
2021-04-16 17:49:11 +08:00
{
userResult . Birthday = new DateTime ( int . Parse ( _years . SelectedItem ) , int . Parse ( _months . SelectedItem ) , int . Parse ( _days . SelectedItem ) ) ;
}
2021-08-25 10:29:03 +08:00
else
2021-04-21 16:16:14 +08:00
{
2021-08-25 10:29:03 +08:00
Utils . SetValidate ( signFormDict , JArray . FromObject ( new object [ ]
2021-04-26 16:25:52 +08:00
{
new { Field = "Years" , ErrMsg = "" } ,
new { Field = "Months" , ErrMsg = "" } ,
new { Field = "Days" , ErrMsg = "" }
} ) ) ;
2021-04-28 15:21:06 +08:00
Utils . showToast ( gameObject , "Please select birthday" ) ; //请选择生日
2021-04-21 16:16:14 +08:00
return false ;
}
2021-04-16 17:49:11 +08:00
userResult . Sex = _genders . SelectedIndex + 1 ;
userResult . Country = UIManager . Instance . loginRegOptions . GetCountryName ( _countrys . SelectedIndex ) ;
userResult . Unit = _units . SelectedIndex ;
2021-04-30 21:09:21 +08:00
userResult . Weight = double . Parse ( _weight . Text ) ;
2021-04-16 17:49:11 +08:00
userResult . Height = int . Parse ( _height . Text ) ;
2021-04-21 16:16:14 +08:00
if ( string . IsNullOrEmpty ( userResult . Nickname ) )
2021-04-19 15:44:11 +08:00
{
userResult . Nickname = userResult . Phone ;
}
2021-08-25 10:29:03 +08:00
var r = ConfigHelper . userApi . Update ( userResult , out string cookie , "" ) ;
2021-04-16 17:49:11 +08:00
return r . result ;
//userResult.Birthday.v
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 微信2/注册返回登录
/// </summary>
2021-04-01 11:01:05 +08:00
private void goLoginReturn2 ( )
{
2021-08-24 17:50:14 +08:00
#if UNITY_ANDROID | | UNITY_IOS
2021-10-14 14:04:44 +08:00
MobileAni ( true ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-04-06 15:30:36 +08:00
if ( wxLogin2 . gameObject . activeSelf ) wxLogin2 . gameObject . SetActive ( false ) ;
2021-04-19 15:44:11 +08:00
//if (wxLogin3.gameObject.activeSelf) wxLogin3.gameObject.SetActive(false);
pageNums = 4 ;
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-05-20 14:12:43 +08:00
if ( wxLogin1 . transform . localPosition . y = = 0 )
{
wxReturnLogin ( ) ;
}
2021-08-24 17:50:14 +08:00
#else
transform . GetComponent < LoginControllerMobile > ( ) . HideThirdLoginPage ( ) ;
#endif
2021-04-06 15:30:36 +08:00
Canvas . ForceUpdateCanvases ( ) ;
2021-04-01 11:01:05 +08:00
this . StartScrollPanel ( 1 ) ;
}
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-05-20 14:12:43 +08:00
void wxReturnLogin ( )
{
wxLock = true ;
wxBrowser . LoadHTML ( "<div/>" ) ;
//wxBrowser.Url = "chrome://version/";
wxLogin1 . DOLocalMoveY ( - 573 , 0.3f ) . onComplete = ( ) = >
{
wxLock = false ;
wxLogin1 . gameObject . SetActive ( false ) ;
} ;
}
2021-08-24 17:50:14 +08:00
#endif
2021-04-26 16:25:52 +08:00
/// <summary>
/// 立刻跳到登录页并且返回按钮强行失效
/// </summary>
2021-08-25 10:29:03 +08:00
private void goLoginImmediately ( )
2021-04-26 16:25:52 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-26 16:25:52 +08:00
imagedf . localPosition = new Vector3 ( - 580 , - 34 , 0 ) ;
imagexf . localPosition = new Vector3 ( 0 , - 669 , 0 ) ;
LoginBg . localPosition = Vector3 . zero ;
LoginBg . GetComponent < RectTransform > ( ) . sizeDelta = new Vector2 ( 360 , 573 ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-04-26 16:25:52 +08:00
var scrollValue = 1f / ( pageNums - 1 ) ;
var value = 1 * scrollValue ;
scrollPanel . horizontalNormalizedPosition = value ;
loginContainer . Find ( "returnQuick" ) . GetComponent < Button > ( ) . gameObject . SetActive ( false ) ;
}
/// <summary>
/// 返回快速登录页
/// </summary>
2021-04-21 16:16:14 +08:00
void ReturnQuick ( )
2021-03-30 14:14:24 +08:00
{
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-03-30 14:14:24 +08:00
if ( imagexf ! = null )
{
2021-04-16 17:49:11 +08:00
imagexf . DOLocalMoveY ( - 575 , 0.3f ) ;
}
if ( imagedf ! = null )
{
imagedf . DOLocalMoveY ( - 128 , 0.3f ) ;
2021-03-30 14:14:24 +08:00
}
2021-04-21 16:16:14 +08:00
if ( LoginBg ! = null )
{
LoginBg . GetComponent < RectTransform > ( ) . DOSizeDelta ( new Vector2 ( 360 , 385 ) , 0.3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOLocalMoveY ( - 94 , 0.3f ) ;
}
2021-08-24 17:50:14 +08:00
#endif
2021-03-30 14:14:24 +08:00
this . StartScrollPanel ( 0 ) ;
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 去登录页
/// </summary>
/// <param name="noReturn"></param>
2021-04-21 16:16:14 +08:00
public void goLogin ( bool noReturn = false )
2021-03-30 14:14:24 +08:00
{
2021-08-23 09:28:14 +08:00
#if ! ( UNITY_IOS | | UNITY_ANDROID )
2021-04-21 16:16:14 +08:00
if ( imagexf ! = null )
2021-03-30 14:14:24 +08:00
{
2021-04-16 17:49:11 +08:00
imagexf . DOLocalMoveY ( - 669 , 0.3f ) ;
}
if ( imagedf ! = null )
{
imagedf . DOLocalMoveY ( - 34 , 0.3f ) ;
2021-03-30 14:14:24 +08:00
}
2021-04-21 16:16:14 +08:00
if ( LoginBg ! = null )
{
LoginBg . GetComponent < RectTransform > ( ) . DOSizeDelta ( new Vector2 ( 360 , 573 ) , 0.3f ) ;
LoginBg . GetComponent < RectTransform > ( ) . DOLocalMoveY ( 0 , 0.3f ) ;
}
2021-08-23 09:28:14 +08:00
#endif
2021-04-21 16:16:14 +08:00
//DOTween.To(() => o, x => o = x, t, 0.3f);
2021-03-30 14:14:24 +08:00
this . StartScrollPanel ( 1 ) ;
2021-04-26 16:25:52 +08:00
if ( noReturn )
2021-04-21 16:16:14 +08:00
{
loginContainer . Find ( "returnQuick" ) . GetComponent < Button > ( ) . gameObject . SetActive ( false ) ;
}
}
2021-04-26 16:25:52 +08:00
void HidePassword ( )
2021-04-21 16:16:14 +08:00
{
2021-04-26 16:25:52 +08:00
signPage1 . Find ( "Password" ) . gameObject . SetActive ( false ) ;
signPage1 . Find ( "CPassword" ) . gameObject . SetActive ( false ) ;
UIManager . RemoveEvent ( signPage1 . Find ( "signThird" ) . gameObject ) ;
UIManager . AddEvent ( signPage1 . Find ( "signThird" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
goRegNextWithoutPass ( ) ;
} ) ;
//signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(goRegNextWithoutPass);
}
2021-10-14 14:04:44 +08:00
void ShowPassword ( bool ignoreEmail = false )
2021-04-26 16:25:52 +08:00
{
2021-10-14 14:04:44 +08:00
if ( ! ignoreEmail )
{
signForm . email . text = "" ;
}
2021-04-26 16:25:52 +08:00
signForm . password . text = "" ;
signForm . captcha . text = "" ;
signForm . cpassword . text = "" ;
signPage1 . Find ( "Password" ) . gameObject . SetActive ( true ) ;
signPage1 . Find ( "CPassword" ) . gameObject . SetActive ( true ) ;
UIManager . RemoveEvent ( signPage1 . Find ( "signThird" ) . gameObject ) ;
UIManager . AddEvent ( signPage1 . Find ( "signThird" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
goRegNext ( 1 ) ;
} ) ;
//signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { ; });
2021-03-30 14:14:24 +08:00
}
2021-04-26 16:25:52 +08:00
/// <summary>
///
/// </summary>
/// <param name="isAccount"></param>
/// <param name="type">0 注册 1 忘记密码</param>
2021-08-25 10:29:03 +08:00
void goSign ( bool isAccount = true , int type = 0 )
2021-03-30 14:14:24 +08:00
{
2021-08-24 17:50:14 +08:00
#if UNITY_ANDROID | | UNITY_IOS
2021-10-14 14:04:44 +08:00
MobileAni ( false ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-04-06 15:30:36 +08:00
if ( ! isAccount )
{
pageNums = 5 ;
//wxLogin2.gameObject.SetActive(false);
signPage1 . Find ( "next" ) . gameObject . SetActive ( false ) ;
2021-04-26 16:25:52 +08:00
signPage1 . Find ( "BtnModiPass" ) . gameObject . SetActive ( false ) ;
2021-10-13 19:03:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-06 15:30:36 +08:00
signPage1 . Find ( "previousThird" ) . gameObject . SetActive ( true ) ;
2021-10-13 19:03:14 +08:00
#endif
2021-04-06 15:30:36 +08:00
signPage1 . Find ( "signThird" ) . gameObject . SetActive ( true ) ;
2021-04-09 15:57:50 +08:00
ShowPassword ( ) ;
2021-04-06 15:30:36 +08:00
this . StartScrollPanel ( 3 ) ;
this . StartScrollSign ( 0 ) ;
}
2021-08-25 10:29:03 +08:00
else
2021-04-06 15:30:36 +08:00
{
2021-04-26 16:25:52 +08:00
if ( type = = 0 )
{
pageNums = 4 ;
signContainer . Find ( "signText" ) . GetComponent < Text > ( ) . text = "SIGN UP" ;
wxLogin2 . gameObject . SetActive ( false ) ;
signPage1 . Find ( "next" ) . gameObject . SetActive ( true ) ;
signPage1 . Find ( "BtnModiPass" ) . gameObject . SetActive ( false ) ;
signPage1 . Find ( "previousThird" ) . gameObject . SetActive ( false ) ;
signPage1 . Find ( "signThird" ) . gameObject . SetActive ( false ) ;
ShowPassword ( ) ;
this . StartScrollPanel ( 2 ) ;
this . StartScrollSign ( 0 ) ;
}
2021-08-25 10:29:03 +08:00
else
2021-04-26 16:25:52 +08:00
{
pageNums = 4 ;
signContainer . Find ( "signText" ) . GetComponent < Text > ( ) . text = "RESET PASSWORD" ;
wxLogin2 . gameObject . SetActive ( false ) ;
signPage1 . Find ( "next" ) . gameObject . SetActive ( false ) ;
signPage1 . Find ( "BtnModiPass" ) . gameObject . SetActive ( true ) ;
signPage1 . Find ( "previousThird" ) . gameObject . SetActive ( false ) ;
signPage1 . Find ( "signThird" ) . gameObject . SetActive ( false ) ;
ShowPassword ( ) ;
this . StartScrollPanel ( 2 ) ;
this . StartScrollSign ( 0 ) ;
}
2021-04-06 15:30:36 +08:00
}
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 登录/注册完成,去首页
/// </summary>
/// <param name="gou"></param>
2021-08-25 10:29:03 +08:00
void goMain ( Transform gou )
2021-04-06 15:30:36 +08:00
{
2021-09-13 18:21:43 +08:00
#if ( UNITY_ANDROID | | UNITY_IOS )
StartCoroutine ( "Loading" ) ;
#endif
2021-04-06 15:30:36 +08:00
var data = userResult ;
if ( data = = null ) return ;
//ConfigHelper.CurrentUser = res.data;
2021-04-15 15:58:37 +08:00
if ( gou ! = null & & gou . gameObject . activeSelf )
2021-04-16 17:49:11 +08:00
{
SaveInfo ( data ) ;
//PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
}
2021-08-25 10:29:03 +08:00
else
2021-04-06 15:30:36 +08:00
{
2021-04-15 15:58:37 +08:00
var u = userInfos . Find ( x = > x . Id = = data . Id ) ;
2021-08-25 10:29:03 +08:00
if ( u ! = null )
2021-04-06 15:30:36 +08:00
{
2021-04-16 17:49:11 +08:00
userInfos . Remove ( u ) ;
2021-04-15 15:58:37 +08:00
}
2021-04-16 17:49:11 +08:00
UIManager . Instance . userInfos = userInfos ;
2021-04-21 11:19:31 +08:00
UIManager . Instance . userInfoIndex = 0 ;
2021-04-06 15:30:36 +08:00
}
2021-04-09 15:57:50 +08:00
App . CurrentUser = data ;
2021-07-16 18:37:02 +08:00
App . RideSetting . Sensitivity = data . Sensitivity ;
2021-07-23 18:07:12 +08:00
//查询我参加的比赛
2021-09-13 18:21:43 +08:00
Task . Run ( ( ) = >
{
UIManager . UpdateJoinCompetition ( ) ;
} ) ;
//SceneManager.LoadSceneAsync("MainScene");
StartCoroutine ( "LoadMain" ) ;
}
private IEnumerator Loading ( )
{
yield return null ;
DontDestroyOnLoad ( loadingPanel ) ;
Utils . showLoadingExtension ( loadingPanel ) ;
}
private IEnumerator LoadMain ( )
{
yield return new WaitForSeconds ( 1f ) ;
SceneManager . LoadSceneAsync ( "MainScene" ) . completed + = QuickLoginUser_completed ;
}
private void QuickLoginUser_completed ( AsyncOperation obj )
{
//Utils.hideLoadingExtension(loadingPanel);
2021-03-25 16:55:36 +08:00
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 缓存打钩的用户信息
/// </summary>
/// <param name="data"></param>
2021-08-25 10:29:03 +08:00
public void SaveInfo ( UserResultModel data )
2021-04-16 17:49:11 +08:00
{
2021-04-21 11:19:31 +08:00
var index = userInfos . FindIndex ( x = > x . Id = = data . Id ) ;
if ( index = = - 1 )
2021-04-16 17:49:11 +08:00
{
userInfos . Add ( new QUserInfo
{
Id = data . Id ,
NickName = data . Nickname ,
Avatar = data . WxHeadImg ,
2021-04-21 16:16:14 +08:00
Cookie = data . cookie ,
Phone = data . Phone
2021-04-16 17:49:11 +08:00
} ) ;
2021-04-21 11:19:31 +08:00
index = userInfos . Count - 1 ;
2021-04-16 17:49:11 +08:00
}
else
{
2021-04-21 11:19:31 +08:00
var u = userInfos [ index ] ;
u . Id = data . Id ;
u . NickName = data . Nickname ;
u . Avatar = data . WxHeadImg ;
u . Cookie = data . cookie ;
2021-04-21 16:16:14 +08:00
u . Phone = data . Phone ;
2021-04-21 11:19:31 +08:00
//userInfos.Insert(0, new QUserInfo
//{
// Id = data.Id,
// NickName = data.Nickname,
// Avatar = data.WxHeadImg,
// Cookie = data.cookie
//});
//userInfos.Remove(u);
2021-04-16 17:49:11 +08:00
}
UIManager . Instance . userInfos = userInfos ;
2021-04-21 11:19:31 +08:00
UIManager . Instance . userInfoIndex = index ;
2021-04-16 17:49:11 +08:00
}
2021-04-26 16:25:52 +08:00
/// <summary>
/// 登录提交
/// </summary>
2021-08-25 10:29:03 +08:00
async void Submit ( )
2021-03-25 16:55:36 +08:00
{
2021-04-21 16:16:14 +08:00
var res = await ConfigHelper . userApi . LoginV1 ( loginForm . email . text , loginForm . password . text , "" ) ;
2021-03-25 16:55:36 +08:00
//var res = await NoAuthApi.Login(phone.text, pwd.text);
if ( res . result )
{
2021-04-21 16:16:14 +08:00
userResult = JObject . FromObject ( res . data ) . ToObject < UserResultModel > ( ) ;
2021-04-06 15:30:36 +08:00
goMain ( remember . transform . Find ( "Gou" ) ) ;
2021-03-25 16:55:36 +08:00
}
2021-08-25 10:29:03 +08:00
else
2021-03-25 16:55:36 +08:00
{
2021-08-25 10:29:03 +08:00
if ( res . data ! = null )
2021-04-23 15:36:18 +08:00
{
var errorList = JArray . FromObject ( res . data ) ;
Utils . SetValidate ( formDict , errorList ) ;
}
2021-04-16 17:49:11 +08:00
Utils . showToast ( gameObject , res . errMsg ) ;
2021-03-25 16:55:36 +08:00
}
}
2021-11-09 11:37:10 +08:00
2021-03-25 16:55:36 +08:00
// Update is called once per frame
2021-11-09 11:37:10 +08:00
protected override void Update ( )
2021-03-25 16:55:36 +08:00
{
2021-11-09 11:37:10 +08:00
base . Update ( ) ;
2021-04-01 11:01:05 +08:00
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
2021-05-20 14:12:43 +08:00
if ( Input . GetKeyDown ( KeyCode . Tab ) )
2021-03-25 16:55:36 +08:00
{
2021-08-25 10:29:03 +08:00
if ( loginForm ! = null & & loginForm . email . isFocused & & loginForm . password ! = null )
2021-05-20 14:12:43 +08:00
{
loginForm . password . ActivateInputField ( ) ;
}
2021-08-25 10:29:03 +08:00
if ( signForm ! = null )
2021-05-20 14:12:43 +08:00
{
2021-08-25 10:29:03 +08:00
if ( signForm . email . isFocused )
2021-05-20 14:12:43 +08:00
{
signForm . captcha . ActivateInputField ( ) ;
}
if ( signForm . captcha . isFocused )
{
signForm . password . ActivateInputField ( ) ;
}
if ( signForm . password . isFocused )
{
signForm . cpassword . ActivateInputField ( ) ;
}
if ( signForm . cpassword . isFocused )
{
signForm . email . ActivateInputField ( ) ;
}
}
2021-03-25 16:55:36 +08:00
}
2021-08-25 10:29:03 +08:00
if ( Input . GetKeyDown ( KeyCode . KeypadEnter ) | | Input . GetKeyDown ( KeyCode . Return ) )
2021-04-21 11:19:31 +08:00
{
2021-04-25 15:33:17 +08:00
if ( loginForm ! = null & & ! string . IsNullOrEmpty ( loginForm . email . text ) & & ! string . IsNullOrEmpty ( loginForm . password . text ) )
2021-04-21 11:19:31 +08:00
{
Submit ( ) ;
}
}
2021-08-25 10:29:03 +08:00
if ( startCaptcha )
2021-04-06 15:30:36 +08:00
{
CaptchaTimerTick ( ) ;
}
2021-08-25 10:29:03 +08:00
2021-04-30 10:32:01 +08:00
//if (wxLogin1.gameObject.activeInHierarchy)
//{
// adjTime += Time.deltaTime;
// if (adjTime >= 0.5 && wxLogin1.gameObject.activeInHierarchy && startJs)
// {
// Debug.Log("在调整");
// adjTime = 0;
// AdjustWxQrCode();
// }
//}
2021-03-25 16:55:36 +08:00
}
2021-08-24 17:50:14 +08:00
private void FixedUpdate ( )
{
goScrollPanel ( ) ;
goScrollSign ( ) ;
}
2021-04-30 10:32:01 +08:00
//float adjTime = 0;
//bool startJs = false;
2021-09-09 16:29:22 +08:00
#region 主 页 面 滑 动 逻 辑
2021-03-30 14:14:24 +08:00
private int tmpImdex = 0 ;
private int scrollPanelIndex = 2 ;
2021-04-01 11:01:05 +08:00
//private float scrollValue = 0.5f;
2021-03-30 14:14:24 +08:00
private bool startScrollPanel = false ;
private void StartScrollPanel ( int index )
{
if ( startScrollPanel ) return ;
scrollPanelIndex = index ;
startScrollPanel = true ;
}
2021-04-19 15:44:11 +08:00
private int pageNums = 4 ;
2021-03-30 14:14:24 +08:00
private void goScrollPanel ( )
{
var index = scrollPanelIndex ;
2021-08-25 10:29:03 +08:00
var scrollValue = 1f / ( pageNums - 1 ) ;
2021-03-30 14:14:24 +08:00
var value = index * scrollValue ;
2021-08-25 10:29:03 +08:00
if ( scrollPanel ! = null & & startScrollPanel )
2021-03-30 14:14:24 +08:00
{
if ( scrollPanel . horizontalNormalizedPosition > = value )
{
2021-08-24 17:50:14 +08:00
scrollPanel . horizontalNormalizedPosition - = ( scrollValue / 10 ) ;
2021-08-25 10:29:03 +08:00
if ( scrollPanel . horizontalNormalizedPosition < = value )
2021-03-30 14:14:24 +08:00
{
scrollPanel . horizontalNormalizedPosition = value ;
startScrollPanel = false ;
}
}
2021-08-25 10:29:03 +08:00
else
2021-03-30 14:14:24 +08:00
{
2021-08-24 17:50:14 +08:00
scrollPanel . horizontalNormalizedPosition + = ( scrollValue / 10 ) ;
2021-03-30 14:14:24 +08:00
if ( scrollPanel . horizontalNormalizedPosition > = value )
{
scrollPanel . horizontalNormalizedPosition = value ;
startScrollPanel = false ;
}
}
}
}
2021-09-09 16:29:22 +08:00
#endregion
2021-08-25 10:29:03 +08:00
2021-09-09 16:29:22 +08:00
#region 注 册 页 面 滑 动 逻 辑
2021-03-30 14:14:24 +08:00
private bool startScrollSign = false ;
private int scrollSignIndex = 0 ;
2021-04-06 15:30:36 +08:00
2021-08-25 10:29:03 +08:00
2021-04-01 11:01:05 +08:00
private void StartScrollSign ( int index )
{
if ( startScrollSign ) return ;
scrollSignIndex = index ;
startScrollSign = true ;
2021-04-06 15:30:36 +08:00
Debug . Log ( $"{index},{index * 160}" ) ;
2021-08-25 10:29:03 +08:00
if ( index = = 1 )
2021-04-06 15:30:36 +08:00
{
2021-08-25 10:29:03 +08:00
if ( signForm . years . value ! = - 1 ) signForm . years . value = 0 ;
2021-04-06 15:30:36 +08:00
if ( signForm . months . value ! = - 1 ) signForm . months . value = 0 ;
if ( signForm . days . value ! = - 1 ) signForm . days . value = 0 ;
if ( signForm . countrys . value ! = - 1 ) signForm . countrys . value = regOptions . countryDefaultValue ;
if ( signForm . genders . value ! = - 1 ) signForm . genders . value = 0 ;
if ( signForm . units . value ! = - 1 ) signForm . units . value = 0 ;
2021-08-25 10:29:03 +08:00
if ( pageNums = = 5 & & wxInfoJson ! = null )
2021-04-06 15:30:36 +08:00
{
var sex = wxInfoJson . Value < int > ( "sex" ) ;
2021-08-25 10:29:03 +08:00
if ( sex > 0 )
2021-04-06 15:30:36 +08:00
{
signForm . genders . value = sex - 1 ;
}
var country = wxInfoJson . Value < string > ( "country" ) ;
signForm . countrys . value = regOptions . GetCountryIndexByCode ( country ) ;
}
2021-04-16 17:49:11 +08:00
//if (string.IsNullOrEmpty(signForm.weight.text))
//{
// signForm.weight.text = "";
//}
//if (!string.IsNullOrEmpty(signForm.height.text))
//{
// signForm.height.text = "";
//}
2021-04-06 15:30:36 +08:00
}
2021-08-24 17:50:14 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
2021-04-06 15:30:36 +08:00
signScrollBar . DOLocalMoveX ( ( index - 1 ) * 160 , 0.2f ) ;
2021-08-24 17:50:14 +08:00
#endif
2021-04-01 11:01:05 +08:00
}
2021-03-30 14:14:24 +08:00
private void goScrollSign ( )
{
float value = scrollSignIndex ;
if ( scrollSign ! = null & & startScrollSign )
{
if ( scrollSignIndex = = 0 )
{
2021-08-24 17:50:14 +08:00
scrollSign . horizontalNormalizedPosition - = ( 1f / 10 ) ;
2021-03-30 14:14:24 +08:00
if ( scrollSign . horizontalNormalizedPosition < = 0 )
{
scrollSign . horizontalNormalizedPosition = 0 ;
startScrollSign = false ;
2021-08-25 10:29:03 +08:00
2021-03-30 14:14:24 +08:00
}
}
else if ( scrollSignIndex = = 1 )
{
2021-08-24 17:50:14 +08:00
scrollSign . horizontalNormalizedPosition + = ( 1f / 10 ) ;
2021-03-30 14:14:24 +08:00
if ( scrollSign . horizontalNormalizedPosition > = 1 )
{
scrollSign . horizontalNormalizedPosition = 1 ;
startScrollSign = false ;
}
}
}
}
2021-09-09 16:29:22 +08:00
#endregion
2021-03-25 16:55:36 +08:00
}