Merge remote-tracking branch 'origin/dev' into dev_lishuo
# Conflicts: # Assets/Scripts/Apis/UserApi.cs # Assets/Scripts/App.cs # Assets/Scripts/ConfigHelper.cs # Assets/Scripts/Scenes/LoginController.cs # Assets/Scripts/UI/Prefab/Panel/HomeController.cs
This commit is contained in:
commit
34cde86a28
605 files changed
+40216
-9552
No files matched your search
@@ -37,11 +37,11 @@ namespace Assets.Scripts.Apis
|
||||
|
||||
httpClientHandler = new HttpClientHandler();
|
||||
httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
|
||||
httpClientHandler.Proxy = WebRequest.DefaultWebProxy;
|
||||
httpClientHandler.CookieContainer = _cookieCollection;
|
||||
httpClientHandler.UseCookies = true;
|
||||
httpClientHandler.CookieContainer.Add(new Uri(ConfigHelper.Host), new Cookie("PowerFun.AUTH", "E1F130A03C0C2F01DF465A17AAA4740E9C44FC5F7C5077AF5A09B5ED29F0CF4FABE44329111C0BDBC6D97A28E7C7C188250265B37D2E6A849D7F0CAC606490648F17DC7FB9C8778BE7217991EBB6304BD543CFEE55084E54CCD634B49F26A751","/"));
|
||||
|
||||
|
||||
httpClient = new System.Net.Http.HttpClient(httpClientHandler);
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion));
|
||||
@@ -74,8 +74,7 @@ namespace Assets.Scripts.Apis
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected async Task<byte[]> GetAsync(string url)
|
||||
{
|
||||
AddLanguage();
|
||||
@@ -115,7 +114,12 @@ namespace Assets.Scripts.Apis
|
||||
var response = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
return await ParseJsonAsync<T>(response);
|
||||
}
|
||||
|
||||
protected async Task<T> GetThirdPartAsync<T>(string url)
|
||||
{
|
||||
AddLanguage();
|
||||
var response = await httpClient.GetAsync(url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
return await ParseJsonAsync<T>(response);
|
||||
}
|
||||
private async Task<T> ParseJsonAsync<T>(HttpResponseMessage response)
|
||||
{
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
@@ -455,7 +459,6 @@ namespace Assets.Scripts.Apis
|
||||
public T Get<T>(string url)
|
||||
{
|
||||
var res = Get(url);
|
||||
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(res);
|
||||
}
|
||||
|
||||
@@ -512,6 +515,11 @@ namespace Assets.Scripts.Apis
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetCookie(string cookie)
|
||||
{
|
||||
httpClientHandler.CookieContainer.Add(new Uri(ConfigHelper.Host), new Cookie("PowerFun.AUTH", cookie, "/"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class UserModel
|
||||
{
|
||||
public string NickName { get; set; }
|
||||
public int Ftp { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public double BicycleWeight { get; set; }
|
||||
public string Carlories { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
public double Distance { get; set; }
|
||||
public string Climb { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 359b7bb30d2d48245821f1b6a86d4811
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -56,5 +56,12 @@ namespace Assets.Scripts.Apis.Models
|
||||
/// 已连接到Strava
|
||||
/// </summary>
|
||||
public bool ConnectedToStrava { get; set; }
|
||||
|
||||
public DateTime? Birthday { get; set; }
|
||||
//cookie
|
||||
public string cookie { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class ThirdPartApi : ApiBase
|
||||
{
|
||||
public async Task<JObject> GetWxAccessToken(string code)
|
||||
{
|
||||
return await GetThirdPartAsync<JObject>($"https://api.weixin.qq.com/sns/oauth2/access_token?appid={App.WxAppId}&secret={App.WxAppSecret}&code={code}&grant_type=authorization_code");
|
||||
}
|
||||
public async Task<JObject> GetWxUserInfo(string accessToken, string openId)
|
||||
{
|
||||
return await GetThirdPartAsync<JObject>($"https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken + "&openid=" + openId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f575a1019121c7a47bcd23795da6bc8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,5 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -64,10 +65,11 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
user.ConnectedToStrava = ret.data.ConnectedToStrava;
|
||||
}
|
||||
user.Birthday = ret.data.Birthday;
|
||||
//todo: check local database, insert new user
|
||||
|
||||
//App.CurrentUser = user;
|
||||
|
||||
//PubCommData.CurrentUser = user;
|
||||
user.cookie = cookies[0].Value;
|
||||
return new JsonResult<UserResultModel>() { result = true, data = user };
|
||||
}
|
||||
else
|
||||
@@ -93,5 +95,104 @@ namespace Assets.Scripts.Apis
|
||||
|
||||
return DateTime.Parse(result);
|
||||
}
|
||||
public async Task<JsonResult<UserResultModel>> Register(string Phone, string Pwd, string Captcha)
|
||||
{
|
||||
var param = new
|
||||
{
|
||||
Phone,
|
||||
Pwd,
|
||||
Captcha
|
||||
};
|
||||
|
||||
JsonResult<UserResultModel> ret = null;
|
||||
try
|
||||
{
|
||||
ret = await PostAsync<JsonResult<UserResultModel>>("NoAuth/v1/Register", param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new JsonResult<UserResultModel> { result = false, errMsg = ex.Message };
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public async Task<JsonResult<object>> GetCaptcha(string phone)
|
||||
{
|
||||
return await PostAsync<JsonResult<object>>("NoAuth/v1/GetCaptcha",new {phone });
|
||||
}
|
||||
public async Task<JsonResult<object>> UpdateUserInfo(UserResultModel user)
|
||||
{
|
||||
return await PostAsync<JsonResult<object>>("User/UpdateUserSetting", user);
|
||||
}
|
||||
public JsonResult<JObject> GetUserInfo()
|
||||
{
|
||||
return Get<JsonResult<JObject>>("User/GetCurrentUser");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<object>> OnWebWxLoginCheckUnionId(string unionId, string openId)
|
||||
{
|
||||
return await PostAsync<JsonResult<object>>("NoAuth/OnWebWxLoginCheckUnionId", new {unionId,openId});
|
||||
}
|
||||
public async Task<JsonResult<UserResultModel>> OnWebWxLogin(string Phone, string Captcha
|
||||
, string UnionId, string WxWebOpenId, string WxHeadImg, string NickName, int? Sex, string Password)
|
||||
{
|
||||
return await PostAsync<JsonResult<UserResultModel>>("NoAuth/OnWebWxLogin",
|
||||
new { Phone, Captcha, UnionId, WxWebOpenId, WxHeadImg, NickName, Sex, Password });
|
||||
}
|
||||
|
||||
|
||||
public async Task<JsonResult<dynamic>> Update(UserResultModel currUser, string filePath = "")
|
||||
{
|
||||
//return await PostAsync<JsonResult<dynamic>>("User/UpdateUserSetting", new {
|
||||
// UID = currUser.Id,
|
||||
// Sex = currUser.Sex,
|
||||
// currUser.Unit,
|
||||
// currUser.Weight,
|
||||
// currUser.FTP,
|
||||
// currUser.WheelDiameter,
|
||||
// currUser.Nickname,
|
||||
// currUser.Country,
|
||||
// currUser.Province,
|
||||
// currUser.City,
|
||||
// currUser.Area,
|
||||
// currUser.AutoPause,
|
||||
// currUser.MaxHeartRate,
|
||||
// currUser.BicycleWeight,
|
||||
// currUser.Contact,
|
||||
// currUser.ContactPhone,
|
||||
// currUser.ContactAddress,
|
||||
// currUser.Sensitivity,
|
||||
// imgData = imgData
|
||||
//});
|
||||
var files = new List<string>();
|
||||
if (!string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
files.Add(filePath);
|
||||
}
|
||||
var res = Upload("v1/User/UpdateUserSetting", new
|
||||
{
|
||||
UID = currUser.Id,
|
||||
Sex = currUser.Sex,
|
||||
currUser.Unit,
|
||||
currUser.Weight,
|
||||
currUser.FTP,
|
||||
currUser.WheelDiameter,
|
||||
currUser.Nickname,
|
||||
currUser.Country,
|
||||
currUser.Province,
|
||||
currUser.City,
|
||||
currUser.Area,
|
||||
currUser.AutoPause,
|
||||
currUser.MaxHeartRate,
|
||||
currUser.BicycleWeight,
|
||||
currUser.Contact,
|
||||
currUser.ContactPhone,
|
||||
currUser.ContactAddress,
|
||||
currUser.Sensitivity,
|
||||
currUser.Birthday
|
||||
//imgData = imgData
|
||||
}, files);
|
||||
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<JsonResult<dynamic>>(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ public static class App
|
||||
public static string AppVersion = "1.0.0";
|
||||
|
||||
public static int RouteIdParam = 0;
|
||||
|
||||
public static UserResultModel CurrentUser { get; set; }
|
||||
|
||||
public static string WxAppId = "wx9e8ca734e024f084";
|
||||
public static string WxAppSecret = "906abafb2a18bc7a66ccfa5550f859b6";
|
||||
public static IDictionary<string,Texture> TextureCache = new Dictionary<string, Texture>();
|
||||
}
|
||||
@@ -14,10 +14,11 @@ namespace Assets.Scripts
|
||||
public static string Host = App.Host;
|
||||
|
||||
public static string AppVersion = App.AppVersion;
|
||||
public static UserResultModel CurrentUser { get; set; }
|
||||
|
||||
public static UserApi userApi = new UserApi();
|
||||
public static MapApi mapApi = new MapApi();
|
||||
public static MapInterruptRecordApi mapInterruptRecordApi = new MapInterruptRecordApi();
|
||||
public static ThirdPartApi thirdPartApi = new ThirdPartApi();
|
||||
public static IPEndPoint UdpAddress { get; private set; } = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
|
||||
public static IPEndPoint TcpAddress { get; private set; } = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11001);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.Login;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -7,16 +10,39 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using ZenFulcrum.EmbeddedBrowser;
|
||||
//记录:小f 是-457和-681
|
||||
public class LoginForm
|
||||
|
||||
public class QUserInfo
|
||||
{
|
||||
public InputField phone;
|
||||
public InputField pwd;
|
||||
public long Id { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
public string Cookie { get; set; }
|
||||
}
|
||||
public class SignForm
|
||||
{
|
||||
//页面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; }
|
||||
}
|
||||
public class LoginController : MonoBehaviour
|
||||
{
|
||||
@@ -25,12 +51,16 @@ public class LoginController : MonoBehaviour
|
||||
[SerializeField] Button loginNewAccount;
|
||||
[SerializeField] Button loginReturn2;
|
||||
[SerializeField] Button returnQuick;
|
||||
[SerializeField] Button regNext;
|
||||
[SerializeField] Button regPrev;
|
||||
[SerializeField] Button sign;
|
||||
[SerializeField] Button remember;
|
||||
[SerializeField] Button wechatLogin;
|
||||
[SerializeField] GameObject loginScrollView;
|
||||
[SerializeField] GameObject signScrollView;
|
||||
private Transform signPage1;
|
||||
private Transform signPage2;
|
||||
private Transform signScrollBar;
|
||||
private SignForm signForm;
|
||||
private LoginRegOptions regOptions;
|
||||
[SerializeField] GameObject avatarScrollView;
|
||||
[SerializeField] RawImage loading;
|
||||
[SerializeField] Button exit;
|
||||
@@ -38,13 +68,33 @@ public class LoginController : MonoBehaviour
|
||||
private ScrollRect scrollSign;
|
||||
private ScrollRect scrollAvatar;
|
||||
private Transform imagexf;
|
||||
private Transform mainContent;
|
||||
//注册主页面
|
||||
private Transform signContainer;
|
||||
private UserResultModel userResult;
|
||||
/*微信相关*/
|
||||
private Browser wxBrowser;
|
||||
private string wxState;
|
||||
private Transform wxLogin1;
|
||||
private Transform wxLogin2;
|
||||
private Transform wxLogin3;
|
||||
private JObject wxInfoJson;
|
||||
private bool wxLock;
|
||||
/*微信相关*/
|
||||
|
||||
private List<QUserInfo> userInfos;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var userInfosJson = PlayerPrefs.GetString("UserInfos");
|
||||
userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
|
||||
if (userInfos == null) userInfos = new List<QUserInfo>();
|
||||
//userInfos.RemoveAt(0);
|
||||
//PlayerPrefs.SetString("UserInfos", "");
|
||||
//transform.Find("RawImage").DOMove(new Vector3(0.5f,0.5f,0),1);
|
||||
if (loginForm.Length == 2 && loginForm[0]!=null && loginForm[1]!=null)
|
||||
if (loginForm.Length == 2 && loginForm[0] != null && loginForm[1] != null)
|
||||
{
|
||||
foreach (var ipt in loginForm)
|
||||
foreach (var ipt in loginForm)
|
||||
{
|
||||
UIManager.AddEvent(ipt.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>
|
||||
((BaseEventData arg0) => { OnLoginInputSelect(arg0, ipt.gameObject); }));
|
||||
@@ -67,61 +117,369 @@ public class LoginController : MonoBehaviour
|
||||
if (loginScrollView != null)
|
||||
{
|
||||
scrollPanel = loginScrollView.GetComponent<ScrollRect>();
|
||||
mainContent = loginScrollView.transform.Find("Viewport").Find("Content");
|
||||
}
|
||||
if (signScrollView != null)
|
||||
{
|
||||
scrollSign = signScrollView.GetComponent<ScrollRect>();
|
||||
var content = signScrollView.transform.Find("Viewport").Find("Content");
|
||||
signPage1 = content.Find("FirstPage");
|
||||
signPage1.Find("next").GetComponent<Button>().onClick.AddListener(()=> { goRegNext(); });
|
||||
signPage1.Find("Captcha").Find("BtnGet").GetComponent<Button>().onClick.AddListener(GetCaptcha);
|
||||
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>();
|
||||
//第三方登录要用的按钮
|
||||
signPage1.Find("previousThird").GetComponent<Button>().onClick.AddListener(goThirdPrev);
|
||||
signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
|
||||
signPage2 = content.Find("NextPage");
|
||||
signPage2.Find("previous").GetComponent<Button>().onClick.AddListener(goRegPrev);
|
||||
signPage2.Find("sign").GetComponent<Button>().onClick.AddListener(goRegEnd);
|
||||
//注册2 字段
|
||||
regOptions = new LoginRegOptions();
|
||||
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>();
|
||||
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) =>
|
||||
{
|
||||
if (index != -1 && months.value!=-1)
|
||||
{
|
||||
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,
|
||||
};
|
||||
signScrollBar = signScrollView.transform.Find("Image").Find("Image");
|
||||
}
|
||||
if (avatarScrollView != null)
|
||||
if (avatarScrollView != null)
|
||||
{
|
||||
scrollAvatar = avatarScrollView.GetComponent<ScrollRect>();
|
||||
scrollAvatar = avatarScrollView.GetComponent<ScrollRect>();
|
||||
var content = scrollAvatar.transform.Find("Viewport").Find("Content");
|
||||
foreach (var user in userInfos)
|
||||
{
|
||||
var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
|
||||
info.GetComponent<QuickLoginUser>().Initial(user);
|
||||
info.parent = content;
|
||||
info.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
content.Find("empty1").transform.SetSiblingIndex(0);
|
||||
content.Find("empty2").transform.SetSiblingIndex(content.childCount-1);
|
||||
scrollAvatar.GetComponent<QuickLoginScroll>().Initial();
|
||||
}
|
||||
if (loginNewAccount != null)
|
||||
{
|
||||
loginNewAccount.onClick.AddListener(goLogin);
|
||||
}
|
||||
if (returnQuick != null)
|
||||
if (returnQuick != null)
|
||||
{
|
||||
returnQuick.onClick.AddListener(ReturnQuick);
|
||||
}
|
||||
if (sign != null)
|
||||
if (sign != null)
|
||||
{
|
||||
sign.onClick.AddListener(goSign);
|
||||
sign.onClick.AddListener(()=>goSign());
|
||||
}
|
||||
if (loginReturn2 != null)
|
||||
if (loginReturn2 != null)
|
||||
{
|
||||
loginReturn2.onClick.AddListener(goLoginReturn2);
|
||||
}
|
||||
if (regNext != null)
|
||||
{
|
||||
regNext.onClick.AddListener(goRegNext);
|
||||
}
|
||||
if (regPrev != null)
|
||||
{
|
||||
regPrev.onClick.AddListener(goRegPrev);
|
||||
}
|
||||
if (exit != null)
|
||||
if (exit != null)
|
||||
{
|
||||
exit.onClick.AddListener(() => Application.Quit());
|
||||
}
|
||||
if (remember != null)
|
||||
signContainer = mainContent.Find("FormContainer-Sign");
|
||||
if (remember != null)
|
||||
{
|
||||
remember.onClick.AddListener(() =>
|
||||
remember.onClick.AddListener(() =>
|
||||
{
|
||||
var gou = remember.transform.Find("Gou");
|
||||
if (gou.gameObject.activeSelf)
|
||||
{
|
||||
gou.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
gou.gameObject.SetActive(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (wechatLogin != null)
|
||||
{
|
||||
wechatLogin.onClick.AddListener(() =>
|
||||
{
|
||||
if (wxLock) return;
|
||||
wxLock = true;
|
||||
|
||||
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={wxState}#wechat_redirect";
|
||||
AdjustWxQrCode();
|
||||
var wx1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
|
||||
wx1.gameObject.SetActive(true);
|
||||
Debug.Log(178+ "已经开启"+ wx1.gameObject.activeSelf);
|
||||
wx1.DOLocalMoveY(0, 0.3f).onComplete = ()=> { wxLock = false; };
|
||||
});
|
||||
}
|
||||
wxLogin1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
|
||||
if (wxLogin1 != null)
|
||||
{
|
||||
wxLogin1.Find("Image").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
wxLock = true;
|
||||
wxLogin1.DOMoveY(-573, 0.8f).onComplete = () =>
|
||||
{
|
||||
wxLock = false;
|
||||
wxLogin1.gameObject.SetActive(false);
|
||||
};
|
||||
});
|
||||
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
|
||||
// }
|
||||
//});");
|
||||
wxBrowser.onTextureUpdated += OnUserScan;
|
||||
//browser.Zoom = 0.5f;
|
||||
//browser.
|
||||
}
|
||||
}
|
||||
|
||||
wxLogin2 = mainContent.Find("FormContainer-wx2");
|
||||
if (wxLogin2!=null)
|
||||
{
|
||||
wxLogin2.Find("return").GetComponent<Button>().onClick.AddListener(() => {
|
||||
wxLogin2.gameObject.SetActive(false);
|
||||
wxLogin3.gameObject.SetActive(false);
|
||||
pageNums = 3;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
StartScrollPanel(1);
|
||||
});
|
||||
|
||||
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(()=>
|
||||
{
|
||||
this.goSign(false);
|
||||
});
|
||||
}
|
||||
wxLogin3 = mainContent.Find("FormContainer-wx3");
|
||||
if (wxLogin3 != null)
|
||||
{
|
||||
wxLogin3.Find("return").GetComponent<Button>().onClick.AddListener(() => {
|
||||
if (signContainer.gameObject.activeSelf)
|
||||
{
|
||||
StartScrollPanel(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
signContainer.gameObject.SetActive(true);
|
||||
wxLogin3.gameObject.SetActive(false);
|
||||
StartScrollPanel(1);
|
||||
}
|
||||
});
|
||||
wxLogin3.Find("rememberButton").GetComponent<Button>().onClick.AddListener(()=>
|
||||
{
|
||||
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
|
||||
gou.SetActive(!gou.activeSelf);
|
||||
});
|
||||
wxLogin3.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
goMain(wxLogin3.Find("rememberButton").Find("Gou"));
|
||||
//goMain
|
||||
});
|
||||
}
|
||||
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
|
||||
|
||||
|
||||
}
|
||||
private void AdjustWxQrCode()
|
||||
{
|
||||
wxBrowser.EvalJS(@"
|
||||
document.getElementsByClassName('qrcode')[0].style.marginTop = 0;
|
||||
document.getElementsByClassName('title')[0].style.display = 'none';
|
||||
document.body.style.background = '#272732';
|
||||
document.body.style.overflow = 'hidden';
|
||||
document.body.style.transformOrigin = 'top left';
|
||||
document.body.style.transform = 'scale(0.85106382978)';
|
||||
document.body.style.padding = '0';
|
||||
");
|
||||
}
|
||||
//浏览器加载回调
|
||||
private async void OnUserScan()
|
||||
{
|
||||
if (wxBrowser.Url.Contains("qrconnect"))
|
||||
{
|
||||
AdjustWxQrCode();
|
||||
}
|
||||
Debug.Log(wxBrowser.Url);
|
||||
var rgx = Regex.Match(wxBrowser.Url, @"https\:\/\/wx.powerfun.com.cn/NoAuth/v1/WxWebLogin\?code=(.*?)&state=(.*?)$");
|
||||
var groups = rgx.Groups;
|
||||
if (groups.Count == 3)
|
||||
{
|
||||
wxLogin1.gameObject.SetActive(false);
|
||||
var state = groups[2].Value;
|
||||
if (state == wxState)
|
||||
{
|
||||
var acjson = await ConfigHelper.thirdPartApi.GetWxAccessToken(groups[1].Value);
|
||||
var infojson = await ConfigHelper.thirdPartApi.GetWxUserInfo(
|
||||
acjson.Value<string>("access_token"), acjson.Value<string>("openid"));
|
||||
wxInfoJson = infojson;
|
||||
string unionId = wxInfoJson.Value<string>("unionid"),
|
||||
openId = wxInfoJson.Value<string>("openid");
|
||||
var r = await ConfigHelper.userApi.OnWebWxLoginCheckUnionId(unionId, openId);
|
||||
if (r.result)
|
||||
{
|
||||
JObject data = JObject.FromObject(r.data);
|
||||
if (data.Value<string>("success")!=null && data.Value<string>("success") == "False")
|
||||
{
|
||||
wxLogin2.gameObject.SetActive(true);
|
||||
Utils.DisplayImage(StartCoroutine,
|
||||
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(StartCoroutine,
|
||||
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
|
||||
{
|
||||
userResult = data.ToObject<UserResultModel>();
|
||||
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;
|
||||
//this.goSign();
|
||||
StartScrollPanel(2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void goThirdNext()
|
||||
{
|
||||
this.StartScrollPanel(4);
|
||||
}
|
||||
|
||||
private void goThirdPrev()
|
||||
{
|
||||
this.StartScrollPanel(2);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//用于倒计时获取验证码
|
||||
int time = 0;
|
||||
float timer = 0f;
|
||||
bool startCaptcha = false;
|
||||
async void GetCaptcha()
|
||||
{
|
||||
var btn = signPage1.Find("Captcha").Find("BtnGet");
|
||||
var btnText = signPage1.Find("Captcha").Find("BtnGet").Find("Text").GetComponent<Text>();
|
||||
var Email = signForm.email;
|
||||
var r = await ConfigHelper.userApi.GetCaptcha(Email.text);
|
||||
//Timer t = new Ti
|
||||
if (r.result)
|
||||
{
|
||||
time = 60;
|
||||
btnText.text = $"Again({time})";
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
btn.GetComponent<Button>().enabled = false;
|
||||
startCaptcha = true;
|
||||
//timer.Interval = 1000;
|
||||
//timer.AutoReset = true;
|
||||
//timer.Elapsed += new ElapsedEventHandler(CaptchaTimerTick);
|
||||
//timer.Enabled = true;
|
||||
//btnGet.
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
void CaptchaTimerTick()
|
||||
{
|
||||
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;
|
||||
startCaptcha = false;
|
||||
//timer.Stop();
|
||||
}
|
||||
timer = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoginInputDeSelect(BaseEventData arg0, GameObject game)
|
||||
{
|
||||
var image = game.transform.GetComponent<Image>();
|
||||
@@ -142,14 +500,55 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
StartScrollSign(0);
|
||||
}
|
||||
|
||||
private void goRegNext()
|
||||
//0-普通 1-微信
|
||||
private async void goRegNext(int signType = 0)
|
||||
{
|
||||
StartScrollSign(1);
|
||||
var Email = signForm.email;
|
||||
var Captcha = signForm.captcha;
|
||||
var Password = signForm.password;
|
||||
var CPassword = signForm.cpassword;
|
||||
//JsonConvert
|
||||
JsonResult<UserResultModel> r = null;
|
||||
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,
|
||||
wxInfoJson.Value<string>("unionid"),
|
||||
wxInfoJson.Value<string>("openid"),
|
||||
wxInfoJson.Value<string>("headimgurl"),
|
||||
wxInfoJson.Value<string>("nickname"),
|
||||
wxInfoJson.Value<int>("sex"),
|
||||
Password.text);
|
||||
}
|
||||
if (r!=null && r.result)
|
||||
{
|
||||
StartScrollSign(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartScrollSign(1);
|
||||
//Utils.showToast(gameObject, r.errMsg, 1);
|
||||
}
|
||||
}
|
||||
private void goRegEnd()
|
||||
{
|
||||
if (pageNums == 5)
|
||||
{
|
||||
this.StartScrollPanel(4);
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void goLoginReturn2()
|
||||
{
|
||||
if (wxLogin2.gameObject.activeSelf) wxLogin2.gameObject.SetActive(false);
|
||||
if (wxLogin3.gameObject.activeSelf) wxLogin3.gameObject.SetActive(false);
|
||||
pageNums = 3;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
this.StartScrollPanel(1);
|
||||
}
|
||||
|
||||
@@ -169,10 +568,59 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
this.StartScrollPanel(1);
|
||||
}
|
||||
void goSign()
|
||||
void goSign(bool isAccount = true)
|
||||
{
|
||||
this.StartScrollPanel(2);
|
||||
this.StartScrollSign(0);
|
||||
if (!isAccount)
|
||||
{
|
||||
pageNums = 5;
|
||||
//wxLogin2.gameObject.SetActive(false);
|
||||
signPage1.Find("next").gameObject.SetActive(false);
|
||||
signPage1.Find("previousThird").gameObject.SetActive(true);
|
||||
signPage1.Find("signThird").gameObject.SetActive(true);
|
||||
this.StartScrollPanel(3);
|
||||
this.StartScrollSign(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pageNums = 3;
|
||||
wxLogin2.gameObject.SetActive(false);
|
||||
|
||||
signPage1.Find("next").gameObject.SetActive(true);
|
||||
signPage1.Find("previousThird").gameObject.SetActive(false);
|
||||
signPage1.Find("signThird").gameObject.SetActive(false);
|
||||
this.StartScrollPanel(2);
|
||||
this.StartScrollSign(0);
|
||||
}
|
||||
|
||||
}
|
||||
void goMain(Transform gou)
|
||||
{
|
||||
var data = userResult;
|
||||
if (data == null) return;
|
||||
//ConfigHelper.CurrentUser = res.data;
|
||||
if (gou != null && gou.gameObject.activeSelf && !userInfos.Exists(x => x.Id == data.Id))
|
||||
{
|
||||
userInfos.Add(new QUserInfo
|
||||
{
|
||||
Id = data.Id,
|
||||
NickName = data.Nickname,
|
||||
Avatar = data.WxHeadImg,
|
||||
Cookie = data.cookie
|
||||
});
|
||||
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
|
||||
}
|
||||
//App.CurrentUser = new UserModel
|
||||
//{
|
||||
// NickName = data.Nickname,
|
||||
// Ftp = data.FTP,
|
||||
// Weight = data.Weight,
|
||||
// BicycleWeight = data.BicycleWeight,
|
||||
// Carlories = "",
|
||||
// Avatar = data.WxHeadImg,
|
||||
// Distance = 0,
|
||||
// Climb = "",
|
||||
//};
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
async void Submit()
|
||||
{
|
||||
@@ -181,19 +629,19 @@ public class LoginController : MonoBehaviour
|
||||
Utils.showToast(gameObject, "未绑定", 1);
|
||||
return;
|
||||
}
|
||||
//if (string.IsNullOrEmpty(phone.text) || string.IsNullOrEmpty(pwd.text))
|
||||
//{
|
||||
// Utils.showToast(gameObject, "请输入信息", 1);
|
||||
// return;
|
||||
//}
|
||||
if (string.IsNullOrEmpty(loginForm[0].text) || string.IsNullOrEmpty(loginForm[1].text))
|
||||
{
|
||||
Utils.showToast(gameObject, "请输入信息", 1);
|
||||
return;
|
||||
}
|
||||
//var res = await Global.userApi.Login(phone.text, pwd.text, "");
|
||||
//测试用
|
||||
var res = await ConfigHelper.userApi.Login("15651831367", "123456", "");
|
||||
var res = await ConfigHelper.userApi.Login(loginForm[0].text, loginForm[1].text, "");
|
||||
//var res = await NoAuthApi.Login(phone.text, pwd.text);
|
||||
if (res.result)
|
||||
{
|
||||
App.CurrentUser = res.data;
|
||||
SceneManager.LoadScene("MainScene");
|
||||
userResult = res.data;
|
||||
goMain(remember.transform.Find("Gou"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,6 +656,10 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
loginForm[1].ActivateInputField();
|
||||
}
|
||||
if (startCaptcha)
|
||||
{
|
||||
CaptchaTimerTick();
|
||||
}
|
||||
goScrollPanel();
|
||||
goScrollSign();
|
||||
//if (Input.GetKeyDown(KeyCode.Return) && )
|
||||
@@ -233,10 +685,11 @@ public class LoginController : MonoBehaviour
|
||||
scrollPanelIndex = index;
|
||||
startScrollPanel = true;
|
||||
}
|
||||
private int pageNums = 3;
|
||||
private void goScrollPanel()
|
||||
{
|
||||
var index = scrollPanelIndex;
|
||||
var scrollValue = 1f/(3 - 1);
|
||||
var scrollValue = 1f/(pageNums - 1);
|
||||
var value = index * scrollValue;
|
||||
if (scrollPanel != null && startScrollPanel)
|
||||
{
|
||||
@@ -278,11 +731,35 @@ public class LoginController : MonoBehaviour
|
||||
#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 (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)
|
||||
{
|
||||
var sex = wxInfoJson.Value<int>("sex");
|
||||
if (sex > 0)
|
||||
{
|
||||
signForm.genders.value = sex - 1;
|
||||
}
|
||||
var country = wxInfoJson.Value<string>("country");
|
||||
signForm.countrys.value = regOptions.GetCountryIndexByCode(country);
|
||||
}
|
||||
signForm.weight.text = "";
|
||||
signForm.height.text = "";
|
||||
}
|
||||
signScrollBar.DOLocalMoveX((index-1) *160, 0.2f);
|
||||
}
|
||||
private void goScrollSign()
|
||||
{
|
||||
@@ -296,6 +773,7 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
scrollSign.horizontalNormalizedPosition = 0;
|
||||
startScrollSign = false;
|
||||
|
||||
}
|
||||
}
|
||||
else if (scrollSignIndex == 1)
|
||||
|
||||
@@ -7,8 +7,8 @@ public class MainController : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
UIManager.Instance.MainPanel = (GameObject)this.transform.Find("Panel").gameObject;
|
||||
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").gameObject;
|
||||
UIManager.Instance.MainPanel = this.transform.Find("Panel").GetComponent<PFUIPanel>();
|
||||
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
||||
|
||||
|
||||
//MainMenu.transform.Find("Home").GetComponent<Button>().onClick.AddListener(() =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -7,14 +8,17 @@ public class ButtonHoverScript : MonoBehaviour, IPointerExitHandler, IPointerEnt
|
||||
{
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
//transform.DOMove
|
||||
Debug.Log("鼠标悬浮");
|
||||
gameObject.transform.localScale = new Vector3(1.01f, 1.01f, 1f);
|
||||
//gameObject.transform.localScale = new Vector3(1.01f, 1.01f, 1f);
|
||||
transform.DOScale(new Vector3(1.01f, 1.01f, 1f),0.2f);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("鼠标松开");
|
||||
gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||
transform.DOScale(new Vector3(1f, 1f, 1f), 0.2f);
|
||||
//gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
@@ -6,15 +6,13 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
public class PFUIDropdown : PFUIComponentBase
|
||||
{
|
||||
private int mSelectedIndex = -1;
|
||||
|
||||
private object mSelectedValue;
|
||||
|
||||
private int mSelectedIndex = 0;
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
@@ -23,15 +21,41 @@ namespace Assets.Scripts.UI.Control
|
||||
}
|
||||
}
|
||||
|
||||
public int Value
|
||||
//public int Value
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return this.GetComponent<Dropdown>().value;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// this.GetComponent<Dropdown>().value = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
public string SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetComponent<Dropdown>().value;
|
||||
if(this.mSelectedIndex >= 0)
|
||||
{
|
||||
return this.GetComponent<Dropdown>().options[this.mSelectedIndex].text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private UnityAction<int> mOnValueChange;
|
||||
public UnityAction<int> OnValueChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return mOnValueChange;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.GetComponent<Dropdown>().value = value;
|
||||
mOnValueChange = value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +64,14 @@ namespace Assets.Scripts.UI.Control
|
||||
//this.mSelectedIndex =
|
||||
//UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Select, new UnityEngine.Events.UnityAction<BaseEventData>(OnSelect));
|
||||
//UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(OnDeselect));
|
||||
|
||||
this.GetComponent<Dropdown>().onValueChanged.AddListener(i => {
|
||||
mSelectedIndex = i;
|
||||
if (OnValueChange != null)
|
||||
{
|
||||
mOnValueChange(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
@@ -57,9 +89,38 @@ namespace Assets.Scripts.UI.Control
|
||||
|
||||
|
||||
public void AddOptions(List<Dropdown.OptionData> options)
|
||||
{
|
||||
this.GetComponent<Dropdown>().AddOptions(options);
|
||||
}
|
||||
|
||||
public void AddOptions(List<string> options)
|
||||
{
|
||||
this.GetComponent<Dropdown>().AddOptions(options);
|
||||
|
||||
}
|
||||
|
||||
public void ClearOptions()
|
||||
{
|
||||
this.GetComponent<Dropdown>().ClearOptions();
|
||||
}
|
||||
|
||||
|
||||
public void SelectIndex(int index)
|
||||
{
|
||||
this.GetComponent<Dropdown>().value = index;
|
||||
this.mSelectedIndex = index;
|
||||
}
|
||||
|
||||
public void SelectValue(string value)
|
||||
{
|
||||
var options = this.GetComponent<Dropdown>().options;
|
||||
for (int i = 0; i < options.Count; i++)
|
||||
{
|
||||
if(options[i].text == value)
|
||||
{
|
||||
SelectIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
[SerializeField]
|
||||
private InputField mInnerInputField;
|
||||
private Outline outline;
|
||||
private bool isSelected = false;
|
||||
|
||||
public string Text
|
||||
{
|
||||
@@ -27,28 +29,95 @@ namespace Assets.Scripts.UI.Control
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
if (this.gameObject.activeInHierarchy == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isSelected = true;
|
||||
//throw new NotImplementedException();
|
||||
this.mInnerInputField.OnSelect(eventData);
|
||||
var image = this.transform.GetComponent<Image>();
|
||||
var png = Resources.Load<Sprite>("Images/ipt-1");
|
||||
image.sprite = png;
|
||||
//var image = this.transform.GetComponent<Image>();
|
||||
// var png = Resources.Load<Sprite>("Images/ipt-1");
|
||||
//image.sprite = png;
|
||||
outline.enabled = true;
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color color);
|
||||
|
||||
outline.effectColor = color;
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
if(this.gameObject.activeInHierarchy == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isSelected = false;
|
||||
this.mInnerInputField.OnDeselect(eventData);
|
||||
var image = this.transform.GetComponent<Image>();
|
||||
var png1 = Resources.Load<Sprite>("Images/ipt-0");
|
||||
image.sprite = png1;
|
||||
//var image = this.transform.GetComponent<Image>();
|
||||
//var png1 = Resources.Load<Sprite>("Images/ipt-0");
|
||||
//image.sprite = png1;
|
||||
outline.enabled = false;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height*0.5f, 0));
|
||||
gameObject.GetComponent<Image>().material = material;
|
||||
|
||||
outline = this.GetComponent<Outline>();
|
||||
if (outline == null)
|
||||
{
|
||||
outline = this.gameObject.AddComponent<Outline>();
|
||||
outline.effectDistance = new Vector2(2, 2);
|
||||
}
|
||||
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>(this.OnSelect));
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>(this.OnDeselect));
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>((e) =>
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
outline.enabled = true;
|
||||
ColorUtility.TryParseHtmlString("#6E6E7D", out Color color);
|
||||
outline.effectColor = color;
|
||||
}));
|
||||
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//outline = this.gameObject.AddComponent<Outline>();
|
||||
outline.enabled = false;
|
||||
}));
|
||||
}
|
||||
|
||||
public void SetValidate(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.mInnerInputField.GetComponent<Text>().color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color color);
|
||||
this.mInnerInputField.GetComponent<Text>().color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
[RequireComponent(typeof(Button))]
|
||||
public class PfPrimaryButton : PFUIComponentBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
[RequireComponent(typeof(Button))]
|
||||
public class PFUIButton : PFUIComponentBase
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Normal,
|
||||
Border,
|
||||
Primary
|
||||
}
|
||||
|
||||
[SerializeField] Type mType;
|
||||
private Image image;
|
||||
private Text text;
|
||||
private Texture2D cursor;
|
||||
private Outline outline;
|
||||
protected void Awake()
|
||||
{
|
||||
outline = this.GetComponent<Outline>();
|
||||
if (mType == Type.Border && outline == null)
|
||||
{
|
||||
outline = this.gameObject.AddComponent<Outline>();
|
||||
outline.effectDistance = new Vector2(2, 2);
|
||||
}
|
||||
|
||||
//设置光标
|
||||
cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
|
||||
|
||||
image = gameObject.GetComponent<Image>();
|
||||
text = this.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height*0.5f, 0));
|
||||
image.material = material;
|
||||
|
||||
InitColor();
|
||||
BindEvent();
|
||||
}
|
||||
|
||||
private void InitColor()
|
||||
{
|
||||
text.color = Color.white;
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
{
|
||||
image.color = ConvertColor("#353543");
|
||||
}
|
||||
break;
|
||||
case Type.Border:
|
||||
{
|
||||
outline.enabled = true;
|
||||
image.color = ConvertColor("#3D3E4D");
|
||||
}
|
||||
break;
|
||||
case Type.Primary:
|
||||
{
|
||||
image.color = ConvertColor("#F93086");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void BindEvent()
|
||||
{
|
||||
//鼠标进入
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerEnter, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
{
|
||||
image.color = ConvertColor("#5C5C6E");
|
||||
}
|
||||
break;
|
||||
case Type.Border:
|
||||
{
|
||||
outline.effectColor = Color.white;
|
||||
}
|
||||
break;
|
||||
case Type.Primary:
|
||||
{
|
||||
image.color = ConvertColor("#FF528A");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
//鼠标离开
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
{
|
||||
image.color = ConvertColor("#353543");
|
||||
}
|
||||
break;
|
||||
case Type.Border:
|
||||
{
|
||||
outline.effectColor = ConvertColor("#474759");
|
||||
}
|
||||
break;
|
||||
case Type.Primary:
|
||||
{
|
||||
image.color = ConvertColor("#F93086");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
//按下
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerDown, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
{
|
||||
image.color = ConvertColor("#23232D");
|
||||
}
|
||||
break;
|
||||
case Type.Border:
|
||||
{
|
||||
outline.effectColor = ConvertColor("#353543");
|
||||
text.color = ConvertColor("#414251");
|
||||
image.color = ConvertColor("#23232D");
|
||||
}
|
||||
break;
|
||||
case Type.Primary:
|
||||
{
|
||||
image.color = ConvertColor("#BD2255");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
//松开
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerUp, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
{
|
||||
image.color = ConvertColor("#5C5C6E");
|
||||
}
|
||||
break;
|
||||
case Type.Border:
|
||||
{
|
||||
outline.effectColor = Color.white;
|
||||
text.color = Color.white;
|
||||
}
|
||||
break;
|
||||
case Type.Primary:
|
||||
{
|
||||
image.color = ConvertColor("#FF528A");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
public void SetEnabled(bool value)
|
||||
{
|
||||
base.enabled = value;
|
||||
if (base.enabled)
|
||||
{
|
||||
InitColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
text.color = ConvertColor("#353543");
|
||||
if (outline != null)
|
||||
{
|
||||
outline.enabled = false;
|
||||
}
|
||||
image.color = ConvertColor("#414251");
|
||||
}
|
||||
}
|
||||
|
||||
private Color ConvertColor(string colorStr)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString(colorStr, out Color color);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
public class Alert : PFUIPanel
|
||||
{
|
||||
private Text text;
|
||||
private Button button;
|
||||
protected override void Awake()
|
||||
{
|
||||
//var rect = this.gameObject.AddComponent<RectTransform>();
|
||||
//var layout = this.gameObject.AddComponent<VerticalLayoutGroup>();
|
||||
//layout.spacing = 20f;
|
||||
//layout.childAlignment = TextAnchor.MiddleCenter;
|
||||
|
||||
var wrap = this.transform.Find("GameObject");
|
||||
|
||||
text = wrap.Find("Text").GetComponent<Text>();
|
||||
//text.transform.SetParent(layout.transform);
|
||||
//text.text = "阿斯达克法拉盛地方";
|
||||
///text = layout.transform.GetChild(0).gameObject.AddComponent<Text>();
|
||||
|
||||
//text = GetComponentInChildren<Transform>().gameObject.AddComponent<Text>();
|
||||
|
||||
button = wrap.Find("Button").GetComponent<Button>();
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
this.Close();
|
||||
//this.Destroy(true);
|
||||
//DestroyImmediate(this);
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetText(string txt)
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
text.text = txt;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
//bg.alphaHitTestMinimumThreshold
|
||||
|
||||
var color = bg.color;
|
||||
color.a = 0.6f;
|
||||
bg.color = color;
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
|
||||
bg.DOFade(0, 0.2f).OnComplete(() =>
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ed02cf2a380afd4bae9546154bd13cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -32,9 +32,11 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
base.Awake();
|
||||
|
||||
deviceList = new Dictionary<ushort, DeviceItem>();
|
||||
var closeBtn = this.transform.Find("CloseBtn");
|
||||
Logo = this.transform.Find("Logo").GetComponent<Image>();
|
||||
content = this.transform.Find("Panel").Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
|
||||
|
||||
var container = this.transform.Find("GameObject");
|
||||
var closeBtn = container.Find("CloseBtn");
|
||||
Logo = container.Find("Logo").GetComponent<Image>();
|
||||
content = container.Find("Panel").Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
|
||||
|
||||
UIManager.AddEvent(closeBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eec3152daffe9ff4895d210abfb2ebc5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Login
|
||||
{
|
||||
public static class DayOptions
|
||||
{
|
||||
private static List<Dropdown.OptionData> SetOptions(int day)
|
||||
{
|
||||
var op = new Dropdown.OptionDataList();
|
||||
for (int m = 1; m <= day; m++)
|
||||
{
|
||||
op.options.Add(new Dropdown.OptionData(m.ToString()));
|
||||
}
|
||||
return op.options;
|
||||
}
|
||||
public static List<Dropdown.OptionData> dayOption28 = SetOptions(28);
|
||||
public static List<Dropdown.OptionData> dayOption29 = SetOptions(29);
|
||||
public static List<Dropdown.OptionData> dayOption30 = SetOptions(30);
|
||||
public static List<Dropdown.OptionData> dayOption31 = SetOptions(31);
|
||||
}
|
||||
public class CountryModel
|
||||
{
|
||||
public string country { get;set; }
|
||||
public string abbreviation { get; set; }
|
||||
public string source { get; set; }
|
||||
}
|
||||
public class LoginRegOptions
|
||||
{
|
||||
public List<Dropdown.OptionData> years;
|
||||
public List<Dropdown.OptionData> months;
|
||||
public List<Dropdown.OptionData> days;
|
||||
public List<Dropdown.OptionData> genders;
|
||||
public List<Dropdown.OptionData> countrys;
|
||||
public List<Dropdown.OptionData> units;
|
||||
public int countryDefaultValue;
|
||||
private List<CountryModel> countryList;
|
||||
public LoginRegOptions()
|
||||
{
|
||||
years = new List<Dropdown.OptionData>();
|
||||
for (int y = 1970; y <= 2021; y++)
|
||||
{
|
||||
years.Add(new Dropdown.OptionData(y.ToString()));
|
||||
}
|
||||
months = new List<Dropdown.OptionData>();
|
||||
for (int m = 1; m <= 12; m++)
|
||||
{
|
||||
months.Add(new Dropdown.OptionData(m.ToString()));
|
||||
}
|
||||
days = new List<Dropdown.OptionData>();
|
||||
genders = new List<Dropdown.OptionData>() {new Dropdown.OptionData("Male"), new Dropdown.OptionData("FeMale") };
|
||||
var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
|
||||
countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
|
||||
countrys = countryList.Select(x => new Dropdown.OptionData(x.country)).ToList();
|
||||
countryDefaultValue = countryList.FindIndex(x => x.country == "中国");
|
||||
units = new List<Dropdown.OptionData>() { new Dropdown.OptionData("Metric"), new Dropdown.OptionData("Imperial") };
|
||||
}
|
||||
public Texture GetCountryImage(int index)
|
||||
{
|
||||
var c = countryList[index];
|
||||
if (c == null) return null;
|
||||
return Resources.Load<Texture>(c.source);
|
||||
}
|
||||
public int GetCountryIndexByCode(string code)
|
||||
{
|
||||
var c = countryList.FindIndex(x => x.abbreviation.ToLower() == code.ToLower());
|
||||
if (c == -1) return countryDefaultValue;
|
||||
return c;
|
||||
}
|
||||
public List<Dropdown.OptionData> GetDayOptions(int year,int month)
|
||||
{
|
||||
if (new int[] { 1, 3, 5, 7, 8, 10, 12 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption31;
|
||||
}
|
||||
else if (new int[] { 4, 6, 9, 11 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption30;
|
||||
}
|
||||
else if (month == 2)
|
||||
{
|
||||
return DateTime.IsLeapYear(year) ? DayOptions.dayOption29 : DayOptions.dayOption28;
|
||||
}
|
||||
else
|
||||
{
|
||||
return days;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca65c2211952c474ebd054dbec009223
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class QuickLoginScroll : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private ScrollRect scroll;
|
||||
private Transform content;
|
||||
private float contentSize;
|
||||
private int count;
|
||||
[SerializeField] Button L, R;
|
||||
void Start()
|
||||
{
|
||||
scroll = gameObject.GetComponent<ScrollRect>();
|
||||
content = gameObject.transform.Find("Viewport").Find("Content");
|
||||
//Initial();
|
||||
if (L != null)
|
||||
{
|
||||
L.onClick.AddListener(goLeft);
|
||||
}
|
||||
if (R != null)
|
||||
{
|
||||
R.onClick.AddListener(goRight);
|
||||
}
|
||||
}
|
||||
public void Initial()
|
||||
{
|
||||
count = content.childCount;
|
||||
if (content.childCount - 2 > 0)
|
||||
{
|
||||
contentSize = 1f / (content.childCount - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
contentSize = 0;
|
||||
}
|
||||
//scroll.horizontalNormalizedPosition = 0;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
scroll.horizontalNormalizedPosition = contentSize/2;
|
||||
SetColor();
|
||||
}
|
||||
void goLeft()
|
||||
{
|
||||
if (scroll.horizontalNormalizedPosition <= contentSize) return;
|
||||
if (!start) startPosition = scroll.horizontalNormalizedPosition;
|
||||
start = true;
|
||||
scrollValue = -1 * contentSize / 30;
|
||||
}
|
||||
void goRight()
|
||||
{
|
||||
if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
|
||||
if (!start) startPosition = scroll.horizontalNormalizedPosition;
|
||||
start = true;
|
||||
scrollValue = contentSize / 30;
|
||||
}
|
||||
private bool start = false, _lock = false;
|
||||
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
|
||||
void SetColor()
|
||||
{
|
||||
int index = (int)System.Math.Round(
|
||||
(scroll.horizontalNormalizedPosition + (contentSize / 2)) / contentSize,
|
||||
0);
|
||||
for (int i = 1; i < content.childCount-1; i++)
|
||||
{
|
||||
string c;
|
||||
if (i == index)
|
||||
{
|
||||
content.GetChild(i).GetComponent<QuickLoginUser>().setActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
content.GetChild(i).GetComponent<QuickLoginUser>().setNoActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
totalScrollValue += scrollValue;
|
||||
if (System.Math.Abs(totalScrollValue) >= contentSize)
|
||||
{
|
||||
scrollValue = 0;
|
||||
start = false;
|
||||
scroll.horizontalNormalizedPosition = startPosition + totalScrollValue;
|
||||
//Debug.Log();
|
||||
|
||||
SetColor();
|
||||
totalScrollValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += scrollValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a77e784c857a15f4593d004821ce2757
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class QuickLoginUser : MonoBehaviour
|
||||
{
|
||||
QUserInfo user;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
public void Initial(QUserInfo user)
|
||||
{
|
||||
if (user ==null) return;
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
ApiBase.SetCookie(user.Cookie);
|
||||
var r = ConfigHelper.userApi.GetUserInfo();
|
||||
if (r.result)
|
||||
{
|
||||
//ConfigHelper.CurrentUser = r.data.Value<UserResultModel>("user");
|
||||
//ConfigHelper.CurrentUser = re;
|
||||
var usermodel = r.data.Value<JObject>("user");
|
||||
//App.CurrentUser = new UserModel
|
||||
//{
|
||||
// NickName = usermodel.Value<string>("NickName"),
|
||||
// Ftp = usermodel.Value<int>("FTP"),
|
||||
// Weight = usermodel.Value<double>("Weight"),
|
||||
// BicycleWeight = usermodel.Value<double>("BicycleWeight"),
|
||||
// Carlories = "",
|
||||
// Avatar = usermodel.Value<string>("WxHeadImg"),
|
||||
// Distance = 0,
|
||||
// Climb = "",
|
||||
//};
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
});
|
||||
this.user = user;
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("Avatar").GetComponent<RawImage>(),user.Avatar);
|
||||
transform.Find("NickNameText").GetComponent<Text>().text = user.NickName;
|
||||
transform.Find("BtnDelete").GetComponent<Button>().onClick.AddListener(DestroySelf);
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
}
|
||||
void DestroySelf()
|
||||
{
|
||||
var content = transform.parent;
|
||||
var index = transform.GetSiblingIndex() - 1;
|
||||
DestroyImmediate(gameObject);
|
||||
//if (content.childCount == 2)
|
||||
//{
|
||||
// var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
|
||||
// info.GetComponent<QuickLoginUser>().Initial(null);
|
||||
// info.parent = content;
|
||||
// info.localScale = new Vector3(1, 1, 1);
|
||||
// content.Find("empty1").transform.SetSiblingIndex(0);
|
||||
// content.Find("empty2").transform.SetSiblingIndex(content.childCount - 1);
|
||||
//}
|
||||
content.parent.parent.GetComponent<QuickLoginScroll>().Initial();
|
||||
DeleteList(index);
|
||||
}
|
||||
|
||||
private void DeleteList(int index)
|
||||
{
|
||||
var userInfosJson = PlayerPrefs.GetString("UserInfos");
|
||||
var userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
|
||||
userInfos.RemoveAt(index);
|
||||
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
|
||||
}
|
||||
|
||||
public void setActive()
|
||||
{
|
||||
//ColorUtility.TryParseHtmlString("#ffffffff", out Color color);
|
||||
//transform.Find("Avatar").GetComponent<RawImage>().color = color;
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(1f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = true;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = true;
|
||||
}
|
||||
public void setNoActive()
|
||||
{
|
||||
//ColorUtility.TryParseHtmlString("#ffffff80", out Color color);
|
||||
//transform.Find("Avatar").GetComponent<RawImage>().color = color;
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(0.5f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = false;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26e36fe24c739ed4eb5fc882dc2a1340
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public float scrollSpeed = 10f;
|
||||
private bool mouseOver = false;
|
||||
|
||||
private List<Selectable> m_Selectables = new List<Selectable>();
|
||||
private ScrollRect m_ScrollRect;
|
||||
|
||||
private Vector2 m_NextScrollPosition = Vector2.up;
|
||||
void OnEnable()
|
||||
{
|
||||
if (m_ScrollRect)
|
||||
{
|
||||
m_ScrollRect.content.GetComponentsInChildren(m_Selectables);
|
||||
}
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
m_ScrollRect = GetComponent<ScrollRect>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
if (m_ScrollRect)
|
||||
{
|
||||
m_ScrollRect.content.GetComponentsInChildren(m_Selectables);
|
||||
}
|
||||
ScrollToSelected(true);
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
// Scroll via input.
|
||||
InputScroll();
|
||||
if (!mouseOver)
|
||||
{
|
||||
// Lerp scrolling code.
|
||||
m_ScrollRect.normalizedPosition = Vector2.Lerp(m_ScrollRect.normalizedPosition, m_NextScrollPosition, scrollSpeed * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NextScrollPosition = m_ScrollRect.normalizedPosition;
|
||||
}
|
||||
}
|
||||
void InputScroll()
|
||||
{
|
||||
if (m_Selectables.Count > 0)
|
||||
{
|
||||
if (Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical") || Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
|
||||
{
|
||||
ScrollToSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ScrollToSelected(bool quickScroll)
|
||||
{
|
||||
int selectedIndex = -1;
|
||||
Selectable selectedElement = EventSystem.current.currentSelectedGameObject ? EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>() : null;
|
||||
|
||||
if (selectedElement)
|
||||
{
|
||||
selectedIndex = m_Selectables.IndexOf(selectedElement);
|
||||
}
|
||||
if (selectedIndex > -1)
|
||||
{
|
||||
if (quickScroll)
|
||||
{
|
||||
m_ScrollRect.normalizedPosition = new Vector2(0, 1 - (selectedIndex / ((float)m_Selectables.Count - 1)));
|
||||
m_NextScrollPosition = m_ScrollRect.normalizedPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NextScrollPosition = new Vector2(0, 1 - (selectedIndex / ((float)m_Selectables.Count - 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
mouseOver = true;
|
||||
}
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
mouseOver = false;
|
||||
ScrollToSelected(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6af95c5bd558984fb9ce789f2f13d0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class MyMap
|
||||
public int rank { get; set; }
|
||||
public string image { get; set; }
|
||||
}
|
||||
public class MapScript : MonoBehaviour
|
||||
public class MapItem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
//[SerializeField] Text text;
|
||||
File renamed without changes.
@@ -6,12 +6,15 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class DeviceController : PFUIPanel
|
||||
{
|
||||
public Toggle toggle;
|
||||
private float timer = 1.0f;
|
||||
private Button mReturnBtn;
|
||||
private Image antStatus;
|
||||
private Sprite ant0;
|
||||
private Sprite ant1;
|
||||
protected override void Awake()
|
||||
{
|
||||
AntConnector.Instance();
|
||||
@@ -27,24 +30,17 @@ public class DeviceController : PFUIPanel
|
||||
// UIManager.ShowHomePanel();
|
||||
//});
|
||||
|
||||
this.toggle = this.transform.Find("Toggle").GetComponent<Toggle>();
|
||||
this.toggle.onValueChanged.AddListener(s =>
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
this.toggle.transform.GetComponentInChildren<UnityEngine.UI.Text>().color = Color.green;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.toggle.transform.GetComponentInChildren<UnityEngine.UI.Text>().color = Color.gray;
|
||||
}
|
||||
});
|
||||
|
||||
mReturnBtn = this.transform.Find("ReturnBtn").GetComponent<Button>();
|
||||
UIManager.AddEvent(mReturnBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
UIManager.AddEvent(mReturnBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
}));
|
||||
|
||||
var bg = this.transform.Find("Status").Find("Bg");
|
||||
antStatus = bg.Find("Ant+").GetComponent<Image>();
|
||||
|
||||
ant0 = Resources.Load<Sprite>("Images/ANT+_0");
|
||||
ant1 = Resources.Load<Sprite>("Images/ANT+_1");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -53,6 +49,14 @@ public class DeviceController : PFUIPanel
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
if (AntConnector.Instance().IsAvailable)
|
||||
{
|
||||
antStatus.sprite = ant1;
|
||||
}
|
||||
else
|
||||
{
|
||||
antStatus.sprite = ant0;
|
||||
}
|
||||
//this.toggle.isOn = AntConnector.Instance().IsAvailable;
|
||||
|
||||
//foreach (var item in AntConnector.Instance().discoveredDevices)
|
||||
|
||||
@@ -1,14 +1,131 @@
|
||||
using System.Collections;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EditUserController : PFUIPanel
|
||||
{
|
||||
private Button mSaveButton;
|
||||
private PFUIDropdown mSexDropdown;
|
||||
private PFUIDropdown mDayDropdown;
|
||||
private PFUIDropdown mMonthDropdown;
|
||||
private PFUIDropdown mYearDropdown;
|
||||
private Text mIdText;
|
||||
private Text mNameText;
|
||||
private RawImage mHeadImage;
|
||||
private UserApi userApi;
|
||||
protected override void Awake()
|
||||
{
|
||||
userApi = new UserApi();
|
||||
|
||||
mIdText = this.transform.Find("IdText").GetComponent<Text>();
|
||||
mNameText = this.transform.Find("NameText").GetComponent<Text>();
|
||||
var panel = this.transform.Find("Panel");
|
||||
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
|
||||
mYearDropdown = panel.Find("YearDropdown").GetComponent<PFUIDropdown>();
|
||||
mMonthDropdown = panel.Find("MonthDropdown").GetComponent<PFUIDropdown>();
|
||||
mDayDropdown = panel.Find("DayDropdown").GetComponent<PFUIDropdown>();
|
||||
mSaveButton = this.transform.Find("SaveButton").GetComponent<Button>();
|
||||
mHeadImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
||||
|
||||
mSexDropdown.ClearOptions();
|
||||
mSexDropdown.AddOptions(new List<string>
|
||||
{
|
||||
"男","女"
|
||||
});
|
||||
|
||||
|
||||
mYearDropdown.ClearOptions();
|
||||
var years = new List<string>();
|
||||
for (int i = 1960; i < 2099; i++)
|
||||
{
|
||||
years.Add(i.ToString());
|
||||
}
|
||||
|
||||
mYearDropdown.AddOptions(years);
|
||||
mYearDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
//Debug.Log(index);
|
||||
SetDayDropdown();
|
||||
};
|
||||
|
||||
mMonthDropdown.ClearOptions();
|
||||
var months = new List<string>();
|
||||
for (int i = 1; i < 13; i++)
|
||||
{
|
||||
months.Add(i.ToString());
|
||||
}
|
||||
mMonthDropdown.AddOptions(months);
|
||||
//mMonthDropdown.SelectValue("9");
|
||||
mMonthDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
SetDayDropdown();
|
||||
};
|
||||
|
||||
|
||||
mDayDropdown.ClearOptions();
|
||||
SetDayDropdown();
|
||||
|
||||
//mDayDropdown.AddOptions()
|
||||
|
||||
//mDayDropdown.AddOptions(new List<Dropdown.OptionData>
|
||||
//{
|
||||
// new Dropdown.OptionData()
|
||||
//});
|
||||
|
||||
LoadDataSync();
|
||||
|
||||
}
|
||||
|
||||
async void LoadDataSync()
|
||||
{
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)mHeadImage.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
mHeadImage.material = material;
|
||||
|
||||
var currentUser = App.CurrentUser;
|
||||
mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
mNameText.text = currentUser.Nickname;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
}
|
||||
if (currentUser.Sex == 1)
|
||||
{
|
||||
mSexDropdown.SelectValue("男");
|
||||
}
|
||||
else
|
||||
{
|
||||
mSexDropdown.SelectValue("女");
|
||||
}
|
||||
if (currentUser.Birthday.HasValue)
|
||||
{
|
||||
var birthday = currentUser.Birthday.Value;
|
||||
mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
}
|
||||
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -16,4 +133,40 @@ public class EditUserController : PFUIPanel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SetDayDropdown()
|
||||
{
|
||||
mDayDropdown.ClearOptions();
|
||||
var year = mYearDropdown.SelectedItem;
|
||||
var month = mMonthDropdown.SelectedItem;
|
||||
|
||||
//var date = new DateTime(int.Parse(year), int.Parse(month), 1);
|
||||
var days = DateTime.DaysInMonth(int.Parse(year), int.Parse(month));
|
||||
var list = new List<string>();
|
||||
for (int i = 1; i <= days; i++)
|
||||
{
|
||||
list.Add(i.ToString());
|
||||
}
|
||||
mDayDropdown.ClearOptions();
|
||||
mDayDropdown.AddOptions(list);
|
||||
}
|
||||
|
||||
async void Save(BaseEventData e)
|
||||
{
|
||||
//var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
|
||||
//user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
|
||||
//user.Sex = mSexDropdown.SelectedItem == "男" ? 1 : 2;
|
||||
|
||||
//var result = await userApi.Update(user);
|
||||
//if (result.result == false)
|
||||
//{
|
||||
// UIManager.ShowAlert(result.errMsg);
|
||||
// return;
|
||||
//}
|
||||
|
||||
//App.CurrentUser = user;
|
||||
|
||||
UIManager.ShowAlert("result.errMsg");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,17 +12,17 @@ using UnityEngine.UI;
|
||||
|
||||
public class HomeController : PFUIPanel
|
||||
{
|
||||
[SerializeField] Text Ftp;
|
||||
[SerializeField] RawImage Avatar;
|
||||
[SerializeField] Text Weight;
|
||||
[SerializeField] Text WKG;
|
||||
[SerializeField] Text Calories;
|
||||
[SerializeField] Text KM;
|
||||
[SerializeField] Text Climb;
|
||||
[SerializeField] Text NickName;
|
||||
[SerializeField] Button More;
|
||||
//[SerializeField] Text Ftp;
|
||||
//[SerializeField] RawImage Avatar;
|
||||
//[SerializeField] Text Weight;
|
||||
//[SerializeField] Text WKG;
|
||||
//[SerializeField] Text Calories;
|
||||
//[SerializeField] Text KM;
|
||||
//[SerializeField] Text Climb;
|
||||
//[SerializeField] Text NickName;
|
||||
//[SerializeField] Button More;
|
||||
[SerializeField] Button BtnRide;
|
||||
|
||||
[SerializeField] Transform userInfo;
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
@@ -33,11 +35,10 @@ public class HomeController : PFUIPanel
|
||||
// toast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
|
||||
// toast.transform.parent = parent;
|
||||
//}
|
||||
//if (ConfigHelper.CurrentUser != null)
|
||||
//{
|
||||
// SetCurrentUser();
|
||||
// GetSummary();
|
||||
//}
|
||||
if (App.CurrentUser != null)
|
||||
{
|
||||
GetSummary();
|
||||
}
|
||||
//if (More != null)
|
||||
//{
|
||||
// More.onClick.AddListener(MoreFunc);
|
||||
@@ -50,41 +51,73 @@ public class HomeController : PFUIPanel
|
||||
UIManager.ShowDevicePanel();
|
||||
});
|
||||
|
||||
var avatar = this.transform.Find("UserInfo").Find("Image");
|
||||
var avatar = userInfo.Find("Avatar");
|
||||
UIManager.AddEvent(avatar.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
if (App.CurrentUser == null)
|
||||
{
|
||||
Login();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Login()
|
||||
{
|
||||
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
|
||||
private void GoRide()
|
||||
{
|
||||
UIManager.ShowMapListPanel();
|
||||
//SceneManager.LoadScene("3-MapList");
|
||||
//DOTween.To()
|
||||
//this.transform.DOLocalMove(new Vector2(1000, 0), 2.0f).SetEase(Ease.InOutExpo).OnComplete(() =>
|
||||
//{
|
||||
//Loom.QueueOnMainThread(() =>
|
||||
//{
|
||||
// Debug.Log("ddddddddddddddddddddddddddd");
|
||||
//});
|
||||
//});
|
||||
}
|
||||
|
||||
void MoreFunc()
|
||||
{
|
||||
Utils.showToast(gameObject, "更多信息", 1);
|
||||
//Utils.showToast(gameObject, "更多信息", 1);
|
||||
|
||||
//DOTween.ToAlpha(() => )
|
||||
|
||||
}
|
||||
|
||||
void SetCurrentUser()
|
||||
{
|
||||
var user = App.CurrentUser;
|
||||
Ftp.text = user.FTP.ToString();
|
||||
Weight.text = user.Weight.ToString();
|
||||
WKG.text = $"{user.Weight}KG/{user.BicycleWeight}KG";
|
||||
NickName.text = user.Nickname;
|
||||
Utils.DisplayImage(StartCoroutine, Avatar, user.WxHeadImg);
|
||||
userInfo.Find("NickName").GetComponent<Text>().text = App.CurrentUser.Nickname;
|
||||
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpValue").GetComponent<Text>().text = App.CurrentUser.FTP.ToString();
|
||||
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightValue").GetComponent<Text>().text = App.CurrentUser.Weight.ToString();
|
||||
userInfo.Find("GroupTop").Find("WKGContainer").Find("WKGValue").GetComponent<Text>().text = $"{App.CurrentUser.Weight}kg/{App.CurrentUser.BicycleWeight}kg";
|
||||
//userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = App.CurrentUser.Carlories;
|
||||
//userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = App.CurrentUser.Distance.ToString("#0.00");
|
||||
//userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = App.CurrentUser.Climb;
|
||||
//var user = ConfigHelper.CurrentUser;
|
||||
//Ftp.text = user.FTP.ToString();
|
||||
//Weight.text = user.Weight.ToString();
|
||||
//WKG.text = $"{user.Weight}KG/{user.BicycleWeight}KG";
|
||||
//NickName.text = user.Nickname;
|
||||
//Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.Avatar);
|
||||
}
|
||||
void GetSummary()
|
||||
{
|
||||
var res = ConfigHelper.userApi.GetSummary();
|
||||
if (res.result)
|
||||
{
|
||||
KM.text = $"{res.data.TotalDistance.ToString("#0.00")}KM";
|
||||
Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//App.CurrentUser.Distance = res.data.TotalDistance;
|
||||
//App.CurrentUser.Climb = res.data.TotalClimb;
|
||||
//App.CurrentUser.Carlories = res.data.Kcal;
|
||||
SetCurrentUser();
|
||||
//Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
//Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//Calories.text = res.data.
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MapController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 969b87ed3066bec4a9981a69d7dfb8e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MapDetailController : MonoBehaviour
|
||||
public class MapDetailController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
[HideInInspector] public int id = 0;
|
||||
@@ -38,7 +38,7 @@ public class MapDetailController : MonoBehaviour
|
||||
{
|
||||
transform.Find("BtnReturn").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
UIManager.ShowMapListPanel();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MapListController : MonoBehaviour
|
||||
public class MapListController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
[SerializeField] GameObject map;
|
||||
@@ -20,6 +20,8 @@ public class MapListController : MonoBehaviour
|
||||
[HideInInspector] public int pageIndex = 0;
|
||||
[HideInInspector] public int pageSize = 20;
|
||||
[HideInInspector] public string hard = "全部";
|
||||
|
||||
private Button returnBtn;
|
||||
public GameObject Content {
|
||||
get
|
||||
{
|
||||
@@ -27,7 +29,7 @@ public class MapListController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
private bool isEnd = false;
|
||||
void Start()
|
||||
protected override void Start()
|
||||
{
|
||||
//if (hardSelector != null)
|
||||
//{
|
||||
@@ -51,6 +53,16 @@ public class MapListController : MonoBehaviour
|
||||
//UIManager.AddEvent(transform.Find("Panel").Find("Panel"))
|
||||
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
|
||||
//obj.transform.parent = transform.parent;
|
||||
|
||||
var btnQuit = this.transform.Find("BtnQuit");
|
||||
if(btnQuit != null)
|
||||
{
|
||||
returnBtn = btnQuit.GetComponent<Button>();
|
||||
UIManager.AddEvent(returnBtn.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
@@ -103,7 +115,7 @@ public class MapListController : MonoBehaviour
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(map);
|
||||
obj.GetComponent<MapScript>().Initial(item);
|
||||
obj.GetComponent<MapItem>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content.transform;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
|
||||
@@ -17,9 +17,24 @@ public class PFUIPanel : UIBehaviour
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
public virtual void Show()
|
||||
{
|
||||
base.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public virtual void Close()
|
||||
{
|
||||
DestroyImmediate(this.gameObject);
|
||||
//DestroyImmediate(this.gameObject);
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void AddChild(PFUIPanel child)
|
||||
{
|
||||
if(child == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
child.transform.SetParent(this.transform);
|
||||
}
|
||||
}
|
||||
//}
|
||||
+64
-16
@@ -3,11 +3,12 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using DG.Tweening;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
private GameObject mMainPanel;
|
||||
public GameObject MainPanel
|
||||
private PFUIPanel mMainPanel;
|
||||
public PFUIPanel MainPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -82,8 +83,8 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject mModalsPanel;
|
||||
public GameObject ModalsPanel
|
||||
private PFUIPanel mModalsPanel;
|
||||
public PFUIPanel ModalsPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -133,7 +134,26 @@ public class UIManager : MonoBehaviour
|
||||
return internalComponent;
|
||||
}
|
||||
|
||||
public static void Show(MonoBehaviour panelToShow, GameObject parent = null, bool modal = false)
|
||||
private T GetInstance<T>(string prefabName, ref T internalComponent)
|
||||
{
|
||||
if (internalComponent == null)
|
||||
{
|
||||
UnityEngine.Object @object = Resources.Load("UI/Prefab/" + prefabName);
|
||||
if (@object != null)
|
||||
{
|
||||
GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(@object, base.transform.parent, false);
|
||||
if (gameObject != null)
|
||||
{
|
||||
internalComponent = gameObject.GetComponent<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return internalComponent;
|
||||
}
|
||||
|
||||
private static PFUIPanel prePanel = null;
|
||||
public static void Show(PFUIPanel panelToShow, PFUIPanel parent = null, bool modal = false)
|
||||
{
|
||||
if (UIManager.Instance == null || panelToShow == null)
|
||||
{
|
||||
@@ -144,30 +164,38 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
parent = UIManager.Instance.ModalsPanel;
|
||||
}
|
||||
|
||||
foreach (Transform child in parent.transform)
|
||||
else
|
||||
{
|
||||
//GameObject.Destroy(child);
|
||||
//GameObject.Destroy(child.gameObject);
|
||||
child.gameObject.SetActive(false);
|
||||
if(prePanel != null)
|
||||
{
|
||||
prePanel.Close();
|
||||
}
|
||||
prePanel = panelToShow;
|
||||
}
|
||||
//foreach (Transform child in parent.transform)
|
||||
//{
|
||||
// //GameObject.Destroy(child);
|
||||
// //GameObject.Destroy(child.gameObject);
|
||||
// child.gameObject.SetActive(false);
|
||||
//}
|
||||
|
||||
//var panel = UIManager.Instance.MainPanel; //UIManager.Instance.MainCanvasTransform.transform.Find("Panel");
|
||||
|
||||
//panel.gameObject.AddComponent<GameObject>(panelToShow.gameObject);
|
||||
panelToShow.transform.SetParent(parent.transform);
|
||||
|
||||
panelToShow.gameObject.SetActive(true);
|
||||
//panelToShow.transform.SetParent(parent.transform);
|
||||
parent.AddChild(panelToShow);
|
||||
//panelToShow.gameObject.SetActive(true);
|
||||
panelToShow.Show();
|
||||
//panelToShow.transform.position = new Vector3(0, 0, 0);
|
||||
panelToShow.transform.localPosition = new Vector3(0, 0, 0);
|
||||
//panelToShow.transform.localRotation = new Quaternion(0, 0, 0, 0);
|
||||
|
||||
if (modal == false)
|
||||
//if (modal == false)
|
||||
{
|
||||
panelToShow.transform.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
|
||||
panelToShow.transform.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
|
||||
}
|
||||
panelToShow.transform.localScale = parent.transform.localScale;
|
||||
|
||||
panelToShow.transform.localScale = parent.transform.localScale;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,6 +277,26 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public Alert alert = null;
|
||||
public static void ShowAlert(string msg)
|
||||
{
|
||||
if(UIManager.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UIManager.Instance.alert == null)
|
||||
{
|
||||
UIManager.Instance.alert = UIManager.Instance.GetInstance<Alert>("Alert", ref UIManager.Instance.alert);
|
||||
UIManager.Instance.alert.SetText(msg);
|
||||
UIManager.Show(UIManager.Instance.alert, null, true);
|
||||
}
|
||||
else {
|
||||
UIManager.Instance.alert.Show();
|
||||
UIManager.Instance.alert.SetText(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -80,5 +81,15 @@ namespace Assets.Scripts
|
||||
return FindUpParent(zi.parent);
|
||||
}
|
||||
/*获取最顶层对象*/
|
||||
|
||||
|
||||
|
||||
public static Color HexToColor(string hex)
|
||||
{
|
||||
byte r = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
|
||||
byte g = byte.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
|
||||
byte b = byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
|
||||
return new Color32(r, g, b, byte.MaxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user