Merge remote-tracking branch 'origin/dev_mobile' into dev_mobile_ble

This commit is contained in:
lishuo committed 2021-08-25 11:22:23 +08:00
commit 92c8f246b8
81 files changed
+74001 -190

No files matched your search

+14 -9
View File
@@ -17,8 +17,13 @@ public static class App
public static int RouteIdParam = 0;
public static UserResultModel CurrentUser { get; set; }
public static string WxAppId = "wx9e8ca734e024f084";
#if !(UNITY_ANDROID || UNITY_IOS)
//pc版微信id
public static string WxAppId => "wx9e8ca734e024f084";
#else
//移动版微信id
public static string WxAppId => "wx9146e6697a6aef2d";
#endif
public static string MapBoxAccessToken => "pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA";
public static double latitude { get; internal set; }
@@ -68,16 +73,16 @@ public static class App
}
public static string CurrentScene { get; set; }//当前场景
public static WeChatController weChatController = new WeChatController();
static App()
{
#if !UNITY_EDITOR
Host = "http://pf.juze.pro/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
//Host = "https://wx.powerfun.com.cn/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
//Host = "http://pf.juze.pro/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
Host = "https://wx.powerfun.com.cn/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
#endif
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f2c27d8ea9a20894180ddf2895a82fed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,63 @@
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);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8bafb22521430b43985508b40e72fd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+174
View File
@@ -0,0 +1,174 @@
using System.Runtime.InteropServices;
using UnityEngine;
/// <summary>
/// Create By Jooki: https://www.yuque.com/jooki
/// 使用流程:
/// WeChatController是一个单例, 请自行给变量 _className 赋值
/// 使用前先调用 Init() 进行初始化,然后调用 IsWeChatAppInstalled() 检查用户设备上是否安装了微信;
/// 之后为保险起见调用 IsWeChatAppInstalled() 判断微信是否已经安装;
/// 最后就是按照需要分享的消息类型调用对应的方法
/// </summary>
public class WeChatController
{
#region iOS微信SDK
#if UNITY_IOS
[DllImport("__Internal")]
private static extern void RegisterApp(string appid);
[DllImport("__Internal")]
private static extern bool IsWechatInstalled_iOS();
[DllImport("__Internal")]
private static extern void WechatLogin(string scope,string state);
#endif
#endregion
/// <summary>
/// com.unityplugins.wechatshare是在Android Studio中创建的 Module,
/// MainActivity 是一个Activity, 对外供C#调用的方法都写在这个Activity内
/// </summary>
private readonly string _className = "com.unityplugins.wechatshare.MainActivity";
private string _APP_ID = "";
private AndroidJavaClass mainActivityClass = null;
private static WeChatController _instance;
public static WeChatController Instance
{
get
{
if (_instance == null)
{
_instance = new WeChatController();
}
return _instance;
}
}
/// <summary>
/// 初始化微信SDK, APPID是用户在微信开放平台注册是所分配的应用唯一标识, 可在微信开放平台找到
/// </summary>
/// <param name="APPID"></param>
public void Init(string APPID)
{
_APP_ID = APPID;
#if !UNITY_EDITOR && UNITY_ANDROID
mainActivityClass = new AndroidJavaClass(_className);
// 第一个参数: MainActivity中的方法名
// 第二、三个参数: 分别是SendMessageToUnity需要接收的第一和第二个参数,对比上面Java的代码
mainActivityClass.CallStatic("InitWeChat", Application.identifier, _APP_ID);
#endif
#if !UNITY_EDITOR && UNITY_IOS
RegisterApp(_APP_ID);
#endif
}
/// <summary>
/// 判断是否是否安装了微信
/// </summary>
/// <returns></returns>
public bool IsWeChatAppInstalled()
{
#if UNITY_ANDROID
return mainActivityClass.CallStatic<bool>("IsWeChatInstalled");
#elif UNITY_IOS
return IsWechatInstalled_iOS();
#endif
}
/// <summary>
/// 分享链接至微信,缩略图用的是APP Icon
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="url">网页链接</param>
/// <param name="title">标题</param>
/// <param name="description">描述</param>
public void ShareWebpageToWX(int scene, string url, string title, string description)
{
mainActivityClass.CallStatic("ShareWebpageToWX", scene, url, title, description);
}
/// <summary>
/// 分享文字至微信
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="text">要分享的文本内容</param>
public void ShareTextToWX(int scene, string text)
{
mainActivityClass.CallStatic("ShareTextToWX", scene, text);
}
/// <summary>
/// 分享图片至微信
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="image">要分享的图片</param>
public void ShareImageToWX(int scene, Texture2D image)
{
mainActivityClass.CallStatic("ShareImageToWX", scene, ImageToBytes(image));
}
/// <summary>
/// 分享音乐至微信
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="musicUrl">音乐的URL</param>
/// <param name="title">标题</param>
/// <param name="description">描述</param>
public void ShareMusicToWX(int scene, string musicUrl, string title, string description)
{
mainActivityClass.CallStatic("ShareMusicToWX", scene, musicUrl, title, description);
}
/// <summary>
/// 分享视频至微信
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="videoUrl">视频的URL</param>
/// <param name="title">标题</param>
/// <param name="description">描述</param>
public void ShareVideoToWX(int scene, string videoUrl, string title, string description)
{
mainActivityClass.CallStatic("ShareVideoToWX", scene, videoUrl, title, description);
}
/// <summary>
/// 分享小程序至微信
/// </summary>
/// <param name="scene">分享至什么场景, 0-对话、1-朋友圈、2-收藏</param>
/// <param name="lowVersionUrl">兼容低版本的网页链接</param>
/// <param name="miniProgramAPPID">小程序原始ID, 获取方法:登录小程序管理后台-设置-基本设置-帐号信息</param>
/// <param name="path">小程序页面路径;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"</param>
/// <param name="title">标题</param>
/// <param name="description">描述</param>
/// <param name="coverImg">分享封面图片</param>
public void ShareMinniProgramToWX(int scene, string lowVersionUrl, string miniProgramAPPID, string path,
string title, string description, Texture2D coverImg)
{
mainActivityClass.CallStatic("ShareMinniProgramToWX", scene, lowVersionUrl, miniProgramAPPID, path, title, description, ImageToBytes(coverImg));
}
public void WxLogin(string scope, string state)
{
#if UNITY_ANDROID
mainActivityClass.CallStatic("WxLogin", scope, state);
#elif UNITY_IOS
WechatLogin(scope, state);
#endif
}
public void SendMessageToUnity(string gameObjectName, string UnityMethodName)
{
mainActivityClass.CallStatic("SendMessageToUnity",gameObjectName, UnityMethodName);
}
/// <summary>
/// 把一张Texture2D的图片信息转为Byte[]
/// </summary>
/// <param name="texture"></param>
/// <returns></returns>
private byte[] ImageToBytes(Texture2D texture)
{
var imageData = texture.EncodeToPNG();
return imageData;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94968fb42ad40634ab6b22df87c405cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+193 -130
View File
@@ -26,7 +26,7 @@ using ZenFulcrum.EmbeddedBrowser;
#endif
//记录:小f 是-457和-681
public class QUserInfo
public class QUserInfo
{
public long Id { get; set; }
public string Phone { get; set; }
@@ -34,12 +34,12 @@ public class QUserInfo
public string Avatar { get; set; }
public string Cookie { get; set; }
}
public class LoginForm
public class LoginForm
{
public InputField email { get; set; }
public InputField password { get; set; }
}
public class SignForm
public class SignForm
{
//页面1
public InputField email { get; set; }
@@ -106,7 +106,7 @@ public class LoginController : MonoBehaviour
//其他
[SerializeField] RawImage loading;
Transform toolContainer;
Dictionary<string, Selectable> formDict,signFormDict;
Dictionary<string, Selectable> formDict, signFormDict;
public string avatarName { get; private set; }
public Texture avatar;
@@ -134,7 +134,7 @@ public class LoginController : MonoBehaviour
EventTriggerType.PointerClick, (b) => goResetPassword());
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
UIManager.AddEvent(signPage1.Find("Captcha").Find("BtnGet").gameObject,
EventTriggerType.PointerClick,(b)=> GetCaptcha());
EventTriggerType.PointerClick, (b) => GetCaptcha());
//signPage1.Find("Captcha").Find("BtnGet").GetComponent<Button>().onClick.AddListener(GetCaptcha);
var email = signPage1.Find("Email").GetComponent<InputField>();
var captcha = signPage1.Find("Captcha").GetComponent<InputField>();
@@ -148,10 +148,10 @@ public class LoginController : MonoBehaviour
EventTriggerType.PointerClick, (b) => goRegNext(1));
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
signPage2 = content.Find("NextPage");
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;
//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;
//signPage2.Find("previous").GetComponent<Button>().onClick.AddListener(goRegPrev);
UIManager.AddEvent(signPage2.Find("sign").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegEnd());
@@ -211,7 +211,9 @@ public class LoginController : MonoBehaviour
countrys = countrys,
units = units,
};
#if !(UNITY_ANDROID || UNITY_IOS)
signScrollBar = signScrollView.transform.Find("Image").Find("Image");
#endif
}
if (avatarScrollView != null)
{
@@ -219,7 +221,11 @@ public class LoginController : MonoBehaviour
var content = scrollAvatar.transform.Find("Viewport").Find("Content");
foreach (var user in userInfos)
{
#if !(UNITY_ANDROID || UNITY_IOS)
var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
#else
var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/Mobile/QuickUserInfo")).transform;
#endif
info.GetComponent<QuickLoginUser>().Initial(user, transform);
info.SetParent(content);
info.localScale = new Vector3(1, 1, 1);
@@ -241,22 +247,23 @@ public class LoginController : MonoBehaviour
UIManager.AddEvent(sign.gameObject, EventTriggerType.PointerClick, (b) => goSign());
remember = loginContainer.Find("rememberButton").GetComponent<Button>();
UIManager.AddEvent(remember.gameObject, EventTriggerType.PointerClick, (b) =>
{
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));
{
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));
#if !(UNITY_IOS || UNITY_ANDROID)
var wechatLogin = loginContainer.Find("otherContainer").Find("Wechat").GetComponent<Button>();
UIManager.AddEvent(wechatLogin.gameObject, EventTriggerType.PointerClick, (b) =>
{
#if !(UNITY_IOS || UNITY_ANDROID)
if (wxLock) return;
wxLock = true;
//wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
@@ -274,9 +281,9 @@ public class LoginController : MonoBehaviour
//Debug.Log(178 + "已经开启" + wx1.gameObject.activeSelf);
//wx1.GetComponent<CanvasGroup>().DOFade(1, 0.8f).onComplete = () => { wxLock = false; };
wxLogin1.DOLocalMoveY(0, 0.3f).onComplete = () => { wxLock = false; };
#endif
});
});
#endif
var login = loginContainer.Find("login").GetComponent<Button>();
UIManager.AddEvent(login.gameObject, EventTriggerType.PointerClick, (b) => Submit());
//login.onClick.AddListener(Submit);
@@ -292,11 +299,18 @@ public class LoginController : MonoBehaviour
//}
if (signContainer != null)
{
#if !(UNITY_ANDROID || UNITY_IOS)
var loginr2 = signContainer.Find("loginr2").GetComponent<Button>();
UIManager.AddEvent(loginr2.gameObject, EventTriggerType.PointerClick, (b) =>
{
goLoginReturn2();
});
#else
UIManager.AddEvent(signContainer.Find("loginr2").gameObject, EventTriggerType.PointerClick, (b) =>
{
goLoginReturn2();
});
#endif
}
if (exit != null)
{
@@ -305,10 +319,10 @@ public class LoginController : MonoBehaviour
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", () =>
{
Application.Quit();
},2);
}, 2);
});
}
#if !(UNITY_IOS || UNITY_ANDROID)
wxLogin1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
if (wxLogin1 != null)
{
@@ -316,7 +330,6 @@ public class LoginController : MonoBehaviour
{
wxReturnLogin();
});
#if !(UNITY_IOS || UNITY_ANDROID)
wxBrowser = wxLogin1.Find("Browser (GUI)").GetComponent<Browser>();
if (wxBrowser != null)
{
@@ -339,21 +352,24 @@ public class LoginController : MonoBehaviour
//browser.Zoom = 0.5f;
//browser.
}
#endif
}
#endif
wxLogin2 = mainContent.Find("FormContainer-wx2");
if (wxLogin2 != null)
{
UIManager.AddEvent(wxLogin2.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
{
{
#if !(UNITY_IOS || UNITY_ANDROID)
wxLogin1.gameObject.SetActive(false);
wxLogin1.GetComponent<RectTransform>().localPosition = new Vector3(0, -573, 0);
wxLogin2.gameObject.SetActive(false);
//wxLogin3.gameObject.SetActive(false);
pageNums = 4;
//Canvas.ForceUpdateCanvases();
StartScrollPanel(1);
});
#endif
wxLogin2.gameObject.SetActive(false);
//wxLogin3.gameObject.SetActive(false);
pageNums = 4;
//Canvas.ForceUpdateCanvases();
StartScrollPanel(1);
});
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
{
this.goSign(false);
@@ -363,38 +379,40 @@ public class LoginController : MonoBehaviour
if (wxLogin3 != null)
{
UIManager.AddEvent(wxLogin3.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
{
if (signContainer.gameObject.activeSelf)
{
if (pageNums == 5)
{
StartScrollPanel(3);
}
else if (pageNums == 4)
{
StartScrollPanel(2);
}
else
{
StartScrollPanel(1);
}
}
else
{
signContainer.gameObject.SetActive(true);
{
if (signContainer.gameObject.activeSelf)
{
if (pageNums == 5)
{
StartScrollPanel(3);
}
else if (pageNums == 4)
{
StartScrollPanel(2);
}
else
{
StartScrollPanel(1);
}
}
else
{
signContainer.gameObject.SetActive(true);
#if !(UNITY_IOS || UNITY_ANDROID)
wxLogin1.gameObject.SetActive(false);
wxLogin1.GetComponent<RectTransform>().localPosition = new Vector3(0, -573, 0);
pageNums = 4;
//wxLogin3.gameObject.SetActive(false);
StartScrollPanel(1);
}
});
#endif
pageNums = 4;
//wxLogin3.gameObject.SetActive(false);
StartScrollPanel(1);
}
});
UIManager.AddEvent(wxLogin3.Find("rememberButton").gameObject, EventTriggerType.PointerClick, (b) =>
{
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
gou.SetActive(!gou.activeSelf);
});
UIManager.AddEvent(wxLogin3.Find("Next").gameObject, EventTriggerType.PointerClick, (b) =>
{
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
gou.SetActive(!gou.activeSelf);
});
UIManager.AddEvent(wxLogin3.Find("Next").gameObject, EventTriggerType.PointerClick, (b) =>
{
goMain(wxLogin3.Find("rememberButton").Find("Gou"));
});
@@ -405,9 +423,9 @@ public class LoginController : MonoBehaviour
if (toolContainer != null)
{
UIManager.AddEvent(toolContainer.Find("Setting").gameObject, EventTriggerType.PointerClick, (b) =>
{
UIManager.ShowSettingModal();
});
{
UIManager.ShowSettingModal();
});
//toolContainer.Find("Setting").GetComponent<Button>().onClick.AddListener(() =>
//{
// UIManager.ShowSettingModal();
@@ -427,6 +445,7 @@ public class LoginController : MonoBehaviour
{"Phone",loginForm.email },
{"Pwd",loginForm.password },
};
#if !(UNITY_ANDROID || UNITY_IOS)
loginForm.email.onEndEdit.AddListener(async (s) =>
{
if (!string.IsNullOrEmpty(s) && avatarName!=s)
@@ -443,7 +462,8 @@ public class LoginController : MonoBehaviour
}
}
});
signFormDict = new Dictionary<string, Selectable>
#endif
signFormDict = new Dictionary<string, Selectable>
{
{ "Phone",signForm.email},
{ "Captcha",signForm.captcha},
@@ -454,11 +474,20 @@ public class LoginController : MonoBehaviour
{ "Days",signForm.days},
};
avatar = Resources.Load<Texture>("Images/New Account");
#if UNITY_ANDROID || UNITY_IOS
transform.Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#else
transform.Find("Panel").Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#endif
}
public void Test(string key)
{
Debug.Log(key);
}
async void Init()
{
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
userInfos = UIManager.Instance.userInfos;
App.DefaultRotateTexture = Utils.ReadTextureFromPlayerPrefs("rotateImage");
@@ -468,18 +497,18 @@ public class LoginController : MonoBehaviour
var r = await ConfigHelper.userApi.GetNotify();
if (r.result)
{
//#if !UNITY_EDITOR
//#if !UNITY_EDITOR
var ver = r.data.Value<JObject>("Version").ToObject<UpdateModel>();
if (ver!=null && ver.HasUpdate)
if (ver != null && ver.HasUpdate)
{
App.UpdateObject = ver;
Debug.Log(Application.persistentDataPath + "/PowerFun.exe");
UIManager.ShowDownloadModal();
}
//#endif
//#endif
App.notifyContent = r.data.Value<string>("Content");
if (r.data.Value<int>("Id") != notifyId)
if (r.data.Value<int>("Id") != notifyId)
{
UIManager.ShowNewsModal();
PlayerPrefs.SetInt("notifyId", r.data.Value<int>("Id"));
@@ -509,7 +538,7 @@ public class LoginController : MonoBehaviour
Debug.Log(JsonConvert.SerializeObject(locationInfo));
var i = await ConfigHelper.thirdPartApi.GetMapImage(locationInfo);
var t = new Texture2D(2, 2);
if (t.LoadImage(Utils.StreamToBytes(i)))
if (t.LoadImage(Utils.StreamToBytes(i)))
{
Debug.Log("成功");
App.TextureCache["rotateImage"] = t;
@@ -526,7 +555,7 @@ public class LoginController : MonoBehaviour
/// </summary>
private void AdjustWxQrCode()
{
#if !(UNITY_IOS || UNITY_ANDROID)
#if !(UNITY_IOS || UNITY_ANDROID)
wxBrowser.EvalJSCSP(@"
document.getElementsByClassName('qrcode')[0].style.marginTop = 0;
document.getElementsByClassName('title')[0].style.display = 'none';
@@ -618,7 +647,7 @@ public class LoginController : MonoBehaviour
{
}
#region 倒计时获取验证码
#region 倒计时获取验证码
int time = 0;
float timer = 0f;
bool startCaptcha = false;
@@ -657,8 +686,8 @@ public class LoginController : MonoBehaviour
Utils.SetValidate(signFormDict, r.errFieldMsg);
}
}
#endregion
#endregion
void CaptchaTimerTick()
{
timer -= Time.deltaTime;
@@ -732,7 +761,7 @@ public class LoginController : MonoBehaviour
Utils.showToast(gameObject, r.errMsg);
}
}
async void goRegNextWithoutPass()
{
var Email = signForm.email;
@@ -745,7 +774,7 @@ public class LoginController : MonoBehaviour
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u,1);
RefreshWx3(u, 1);
StartScrollPanel(4);
}
else
@@ -756,7 +785,7 @@ public class LoginController : MonoBehaviour
/// <summary>
/// 重置密码逻辑
/// </summary>
async void goResetPassword()
async void goResetPassword()
{
var Email = signForm.email;
var Captcha = signForm.captcha;
@@ -775,15 +804,15 @@ public class LoginController : MonoBehaviour
var r = await ConfigHelper.userApi.ResetPassword(Email.text, Captcha.text, Password.text);
if (r.result)
{
Utils.showToast(gameObject, "Success",type:1);
Utils.showToast(gameObject, "Success", type: 1);
goLoginReturn2();
}
else
else
{
Utils.showToast(gameObject, r.errMsg);
}
}
void RefreshWx3(UserResultModel data,int type)
void RefreshWx3(UserResultModel data, int type)
{
Utils.DisplayHead(wxLogin3.Find("Avatar").GetComponent<RawImage>(),
data.WxHeadImg);
@@ -798,6 +827,12 @@ public class LoginController : MonoBehaviour
void goRegEnd()
{
if (!UpdateInfo()) return;
#if UNITY_ANDROID || UNITY_IOS
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);
#endif
if (pageNums == 5)
{
this.StartScrollPanel(4);
@@ -838,7 +873,7 @@ public class LoginController : MonoBehaviour
/// 注册页2 修改信息
/// </summary>
/// <returns></returns>
bool UpdateInfo()
bool UpdateInfo()
{
if (userResult == null) return false;
var _days = signForm.days.GetComponent<PFUIDropdown>();
@@ -853,9 +888,9 @@ public class LoginController : MonoBehaviour
{
userResult.Birthday = new DateTime(int.Parse(_years.SelectedItem), int.Parse(_months.SelectedItem), int.Parse(_days.SelectedItem));
}
else
else
{
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
Utils.SetValidate(signFormDict, JArray.FromObject(new object[]
{
new { Field = "Years", ErrMsg = "" },
new { Field = "Months", ErrMsg = "" },
@@ -873,7 +908,7 @@ public class LoginController : MonoBehaviour
{
userResult.Nickname = userResult.Phone;
}
var r = ConfigHelper.userApi.Update(userResult,out string cookie,"");
var r = ConfigHelper.userApi.Update(userResult, out string cookie, "");
return r.result;
//userResult.Birthday.v
}
@@ -882,22 +917,31 @@ public class LoginController : MonoBehaviour
/// </summary>
private void goLoginReturn2()
{
#if UNITY_ANDROID || UNITY_IOS
imagedf.GetComponent<Image>().DOFade(1, .3f);
imagexf.GetComponent<Image>().DOFade(1, .3f);
LoginBg.GetComponent<RectTransform>().DOSizeDelta(new Vector2(354, 300), .3f);
LoginBg.GetComponent<RectTransform>().DOLocalMoveY(-35, .3f);
#endif
if (wxLogin2.gameObject.activeSelf) wxLogin2.gameObject.SetActive(false);
//if (wxLogin3.gameObject.activeSelf) wxLogin3.gameObject.SetActive(false);
pageNums = 4;
#if !(UNITY_ANDROID || UNITY_IOS)
if (wxLogin1.transform.localPosition.y == 0)
{
wxReturnLogin();
}
#else
transform.GetComponent<LoginControllerMobile>().HideThirdLoginPage();
#endif
Canvas.ForceUpdateCanvases();
this.StartScrollPanel(1);
}
#if !(UNITY_IOS || UNITY_ANDROID)
void wxReturnLogin()
{
wxLock = true;
#if !(UNITY_IOS || UNITY_ANDROID)
wxBrowser.LoadHTML("<div/>");
#endif
//wxBrowser.Url = "chrome://version/";
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
{
@@ -905,15 +949,18 @@ public class LoginController : MonoBehaviour
wxLogin1.gameObject.SetActive(false);
};
}
#endif
/// <summary>
/// 立刻跳到登录页并且返回按钮强行失效
/// </summary>
private void goLoginImmediately()
private void goLoginImmediately()
{
#if !(UNITY_IOS || UNITY_ANDROID)
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);
#endif
var scrollValue = 1f / (pageNums - 1);
var value = 1 * scrollValue;
scrollPanel.horizontalNormalizedPosition = value;
@@ -924,6 +971,7 @@ public class LoginController : MonoBehaviour
/// </summary>
void ReturnQuick()
{
#if !(UNITY_IOS || UNITY_ANDROID)
if (imagexf != null)
{
imagexf.DOLocalMoveY(-575, 0.3f);
@@ -937,6 +985,7 @@ public class LoginController : MonoBehaviour
LoginBg.GetComponent<RectTransform>().DOSizeDelta(new Vector2(360, 385), 0.3f);
LoginBg.GetComponent<RectTransform>().DOLocalMoveY(-94, 0.3f);
}
#endif
this.StartScrollPanel(0);
}
/// <summary>
@@ -945,6 +994,7 @@ public class LoginController : MonoBehaviour
/// <param name="noReturn"></param>
public void goLogin(bool noReturn = false)
{
#if !(UNITY_IOS || UNITY_ANDROID)
if (imagexf != null)
{
imagexf.DOLocalMoveY(-669, 0.3f);
@@ -958,6 +1008,7 @@ public class LoginController : MonoBehaviour
LoginBg.GetComponent<RectTransform>().DOSizeDelta(new Vector2(360, 573), 0.3f);
LoginBg.GetComponent<RectTransform>().DOLocalMoveY(0, 0.3f);
}
#endif
//DOTween.To(() => o, x => o = x, t, 0.3f);
this.StartScrollPanel(1);
if (noReturn)
@@ -1002,8 +1053,14 @@ public class LoginController : MonoBehaviour
/// </summary>
/// <param name="isAccount"></param>
/// <param name="type">0 注册 1 忘记密码</param>
void goSign(bool isAccount = true,int type = 0)
void goSign(bool isAccount = true, int type = 0)
{
#if UNITY_ANDROID || UNITY_IOS
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
if (!isAccount)
{
pageNums = 5;
@@ -1016,7 +1073,7 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(3);
this.StartScrollSign(0);
}
else
else
{
if (type == 0)
{
@@ -1031,7 +1088,7 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(2);
this.StartScrollSign(0);
}
else
else
{
pageNums = 4;
signContainer.Find("signText").GetComponent<Text>().text = "RESET PASSWORD";
@@ -1050,7 +1107,7 @@ public class LoginController : MonoBehaviour
/// 登录/注册完成,去首页
/// </summary>
/// <param name="gou"></param>
void goMain(Transform gou)
void goMain(Transform gou)
{
var data = userResult;
if (data == null) return;
@@ -1060,10 +1117,10 @@ public class LoginController : MonoBehaviour
SaveInfo(data);
//PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
}
else
else
{
var u = userInfos.Find(x => x.Id == data.Id);
if (u != null)
if (u != null)
{
userInfos.Remove(u);
}
@@ -1074,13 +1131,13 @@ public class LoginController : MonoBehaviour
App.RideSetting.Sensitivity = data.Sensitivity;
//查询我参加的比赛
UIManager.UpdateJoinCompetition();
SceneManager.LoadScene("MainScene");
SceneManager.LoadSceneAsync("MainScene");
}
/// <summary>
/// 缓存打钩的用户信息
/// </summary>
/// <param name="data"></param>
public void SaveInfo(UserResultModel data)
public void SaveInfo(UserResultModel data)
{
var index = userInfos.FindIndex(x => x.Id == data.Id);
if (index == -1)
@@ -1118,7 +1175,7 @@ public class LoginController : MonoBehaviour
/// <summary>
/// 登录提交
/// </summary>
async void Submit()
async void Submit()
{
var res = await ConfigHelper.userApi.LoginV1(loginForm.email.text, loginForm.password.text, "");
//var res = await NoAuthApi.Login(phone.text, pwd.text);
@@ -1127,9 +1184,9 @@ public class LoginController : MonoBehaviour
userResult = JObject.FromObject(res.data).ToObject<UserResultModel>();
goMain(remember.transform.Find("Gou"));
}
else
else
{
if (res.data != null)
if (res.data != null)
{
var errorList = JArray.FromObject(res.data);
Utils.SetValidate(formDict, errorList);
@@ -1143,13 +1200,13 @@ public class LoginController : MonoBehaviour
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
if (Input.GetKeyDown(KeyCode.Tab))
{
if (loginForm != null && loginForm.email.isFocused && loginForm.password != null)
if (loginForm != null && loginForm.email.isFocused && loginForm.password != null)
{
loginForm.password.ActivateInputField();
}
if (signForm != null)
if (signForm != null)
{
if (signForm.email.isFocused)
if (signForm.email.isFocused)
{
signForm.captcha.ActivateInputField();
}
@@ -1167,19 +1224,18 @@ public class LoginController : MonoBehaviour
}
}
}
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
{
if (loginForm != null && !string.IsNullOrEmpty(loginForm.email.text) && !string.IsNullOrEmpty(loginForm.password.text))
{
Submit();
}
}
if (startCaptcha)
if (startCaptcha)
{
CaptchaTimerTick();
}
goScrollPanel();
goScrollSign();
//if (wxLogin1.gameObject.activeInHierarchy)
//{
// adjTime += Time.deltaTime;
@@ -1191,9 +1247,14 @@ public class LoginController : MonoBehaviour
// }
//}
}
private void FixedUpdate()
{
goScrollPanel();
goScrollSign();
}
//float adjTime = 0;
//bool startJs = false;
#region 主页面滑动逻辑
#region 主页面滑动逻辑
private int tmpImdex = 0;
private int scrollPanelIndex = 2;
//private float scrollValue = 0.5f;
@@ -1208,22 +1269,22 @@ public class LoginController : MonoBehaviour
private void goScrollPanel()
{
var index = scrollPanelIndex;
var scrollValue = 1f/(pageNums - 1);
var scrollValue = 1f / (pageNums - 1);
var value = index * scrollValue;
if (scrollPanel != null && startScrollPanel)
if (scrollPanel != null && startScrollPanel)
{
if (scrollPanel.horizontalNormalizedPosition >= value)
{
scrollPanel.horizontalNormalizedPosition -= (scrollValue / 20);
if (scrollPanel.horizontalNormalizedPosition <= value)
scrollPanel.horizontalNormalizedPosition -= (scrollValue / 10);
if (scrollPanel.horizontalNormalizedPosition <= value)
{
scrollPanel.horizontalNormalizedPosition = value;
startScrollPanel = false;
}
}
else
else
{
scrollPanel.horizontalNormalizedPosition += (scrollValue / 20);
scrollPanel.horizontalNormalizedPosition += (scrollValue / 10);
if (scrollPanel.horizontalNormalizedPosition >= value)
{
scrollPanel.horizontalNormalizedPosition = value;
@@ -1232,31 +1293,31 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#region 注册页面滑动逻辑
#endregion
#region 注册页面滑动逻辑
private bool startScrollSign = false;
private int scrollSignIndex = 0;
private void StartScrollSign(int index)
{
if (startScrollSign) return;
scrollSignIndex = index;
startScrollSign = true;
Debug.Log($"{index},{index * 160}");
if (index == 1)
if (index == 1)
{
if (signForm.years.value!=-1) signForm.years.value = 0;
if (signForm.years.value != -1) signForm.years.value = 0;
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;
if (pageNums == 5 && wxInfoJson != null)
if (pageNums == 5 && wxInfoJson != null)
{
var sex = wxInfoJson.Value<int>("sex");
if (sex > 0)
if (sex > 0)
{
signForm.genders.value = sex - 1;
}
@@ -1272,7 +1333,9 @@ public class LoginController : MonoBehaviour
// signForm.height.text = "";
//}
}
#if !(UNITY_ANDROID || UNITY_IOS)
signScrollBar.DOLocalMoveX((index-1) *160, 0.2f);
#endif
}
private void goScrollSign()
{
@@ -1281,17 +1344,17 @@ public class LoginController : MonoBehaviour
{
if (scrollSignIndex == 0)
{
scrollSign.horizontalNormalizedPosition -= (1f / 20);
scrollSign.horizontalNormalizedPosition -= (1f / 10);
if (scrollSign.horizontalNormalizedPosition <= 0)
{
scrollSign.horizontalNormalizedPosition = 0;
startScrollSign = false;
}
}
else if (scrollSignIndex == 1)
{
scrollSign.horizontalNormalizedPosition += (1f / 20);
scrollSign.horizontalNormalizedPosition += (1f / 10);
if (scrollSign.horizontalNormalizedPosition >= 1)
{
scrollSign.horizontalNormalizedPosition = 1;
@@ -1300,5 +1363,5 @@ public class LoginController : MonoBehaviour
}
}
}
#endregion
#endregion
}
+4 -1
View File
@@ -21,7 +21,10 @@ public class MainController : BaseScene
Version.text = "V"+App.AppVersion;
DeviceCache.Init(PFConstants.DeviceCacheFolder);
Loom.Initialize();
#if UNITY_ANDROID || UNITY_IOS
transform.GetComponent<CanvasScaler>().referenceResolution = new Vector2(844,390);
transform.Find("Panel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
#endif
App.MainDeviceAdapter.StartScan();
}
@@ -17,6 +17,10 @@ public class QuickLoginScroll : MonoBehaviour
void Start()
{
scroll = gameObject.GetComponent<ScrollRect>();
//scroll.onValueChanged.AddListener((a) =>
//{
// Debug.Log(a);
//});
content = gameObject.transform.Find("Viewport").Find("Content");
lightbg = transform.parent.Find("Light");
//Initial();
@@ -42,9 +46,7 @@ public class QuickLoginScroll : MonoBehaviour
{
lightbg.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff00");
lightbg.GetComponent<Image>().gameObject.SetActive(false);
int index = (int)System.Math.Round(
(scroll.horizontalNormalizedPosition + (contentSize / 2)) / contentSize,
0);
int index = GetIndex();
content.GetChild(index).GetComponent<QuickLoginUser>().setNoActive();
//lightbg.GetComponent<Image>().DOFade(0, 0.15f);
}
@@ -52,6 +54,7 @@ public class QuickLoginScroll : MonoBehaviour
public void Initial()
{
count = content.childCount;
#if !(UNITY_ANDROID || UNITY_IOS)
if (content.childCount - 2 > 0)
{
contentSize = 1f / (content.childCount - 2);
@@ -60,11 +63,27 @@ public class QuickLoginScroll : MonoBehaviour
{
contentSize = 0;
}
#else
if (content.childCount - 3 > 0)
{
contentSize = 1f / (content.childCount - 3);
}
else
{
contentSize = 0;
}
#endif
//scroll.horizontalNormalizedPosition = 0;
Canvas.ForceUpdateCanvases();
var i = PlayerPrefs.GetInt("UserInfoIndex");
Debug.Log($"51 {i}");
#if !(UNITY_ANDROID || UNITY_IOS)
scroll.horizontalNormalizedPosition = contentSize/2+i*contentSize;
#else
scroll.horizontalNormalizedPosition = i * contentSize;
Debug.Log(scroll.horizontalNormalizedPosition);
#endif
SetColor();
}
void goLeft()
@@ -74,7 +93,8 @@ public class QuickLoginScroll : MonoBehaviour
}
void goRight()
{
if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
Debug.Log(scroll.horizontalNormalizedPosition);
if (scroll.horizontalNormalizedPosition+0.0001 >= 1) return;
goMove();
}
void goMove(int i = 1)
@@ -82,15 +102,25 @@ public class QuickLoginScroll : MonoBehaviour
doAni();
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = i*contentSize / 30;
scrollValue = i*contentSize / 10;
}
private bool start = false;
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
void SetColor()
int GetIndex()
{
int index = (int)System.Math.Round(
#if !(UNITY_ANDROID || UNITY_IOS)
return (int)System.Math.Round(
(scroll.horizontalNormalizedPosition + (contentSize / 2)) / contentSize,
0);
#else
return (int)System.Math.Round(
(scroll.horizontalNormalizedPosition+ contentSize) / contentSize,
0);
#endif
}
void SetColor()
{
int index = GetIndex();
//lightbg.GetComponent<Image>().gameObject.SetActive(true);
//lightbg.GetComponent<Image>().DOFade(1, 0.2f);
//content.GetChild(index).GetComponent<QuickLoginUser>().setActive();
@@ -111,7 +141,7 @@ public class QuickLoginScroll : MonoBehaviour
}
}
// Update is called once per frame
void Update()
void FixedUpdate()
{
if (start)
{
@@ -250,7 +250,11 @@ public class EditUserController : PFUIPanel
{
UIManager.ShowConfirm("Logout", "Do you want to log out and change accounts?", () =>
{
#if !(UNITY_ANDROID || UNITY_IOS)
SceneManager.LoadScene("Login");
#else
SceneManager.LoadScene("Login-Mobile");
#endif
UIManager.CloseConfirm();
},2);
}
@@ -32,7 +32,11 @@ public class UserInfoController : PFUIPanel
{
UIManager.ShowConfirm("Logout", "Do you want to log out and change accounts?", () =>
{
#if !(UNITY_ANDROID || UNITY_IOS)
SceneManager.LoadScene("Login");
#else
SceneManager.LoadScene("Login-Mobile");
#endif
UIManager.CloseConfirm();
},2);
});
+6 -2
View File
@@ -152,7 +152,7 @@ public class UIManager : MonoBehaviour
{
UIManager.PopStack();
}
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
UIManager.Instance.MainPanel.transform.parent.Find("Bg").GetComponent<Image>().sprite =
Resources.Load<Sprite>("Images/Race/RACE-BG");
UIManager.Show(UIManager.Instance.RaceHomePanel, UIManager.Instance.MainPanel);
}
@@ -307,7 +307,11 @@ public class UIManager : MonoBehaviour
{
if (internalComponent == null)
{
#if !(UNITY_ANDROID || UNITY_IOS)
UnityEngine.Object @object = Resources.Load("UI/Prefab/Panel/" + prefabName);
#else
UnityEngine.Object @object = Resources.Load("UI/Prefab/Panel/Mobile/" + prefabName);
#endif
if (@object != null)
{
GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(@object, base.transform.parent, false);
@@ -464,7 +468,7 @@ public class UIManager : MonoBehaviour
public static void ShowHomePanel()
{
stack.Clear();
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
UIManager.Instance.MainPanel.transform.parent.Find("Bg").GetComponent<Image>().sprite =
Resources.Load<Sprite>("Images/main-bg");
UIManager.Show(UIManager.Instance.HomePanel, UIManager.Instance.MainPanel);
}