Merge remote-tracking branch 'origin/dev' into dev_lishuo

This commit is contained in:
lishuo committed 2021-04-23 09:37:55 +08:00
commit a96d538dc1
86 files changed
+8879 -1515

No files matched your search

+17
View File
@@ -106,6 +106,23 @@ namespace Assets.Scripts.Apis
//{
// return http.Get(ConfigHelper.Host + url, query);
//}
protected async Task<string> GetStringAsync(string url)
{
//var result = await Task.Factory.StartNew(() =>
//{
// return Get(url, query);
//});
//return result;
AddLanguage();
var response = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
return await ParseStringAsync(response);
}
async Task<string> ParseStringAsync(HttpResponseMessage response)
{
return await response.Content.ReadAsStringAsync();
}
protected async Task<T> GetAsync<T>(string url)
{
+2 -2
View File
@@ -56,11 +56,11 @@ namespace Assets.Scripts.Apis
/// <param name="sort">hot, distance</param>
/// <param name="sortDire">asc</param>
/// <returns></returns>
public JsonResult<List<MapRoute>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false)
public Task<JsonResult<List<MapRoute>>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false)
{
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }&isFav={isFav}";
return Get<JsonResult<List<MapRoute>>>(url);
return GetAsync<JsonResult<List<MapRoute>>>(url);
}
/// <summary>
@@ -46,5 +46,7 @@ namespace Assets.Scripts.Apis.Models
public double CompleteRoute { get; set; }
public string Tips { get; set; }
}
}
@@ -63,5 +63,11 @@ namespace Assets.Scripts.Apis.Models
public string Unionid { get; set; }
public int Height { get; set; }
public DateTime LastUpdateFtpTime { get; set; }
public DateTime LastUpdateWeightTime { get; set; }
public DateTime LastUpdateBicycleWeightTime { get; set; }
}
}
+71 -13
View File
@@ -1,4 +1,5 @@
using Assets.Scripts.Apis.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -66,6 +67,9 @@ namespace Assets.Scripts.Apis
user.ConnectedToStrava = ret.data.ConnectedToStrava;
}
user.Birthday = ret.data.Birthday;
user.LastUpdateFtpTime = ret.data.LastUpdateFtpTime;
user.LastUpdateWeightTime = ret.data.LastUpdateWeightTime;
user.LastUpdateBicycleWeightTime = ret.data.LastUpdateBicycleWeightTime;
//todo: check local database, insert new user
//PubCommData.CurrentUser = user;
@@ -77,7 +81,37 @@ namespace Assets.Scripts.Apis
return new JsonResult<UserResultModel>() { result = false, data = null, errMsg = ret.errMsg };
}
}
public async Task<JsonResult<object>> LoginV1(string phone, string pwd, string countryCode)
{
var param = new
{
Phone = phone,
Pwd = pwd,
countryCode
};
JsonResult<object> ret = null;
try
{
ret = await PostAsync<JsonResult<object>>("NoAuth/v1/Login", param);
}
catch (Exception ex)
{
return new JsonResult<object> { result = false, errMsg = ex.Message };
}
//ApiBase.cookies = response.Cookies;
//var ret = response.DynamicBody;
if (ret.result)
{
var user = JObject.FromObject(ret.data).ToObject<UserResultModel>();
user.cookie = cookies[0].Value;
return new JsonResult<object>() { result = true, data = user };
}
else
{
return new JsonResult<object>() { result = false, data = ret.data, errMsg = ret.errMsg };
}
}
/// <summary>
/// 获取个人中心的统计信息
/// </summary>
@@ -95,7 +129,7 @@ namespace Assets.Scripts.Apis
return DateTime.Parse(result);
}
public async Task<JsonResult<UserResultModel>> Register(string Phone, string Pwd, string Captcha)
public async Task<JsonResult<object>> Register(string Phone, string Pwd, string Captcha)
{
var param = new
{
@@ -104,18 +138,31 @@ namespace Assets.Scripts.Apis
Captcha
};
JsonResult<UserResultModel> ret = null;
JsonResult<object> ret = null;
try
{
ret = await PostAsync<JsonResult<UserResultModel>>("NoAuth/v1/Register", param);
ret.data.cookie = cookies[0].Value;
ret = await PostAsync<JsonResult<object>>("NoAuth/v1/Register", param);
if (ret.result)
{
var u = JObject.FromObject(ret.data).ToObject<UserResultModel>();
u.cookie = cookies[0].Value;
return new JsonResult<object> { result = true, data = u,errMsg = ret.errMsg};
}
else
{
return new JsonResult<object> { result = false,data = ret.data, errMsg = ret.errMsg };
}
}
catch (Exception ex)
{
return new JsonResult<UserResultModel> { result = false, errMsg = ex.Message };
return new JsonResult<object> { result = false, errMsg = ex.Message };
}
return ret;
}
public async Task<string> GetHeadImg(string phone)
{
return await GetStringAsync($"noauth/getheadimg?phone={phone}");
}
public async Task<JsonResult<JObject>> GetCaptcha(string phone)
{
return await PostAsync<JsonResult<JObject>>("NoAuth/v1/GetCaptcha",new {phone });
@@ -154,16 +201,25 @@ namespace Assets.Scripts.Apis
}
return r;
}
public async Task<JsonResult<UserResultModel>> OnWebWxLogin(string Phone, string Captcha
public async Task<JsonResult<object>> OnWebWxLogin(string Phone, string Captcha
, string UnionId, string WxWebOpenId, string WxHeadImg, string NickName, int? Sex, string Password)
{
var r = await PostAsync<JsonResult<UserResultModel>>("NoAuth/OnWebWxLogin",
new { Phone, Captcha, UnionId, WxWebOpenId, WxHeadImg, NickName, Sex, Password });
r.data.cookie = cookies[0].Value;
return r;
var r = await PostAsync<JsonResult<object>>("NoAuth/OnWebWxLogin",
new { Phone, Captcha, UnionId, WxWebOpenId, WxHeadImg, NickName, Sex, Pwd = Password });
if (r.result)
{
var u = JObject.FromObject(r.data);
u.Add("cookie", cookies[0].Value);
return new JsonResult<object> { result = true, data = u, errMsg = r.errMsg };
}
else return r;
}
public async Task<JsonResult<object>> AddFeedBack(string content, List<string> files)
{
var res = Upload("feedback/add", new { content } , files);
return Newtonsoft.Json.JsonConvert.DeserializeObject<JsonResult<object>>(res);
}
public async Task<JsonResult<JObject>> Update(UserResultModel currUser, string filePath = "")
{
//return await PostAsync<JsonResult<dynamic>>("User/UpdateUserSetting", new {
@@ -223,5 +279,7 @@ namespace Assets.Scripts.Apis
{
return await GetAsync<JsonResult<JObject>>("/Home/GetNotify");
}
}
}
+28 -3
View File
@@ -23,9 +23,34 @@ namespace Assets.Scripts
return _userApi;
}
}
public static MapApi mapApi = new MapApi();
public static MapInterruptRecordApi mapInterruptRecordApi = new MapInterruptRecordApi();
public static ThirdPartApi thirdPartApi = new ThirdPartApi();
private static MapApi _mapApi;
public static MapApi mapApi
{
get
{
if (_mapApi == null) _mapApi = new MapApi();
return _mapApi;
}
}
private static MapInterruptRecordApi _mapInterruptRecordApi;
public static MapInterruptRecordApi mapInterruptRecordApi
{
get
{
if (_mapInterruptRecordApi == null) _mapInterruptRecordApi = new MapInterruptRecordApi();
return _mapInterruptRecordApi;
}
}
public static ThirdPartApi _thirdPartApi;
public static ThirdPartApi thirdPartApi
{
get
{
if (_thirdPartApi == null) _thirdPartApi = new ThirdPartApi();
return _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 -1
View File
@@ -152,7 +152,7 @@ namespace Assets.Scripts.Devices.Ant
private void antDevice_serialError(ANT_Device sender, ANT_Device.serialErrorCode error, bool isCritical)
{
//throw new NotImplementedException();
Log("出错了");
Log("出错了"+ error.ToString());
if (error != ANT_Device.serialErrorCode.DeviceConnectionLost)
return;
+217 -83
View File
@@ -26,6 +26,7 @@ using ZenFulcrum.EmbeddedBrowser;
public class QUserInfo
{
public long Id { get; set; }
public string Phone { get; set; }
public string NickName { get; set; }
public string Avatar { get; set; }
public string Cookie { get; set; }
@@ -59,6 +60,8 @@ public class LoginController : MonoBehaviour
private Transform quickContainer;
private Transform loginContainer;
private Transform signContainer;
//修改高度
Transform LoginBg;
/*初始页面*/
LoginForm loginForm;
[SerializeField] Button loginReturn2;
@@ -74,11 +77,11 @@ public class LoginController : MonoBehaviour
private Transform signScrollBar;
private SignForm signForm;
private LoginRegOptions regOptions;
private ScrollRect scrollPanel;
private ScrollRect scrollSign;
private ScrollRect scrollAvatar;
private Transform imagexf,imagedf;
private Transform imagexf, imagedf;
//注册主页面
private UserResultModel userResult;
/*微信相关*/
@@ -98,7 +101,10 @@ public class LoginController : MonoBehaviour
//其他
[SerializeField] RawImage loading;
Transform toolContainer;
Dictionary<string, Selectable> formDict,signFormDict;
public string avatarName { get; private set; }
public Texture avatar;
// Start is called before the first frame update
void Start()
{
@@ -130,6 +136,7 @@ public class LoginController : MonoBehaviour
if (loginScrollView != null)
{
scrollPanel = loginScrollView.GetComponent<ScrollRect>();
LoginBg = loginScrollView.transform.Find("Viewport").Find("LoginBg");
mainContent = loginScrollView.transform.Find("Viewport").Find("Content");
quickContainer = mainContent.Find("Empty").Find("FormContainer-Quick");
loginContainer = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer");
@@ -140,18 +147,30 @@ public class LoginController : MonoBehaviour
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);
UIManager.AddEvent(signPage1.Find("next").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegNext());
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
UIManager.AddEvent(signPage1.Find("Captcha").Find("BtnGet").gameObject,
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>();
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); });
UIManager.AddEvent(signPage1.Find("previousThird").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goThirdPrev());
//signPage1.Find("previousThird").GetComponent<Button>().onClick.AddListener(goThirdPrev);
UIManager.AddEvent(signPage1.Find("signThird").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegNext(1));
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
signPage2 = content.Find("NextPage");
signPage2.Find("previous").GetComponent<Button>().onClick.AddListener(goRegPrev);
signPage2.Find("sign").GetComponent<Button>().onClick.AddListener(goRegEnd);
UIManager.AddEvent(signPage2.Find("previous").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegPrev());
//signPage2.Find("previous").GetComponent<Button>().onClick.AddListener(goRegPrev);
UIManager.AddEvent(signPage2.Find("sign").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegEnd());
//signPage2.Find("sign").GetComponent<Button>().onClick.AddListener(goRegEnd);
//注册2 字段
var years = signPage2.Find("Year").GetComponent<Dropdown>();
var months = signPage2.Find("Month").GetComponent<Dropdown>();
@@ -168,7 +187,7 @@ public class LoginController : MonoBehaviour
days.captionText.text = "Day";
years.onValueChanged.AddListener((int index) =>
{
if (index != -1 && months.value!=-1)
if (index != -1 && months.value != -1)
{
days.options = regOptions.GetDayOptions(int.Parse(years.captionText.text), int.Parse(months.captionText.text));
days.value = 0;
@@ -213,31 +232,28 @@ public class LoginController : MonoBehaviour
{
scrollAvatar = avatarScrollView.GetComponent<ScrollRect>();
var content = scrollAvatar.transform.Find("Viewport").Find("Content");
foreach (var user in userInfos)
foreach (var user in userInfos)
{
var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
info.GetComponent<QuickLoginUser>().Initial(user,transform);
info.GetComponent<QuickLoginUser>().Initial(user, transform);
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.Find("empty2").transform.SetSiblingIndex(content.childCount - 1);
scrollAvatar.GetComponent<QuickLoginScroll>().Initial();
}
if (quickContainer != null)
if (quickContainer != null)
{
var loginNewAccount = quickContainer.Find("loginNewAccount").GetComponent<Button>();
loginNewAccount.onClick.AddListener(goLogin);
UIManager.AddEvent(loginNewAccount.gameObject, EventTriggerType.PointerClick, (b) => goLogin());
}
if (loginContainer != null)
if (loginContainer != null)
{
var returnQuick = loginContainer.Find("returnQuick").GetComponent<Button>();
UIManager.AddEvent(returnQuick.gameObject, EventTriggerType.PointerClick, (b) =>
{
ReturnQuick();
});
UIManager.AddEvent(returnQuick.gameObject, EventTriggerType.PointerClick, (b) => ReturnQuick());
var sign = loginContainer.Find("reg").GetComponent<Button>();
sign.onClick.AddListener(() => goSign());
UIManager.AddEvent(sign.gameObject, EventTriggerType.PointerClick, (b) => goSign());
remember = loginContainer.Find("rememberButton").GetComponent<Button>();
UIManager.AddEvent(remember.gameObject, EventTriggerType.PointerClick, (b) =>
{
@@ -252,7 +268,7 @@ public class LoginController : MonoBehaviour
}
});
var wechatLogin = loginContainer.Find("otherContainer").Find("Wechat").GetComponent<Button>();
wechatLogin.onClick.AddListener(() =>
UIManager.AddEvent(wechatLogin.gameObject, EventTriggerType.PointerClick, (b) =>
{
if (wxLock) return;
wxLock = true;
@@ -266,8 +282,13 @@ public class LoginController : MonoBehaviour
//wx1.GetComponent<CanvasGroup>().DOFade(1, 0.8f).onComplete = () => { wxLock = false; };
wx1.DOLocalMoveY(0, 0.3f).onComplete = () => { wxLock = false; };
});
//wechatLogin.onClick.AddListener(() =>
//{
//});
var login = loginContainer.Find("login").GetComponent<Button>();
login.onClick.AddListener(Submit);
UIManager.AddEvent(login.gameObject, EventTriggerType.PointerClick, (b) => Submit());
//login.onClick.AddListener(Submit);
loginForm = new LoginForm()
{
email = loginContainer.Find("phone").GetComponent<InputField>(),
@@ -278,7 +299,7 @@ public class LoginController : MonoBehaviour
//{
// loginReturn2.onClick.AddListener(goLoginReturn2);
//}
if (signContainer != null)
if (signContainer != null)
{
var loginr2 = signContainer.Find("loginr2").GetComponent<Button>();
UIManager.AddEvent(loginr2.gameObject, EventTriggerType.PointerClick, (b) =>
@@ -293,14 +314,15 @@ public class LoginController : MonoBehaviour
Application.Quit();
});
}
wxLogin1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
if (wxLogin1 != null)
{
UIManager.AddEvent(wxLogin1.Find("Image").gameObject, EventTriggerType.PointerClick, (b) =>
{
wxLock = true;
wxBrowser.Url = "chrome://version/";
wxBrowser.LoadHTML("<div/>");
//wxBrowser.Url = "chrome://version/";
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
{
wxLock = false;
@@ -329,9 +351,9 @@ public class LoginController : MonoBehaviour
//browser.
}
}
wxLogin2 = mainContent.Find("FormContainer-wx2");
if (wxLogin2!=null)
if (wxLogin2 != null)
{
UIManager.AddEvent(wxLogin2.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
{
@@ -341,7 +363,7 @@ public class LoginController : MonoBehaviour
Canvas.ForceUpdateCanvases();
StartScrollPanel(1);
});
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(()=>
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
{
this.goSign(false);
});
@@ -368,20 +390,15 @@ public class LoginController : MonoBehaviour
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
gou.SetActive(!gou.activeSelf);
});
//wxLogin3.Find("rememberButton").GetComponent<Button>().onClick.AddListener(()=>
//{
//});
wxLogin3.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
UIManager.AddEvent(wxLogin3.Find("Next").gameObject, EventTriggerType.PointerClick, (b) =>
{
goMain(wxLogin3.Find("rememberButton").Find("Gou"));
//goMain
});
}
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
imagedf = transform.Find("Panel").Find("LoginContainer").Find("Imagedf");
toolContainer = transform.Find("Panel").Find("ToolContainer");
if (toolContainer != null)
if (toolContainer != null)
{
UIManager.AddEvent(toolContainer.Find("Setting").gameObject, EventTriggerType.PointerClick, (b) =>
{
@@ -400,19 +417,62 @@ public class LoginController : MonoBehaviour
// UIManager.ShowNewsModal();
//});
}
if (userInfos.Count == 0) goLoginImmediately();
formDict = new Dictionary<string, Selectable>()
{
{"Phone",loginForm.email },
{"Pwd",loginForm.password },
};
loginForm.email.onEndEdit.AddListener(async (s) =>
{
if (!string.IsNullOrEmpty(s) && avatarName!=s)
{
var r = await ConfigHelper.userApi.GetHeadImg(s);
if (!string.IsNullOrEmpty(r))
{
Utils.DisplayImage(StartCoroutine, loginContainer.Find("Avatar").GetComponent<RawImage>(), r);
avatarName = s;
}
else
{
loginContainer.Find("Avatar").GetComponent<RawImage>().texture = avatar;
}
}
});
signFormDict = new Dictionary<string, Selectable>
{
{ "Phone",signForm.email},
{ "Captcha",signForm.captcha},
{ "Pwd",signForm.password},
{ "Years",signForm.years},
{ "Months",signForm.months},
{ "Days",signForm.days},
};
avatar = Resources.Load<Texture>("Images/New Account");
}
private void AdjustWxQrCode()
private void AdjustWxQrCode()
{
wxBrowser.EvalJS(@"
console.log(document.getElementsByClassName('qrcode')[0]);
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';
");
console.log(439,document.body.style.padding);
let time = null;
let f = ()=>{
console.log(442);
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';
if(document.body.style.padding === '0px' && time!=null){
clearInterval(time);
}
}
f();
if(document.body.style.padding !== '0px'){
time = setInterval(f,500);
}");
}
//浏览器加载回调
private async void OnUserScan()
@@ -440,7 +500,7 @@ public class LoginController : MonoBehaviour
if (r.result)
{
JObject data = JObject.FromObject(r.data);
if (data.Value<string>("success")!=null && data.Value<string>("success") == "False")
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
wxLogin2.gameObject.SetActive(true);
Utils.DisplayImage(StartCoroutine,
@@ -500,12 +560,12 @@ public class LoginController : MonoBehaviour
{
var btn = signPage1.Find("Captcha").Find("BtnGet");
var btnText = signPage1.Find("Captcha").Find("BtnGet").Find("Text").GetComponent<Text>();
var Email = signForm.email;
var Email = signForm.email;
var r = await ConfigHelper.userApi.GetCaptcha(Email.text);
//Timer t = new Ti
if (r.result)
{
if (r.data.Value<bool>("isExist") && pageNums == 5)
if (r.data.Value<bool>("isExist") && pageNums == 5)
{
HidePassword();
}
@@ -513,6 +573,7 @@ public class LoginController : MonoBehaviour
btnText.text = $"Again({time})";
System.Timers.Timer timer = new System.Timers.Timer();
btn.GetComponent<Button>().enabled = false;
btn.GetComponent<Button>().interactable = false;
startCaptcha = true;
//timer.Interval = 1000;
//timer.AutoReset = true;
@@ -520,7 +581,7 @@ public class LoginController : MonoBehaviour
//timer.Enabled = true;
//btnGet.
}
else
else
{
Utils.showToast(gameObject, r.errMsg);
}
@@ -537,12 +598,16 @@ public class LoginController : MonoBehaviour
void ShowPassword()
{
signForm.email.text = "";
signForm.password.text = "";
signForm.captcha.text = "";
signForm.cpassword.text = "";
signPage1.Find("Password").gameObject.SetActive(true);
signPage1.Find("CPassword").gameObject.SetActive(true);
signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
}
void CaptchaTimerTick()
void CaptchaTimerTick()
{
timer -= Time.deltaTime;
if (timer <= 0)
@@ -554,13 +619,14 @@ public class LoginController : MonoBehaviour
{
btnText.text = "Get";
btn.GetComponent<Button>().enabled = true;
btn.GetComponent<Button>().interactable = true;
startCaptcha = false;
//timer.Stop();
}
timer = 1.0f;
}
}
private void OnLoginInputDeSelect(BaseEventData arg0, GameObject game)
{
var image = game.transform.GetComponent<Image>();
@@ -569,7 +635,7 @@ public class LoginController : MonoBehaviour
//rect.SetSiblingIndex(rect.childCount-1);
}
private void OnLoginInputSelect(BaseEventData arg0,GameObject game)
private void OnLoginInputSelect(BaseEventData arg0, GameObject game)
{
var image = game.transform.GetComponent<Image>();
image.sprite = Resources.Load<Sprite>("Images/gl");
@@ -588,13 +654,13 @@ public class LoginController : MonoBehaviour
var Captcha = signForm.captcha;
var Password = signForm.password;
var CPassword = signForm.cpassword;
if (Password.text != CPassword.text)
if (Password.text != CPassword.text)
{
Utils.showToast(gameObject,"两次密码输入不一致");
Utils.showToast(gameObject, "两次密码输入不一致");
return;
}
//JsonConvert
JsonResult<UserResultModel> r = null;
JsonResult<object> r = null;
if (signType == 0)
{
r = await ConfigHelper.userApi.Register(Email.text, Password.text, Captcha.text);
@@ -610,17 +676,38 @@ public class LoginController : MonoBehaviour
wxInfoJson.Value<int>("sex"),
Password.text);
}
if (r!=null && r.result)
if (r != null && r.result)
{
RefreshWx3(r.data);
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u);
LoadInfo();
StartScrollSign(1);
}
else
else
{
var errorList = JArray.FromObject(r.data);
SetValidate(signFormDict, errorList);
Utils.showToast(gameObject, r.errMsg, 1);
}
}
void SetValidate(Dictionary<string,Selectable> dict,JArray errorList)
{
foreach (var error in errorList)
{
var className = dict[error.Value<string>("Field")].GetType().Name;
if (className == "InputField")
{
dict[error.Value<string>("Field")].GetComponent<PFUIInputField>()
.SetValidate(true);
}
else if (className == "Dropdown")
{
dict[error.Value<string>("Field")].GetComponent<PFUIDropdown>()
.SetValidate();
}
//formDict[error.Value<string>("Filed")].error.Value<string>("ErrMsg");
}
}
async void goRegNextWithoutPass()
{
var Email = signForm.email;
@@ -635,7 +722,8 @@ public class LoginController : MonoBehaviour
"");
if (r.result)
{
RefreshWx3(r.data);
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u);
StartScrollPanel(4);
}
else
@@ -643,7 +731,7 @@ public class LoginController : MonoBehaviour
Utils.showToast(gameObject, r.errMsg);
}
}
void RefreshWx3(UserResultModel data)
void RefreshWx3(UserResultModel data)
{
Utils.DisplayImage(StartCoroutine,
wxLogin3.Find("Avatar").GetComponent<RawImage>(),
@@ -653,8 +741,8 @@ public class LoginController : MonoBehaviour
}
async void goRegEnd()
{
if(!await UpdateInfo()) return;
if (pageNums == 5)
if (!await UpdateInfo()) return;
if (pageNums == 5)
{
this.StartScrollPanel(4);
}
@@ -664,7 +752,7 @@ public class LoginController : MonoBehaviour
}
//throw new NotImplementedException();
}
void LoadInfo()
void LoadInfo()
{
var _days = signForm.days.GetComponent<PFUIDropdown>();
var _months = signForm.months.GetComponent<PFUIDropdown>();
@@ -681,13 +769,13 @@ public class LoginController : MonoBehaviour
_months.SelectValue(userResult.Birthday.Value.Month.ToString());
_years.SelectValue(userResult.Birthday.Value.Year.ToString());
}
_genders.SelectIndex(userResult.Sex-1);
_genders.SelectIndex(userResult.Sex - 1);
_countrys.SelectIndex(UIManager.Instance.loginRegOptions.GetCountryIndexByName(userResult.Country));
_units.SelectIndex(userResult.Unit);
_weight.Text = userResult.Weight.ToString();
_height.Text = userResult.Height.ToString();
}
async Task<bool> UpdateInfo()
async Task<bool> UpdateInfo()
{
if (userResult == null) return false;
var _days = signForm.days.GetComponent<PFUIDropdown>();
@@ -698,16 +786,26 @@ public class LoginController : MonoBehaviour
var _units = signForm.units.GetComponent<PFUIDropdown>();
var _weight = signForm.weight.GetComponent<PFUIInputField>();
var _height = signForm.height.GetComponent<PFUIInputField>();
if (signForm.years.value != -1 && signForm.months.value != -1 && signForm.days.value != -1)
if (signForm.years.value != -1 && signForm.months.value != -1 && signForm.days.value != -1)
{
userResult.Birthday = new DateTime(int.Parse(_years.SelectedItem), int.Parse(_months.SelectedItem), int.Parse(_days.SelectedItem));
}
else
{
var errorList = new List<object>();
errorList.Add(new { Field="Years", ErrMsg="" });
errorList.Add(new { Field = "Months", ErrMsg = "" });
errorList.Add(new { Field = "Days", ErrMsg = "" });
SetValidate(signFormDict, JArray.FromObject(errorList));
Utils.showToast(gameObject, "请选择生日");
return false;
}
userResult.Sex = _genders.SelectedIndex + 1;
userResult.Country = UIManager.Instance.loginRegOptions.GetCountryName(_countrys.SelectedIndex);
userResult.Unit = _units.SelectedIndex;
userResult.Weight = int.Parse(_weight.Text);
userResult.Height = int.Parse(_height.Text);
if (string.IsNullOrEmpty(userResult.Nickname))
if (string.IsNullOrEmpty(userResult.Nickname))
{
userResult.Nickname = userResult.Phone;
}
@@ -724,7 +822,7 @@ public class LoginController : MonoBehaviour
this.StartScrollPanel(1);
}
void ReturnQuick()
void ReturnQuick()
{
if (imagexf != null)
{
@@ -734,11 +832,16 @@ public class LoginController : MonoBehaviour
{
imagedf.DOLocalMoveY(-128, 0.3f);
}
if (LoginBg != null)
{
LoginBg.GetComponent<RectTransform>().DOSizeDelta(new Vector2(360, 385), 0.3f);
LoginBg.GetComponent<RectTransform>().DOLocalMoveY(-94, 0.3f);
}
this.StartScrollPanel(0);
}
void goLogin()
public void goLogin(bool noReturn = false)
{
if (imagexf != null)
if (imagexf != null)
{
imagexf.DOLocalMoveY(-669, 0.3f);
}
@@ -746,7 +849,32 @@ public class LoginController : MonoBehaviour
{
imagedf.DOLocalMoveY(-34, 0.3f);
}
if (LoginBg != null)
{
LoginBg.GetComponent<RectTransform>().DOSizeDelta(new Vector2(360, 573), 0.3f);
LoginBg.GetComponent<RectTransform>().DOLocalMoveY(0, 0.3f);
}
//DOTween.To(() => o, x => o = x, t, 0.3f);
this.StartScrollPanel(1);
if (noReturn)
{
loginContainer.Find("returnQuick").GetComponent<Button>().gameObject.SetActive(false);
}
}
/// <summary>
/// 立刻跳到登录页并且返回按钮强行失效
/// </summary>
private void goLoginImmediately()
{
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);
var scrollValue = 1f / (pageNums - 1);
var value = 1 * scrollValue;
scrollPanel.horizontalNormalizedPosition = value;
loginContainer.Find("returnQuick").GetComponent<Button>().gameObject.SetActive(false);
}
void goSign(bool isAccount = true)
{
@@ -818,7 +946,8 @@ public class LoginController : MonoBehaviour
Id = data.Id,
NickName = data.Nickname,
Avatar = data.WxHeadImg,
Cookie = data.cookie
Cookie = data.cookie,
Phone = data.Phone
});
index = userInfos.Count - 1;
}
@@ -829,6 +958,7 @@ public class LoginController : MonoBehaviour
u.NickName = data.Nickname;
u.Avatar = data.WxHeadImg;
u.Cookie = data.cookie;
u.Phone = data.Phone;
//userInfos.Insert(0, new QUserInfo
//{
// Id = data.Id,
@@ -844,27 +974,30 @@ public class LoginController : MonoBehaviour
}
async void Submit()
{
if (loginForm.email == null || loginForm.password == null)
{
Utils.showToast(gameObject, "未绑定", 1);
return;
}
if (string.IsNullOrEmpty(loginForm.email.text) || string.IsNullOrEmpty(loginForm.password.text))
{
Utils.showToast(gameObject, "请输入信息", 1);
return;
}
//if (loginForm.email == null || loginForm.password == null)
//{
// Utils.showToast(gameObject, "未绑定", 1);
// return;
//}
//if (string.IsNullOrEmpty(loginForm.email.text) || string.IsNullOrEmpty(loginForm.password.text))
//{
// Utils.showToast(gameObject, "请输入信息", 1);
// return;
//}
//var res = await Global.userApi.Login(phone.text, pwd.text, "");
//测试用
var res = await ConfigHelper.userApi.Login(loginForm.email.text, loginForm.password.text, "");
var res = await ConfigHelper.userApi.LoginV1(loginForm.email.text, loginForm.password.text, "");
//var res = await NoAuthApi.Login(phone.text, pwd.text);
if (res.result)
{
userResult = res.data;
userResult = JObject.FromObject(res.data).ToObject<UserResultModel>();
goMain(remember.transform.Find("Gou"));
}
else
{
var errorList = JArray.FromObject(res.data);
SetValidate(formDict, errorList);
Utils.showToast(gameObject, res.errMsg);
}
}
@@ -959,6 +1092,7 @@ public class LoginController : MonoBehaviour
private bool startScrollSign = false;
private int scrollSignIndex = 0;
private void StartScrollSign(int index)
{
if (startScrollSign) return;
+23 -3
View File
@@ -1,6 +1,9 @@
using Mapbox.Examples;
using Assets.Scripts;
using Assets.Scripts.Devices.Ant;
using Mapbox.Examples;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
@@ -11,17 +14,23 @@ public class MainController : MonoBehaviour
private void Awake()
{
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
Version.text = "Version:"+App.AppVersion;
Version.text = "V"+App.AppVersion;
AntConnector.Instance();
}
// Start is called before the first frame update
void Start()
async void Start()
{
UIManager.Instance.Root = root;
UIManager.Instance.MainPanel = this.transform.Find("Panel").GetComponent<PFUIPanel>();
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
if (App.CurrentUser == null)
{
await Login();
}
//MainMenu.transform.Find("Home").GetComponent<Button>().onClick.AddListener(() =>
//{
// UIManager.ShowHomePanel();
@@ -52,4 +61,15 @@ public class MainController : MonoBehaviour
{
}
private async Task Login()
{
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
private void OnApplicationQuit()
{
AntConnector.Instance().Dispose();
}
}
+2 -2
View File
@@ -9,14 +9,14 @@ public class ButtonHoverScript : MonoBehaviour, IPointerExitHandler, IPointerEnt
public void OnPointerEnter(PointerEventData eventData)
{
//transform.DOMove
Debug.Log("鼠标悬浮");
//Debug.Log("鼠标悬浮");
//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("鼠标松开");
//Debug.Log("鼠标松开");
transform.DOScale(new Vector3(1f, 1f, 1f), 0.2f);
//gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
}
+11 -2
View File
@@ -58,7 +58,7 @@ namespace Assets.Scripts.UI.Control
}
}
private Outline outline;
void Awake()
{
//this.mSelectedIndex =
@@ -71,9 +71,18 @@ namespace Assets.Scripts.UI.Control
{
mOnValueChange(i);
}
outline.enabled = false;
});
outline = transform.GetComponent<Outline>();
}
public void SetValidate()
{
outline.enabled = true;
}
//public void SetValidate(string s)
//{
// outline.gameObject.SetActive(true);
//}
public void OnSelect(BaseEventData eventData)
{
var image = this.transform.GetComponent<Image>();
+4 -2
View File
@@ -29,7 +29,7 @@ namespace Assets.Scripts.UI.Control
}
}
string placeHolderText;
public void OnSelect(BaseEventData eventData)
{
if (this.gameObject.activeInHierarchy == false)
@@ -49,7 +49,7 @@ namespace Assets.Scripts.UI.Control
Text = "";
}
_text.color = Color.white;
transform.Find("Placeholder").GetComponent<Text>().text = "";
outline.enabled = true;
ColorUtility.TryParseHtmlString("#F93086", out Color color);
@@ -65,6 +65,7 @@ namespace Assets.Scripts.UI.Control
isSelected = false;
this.mInnerInputField.OnDeselect(eventData);
transform.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
//var image = this.transform.GetComponent<Image>();
//var png1 = Resources.Load<Sprite>("Images/ipt-0");
//image.sprite = png1;
@@ -113,6 +114,7 @@ namespace Assets.Scripts.UI.Control
//outline = this.gameObject.AddComponent<Outline>();
outline.enabled = false;
}));
placeHolderText = transform.Find("Placeholder").GetComponent<Text>().text;
}
public void SetValidate(bool value)
+1 -1
View File
@@ -111,7 +111,7 @@ public class Item : PFUIPanel //, IPointerClickHandler
this.Text = model.Name;
this.Distance = model.Distance.ToString("0.0") + "KM";
this.Count = model.TheHeat.ToString();
hot.gameObject.SetActive(model.IsFire);
}
// Start is called before the first frame update
@@ -29,6 +29,8 @@ public class ConnectDeviceModal : PFUIPanel
private VerticalLayoutGroup content;
private PfUIButton connectBtn;
private Dictionary<ushort, DeviceItem> deviceList;
private Text noDevice;
private RectTransform searchIconRect;
protected override void Awake()
{
@@ -42,13 +44,12 @@ public class ConnectDeviceModal : PFUIPanel
var panel = container.Find("Panel");
content = panel.Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
//Material material = null;
//if (material == null)
//{
// material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
//}
//var rect = ((RectTransform)panel.transform).rect;
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 20f, 0));
noDevice = container.Find("NoDevice").GetComponent<Text>();
searchIconRect = container.Find("SearchIcon").GetComponent<RectTransform>();
_x = searchIconRect.localPosition.x;
_y = searchIconRect.localPosition.y;
base.SetRounded(panel.GetComponent<Image>().transform, 20f);
UIManager.AddEvent(closeBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
@@ -88,7 +89,6 @@ public class ConnectDeviceModal : PFUIPanel
protected override void Start()
{
SearchDevice();
}
@@ -101,6 +101,8 @@ public class ConnectDeviceModal : PFUIPanel
SearchDevice();
timer = 1.0f;
}
Move();
}
private void SearchDevice()
@@ -144,32 +146,19 @@ public class ConnectDeviceModal : PFUIPanel
gameObject.transform.SetParent(content.transform);
var deviceItemObj = gameObject.GetComponent<DeviceItem>();
deviceItemObj.DeviceInfo = device;
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
////deviceItemObj.Select();
//if(deviceItemObj.DeviceInfo.Sensor == SensorType)
//{
// deviceItemObj.DeviceInfo.Connect();
//}
deviceItemObj.Set(true);
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.DeviceNumber)
{
item.Value.Set(false);
//if (item.Value.DeviceInfo.Sensor == SensorType)
//{
// item.Value.DeviceInfo.Disconnect();
//}
}
}
//Close();
}));
//UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
//{
// //Debug.Log("de select");
@@ -190,6 +179,7 @@ public class ConnectDeviceModal : PFUIPanel
firstDevice.Set(true);
//connectBtn.text.text = "DISCOUNECT";
noDevice.text = firstDevice.DeviceInfo.Name;
}
}
}
@@ -200,4 +190,29 @@ public class ConnectDeviceModal : PFUIPanel
base.Close();
DestroyImmediate(this.gameObject);
}
float time = 0;
float _x = 0;
float _y = 0;
void Move()
{
var hudu = (2 * Mathf.PI / 360) * 1 * time;
var x = _x + Mathf.Sin(hudu) * 8f;
var y = _y + Mathf.Cos(hudu) * 8f;
var rect = searchIconRect.localPosition;
//rect.x = x;
//rect.y = y;
rect.x = x;
rect.y = y;
searchIconRect.localPosition = rect;
time += 1.8f;
//Debug.Log(x + ", " + y);
//yield return null;
}
}
+95 -74
View File
@@ -10,6 +10,7 @@ using UnityEngine.Events;
using Assets.Scripts.Devices.Ant.Interfaces;
using Assets.Scripts.UI.UIEffect;
using Assets.Scripts;
using DG.Tweening;
public class DeviceView : MonoBehaviour
{
@@ -36,6 +37,7 @@ public class DeviceView : MonoBehaviour
private Text title;
private Text noDevice;
private Text powerValue;
private Text powerUnit;
//private Text cadenceValue;
//private Text speedValue;
//private Text heartRateValue;
@@ -80,9 +82,7 @@ public class DeviceView : MonoBehaviour
gradient.color1 = Utils.HexToColor("353543");
gradient.color2 = Utils.HexToColor("23232D");
}
}
}
var img2 = connectionPanel.GetComponent<Image>();
if(img2 != null)
@@ -98,7 +98,7 @@ public class DeviceView : MonoBehaviour
}
logo = this.transform.Find("Logo").GetComponent<Image>();
InitLogo();
mDisconnectButton = connectionPanel.transform.Find("DisconnectBtn").gameObject;
var powerValueObj = connectionPanel.transform.Find("PowerValue");
@@ -106,21 +106,14 @@ public class DeviceView : MonoBehaviour
{
powerValue = powerValueObj.gameObject.GetComponent<Text>();
}
//var cadenceValueObj = connectionPanel.transform.Find("CadenceValue");
//if (cadenceValueObj != null) {
// cadenceValue = cadenceValueObj.gameObject.GetComponent<Text>();
//}
//var speedValueObj = connectionPanel.transform.Find("SpeedValue");
//if (speedValueObj != null)
//{
// speedValue = speedValueObj.gameObject.GetComponent<Text>();
//}
//var heartRateValueObj = connectionPanel.transform.Find("HeartRateValue");
//if(heartRateValueObj != null)
//{
// heartRateValue = heartRateValueObj.gameObject.GetComponent<Text>();
//}
var powerUnitObj = connectionPanel.transform.Find("PowerUnit");
if(powerUnitObj != null)
{
powerUnit = powerUnitObj.gameObject.GetComponent<Text>();
}
InitLogo();
connectionPanel.SetActive(false);
@@ -159,26 +152,34 @@ public class DeviceView : MonoBehaviour
sprite0 = Resources.Load<Sprite>("Images/Devices/Power_0");
sprite1 = Resources.Load<Sprite>("Images/Devices/Power_1");
sprite3 = Resources.Load<Sprite>("Images/Devices/Power_3");
powerUnit.text = "W";
}
else if (SensorType == SensorType.SpeedCadence)
{
sprite0 = Resources.Load<Sprite>("Images/Devices/Speed_0");
sprite1 = Resources.Load<Sprite>("Images/Devices/Speed_1");
sprite3 = Resources.Load<Sprite>("Images/Devices/Speed_3");
powerUnit.text = "KPH";
}
else if (SensorType == SensorType.Cadence)
{
sprite0 = Resources.Load<Sprite>("Images/Devices/Cadence_0");
sprite1 = Resources.Load<Sprite>("Images/Devices/Cadence_1");
sprite3 = Resources.Load<Sprite>("Images/Devices/Cadence_3");
powerUnit.text = "RPM";
}
else if (SensorType == SensorType.HeartRate)
{
sprite0 = Resources.Load<Sprite>("Images/Devices/Heart Rate_0");
sprite1 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
sprite3 = Resources.Load<Sprite>("Images/Devices/Heart Rate_3");
powerUnit.text = "BPM";
}
else
else if(SensorType == SensorType.Trainer)
{
sprite0 = Resources.Load<Sprite>("Images/Devices/Trainer_0");
sprite1 = Resources.Load<Sprite>("Images/Devices/Trainer_1");
@@ -220,33 +221,8 @@ public class DeviceView : MonoBehaviour
noDevice.text = "NO DEVICE";
searchState.text = "Searching...";
switch (SensorType)
{
case SensorType.None:
break;
case SensorType.Cadence:
title.text = "Cadence Sensor";
break;
case SensorType.HeartRate:
title.text = "Heart Rate Monitor";
break;
case SensorType.Power:
title.text = "Power Meter";
break;
case SensorType.Speed:
break;
case SensorType.SpeedCadence:
title.text = "Speed Meter";
break;
case SensorType.Trainer:
title.text = "Smart Trainer";
break;
case SensorType.VirtualPower:
break;
default:
break;
}
title.text = GetTitle();
var hasDevice = AntConnector.Instance().discoveredDevices.Any(d => d.Sensor == SensorType);
if (hasDevice)
{
@@ -273,45 +249,90 @@ public class DeviceView : MonoBehaviour
else if (connectedDevice.State == DeviceState.Connected)
{
unconnectionPanel.SetActive(false);
connectionPanel.SetActive(true);
if (connectionPanel.activeInHierarchy == false)
{
var connectionCanvasGroup = connectionPanel.GetComponent<CanvasGroup>();
connectionCanvasGroup.alpha = 0;
connectionPanel.SetActive(true);
connectionCanvasGroup.DOFade(1f, .3f);
}
logo.sprite = sprite3;
title.text = connectedDevice.Name;
noDevice.text = connectedDevice.DeviceNumber.ToString();
noDevice.color = Color.white;
switch (SensorType)
if (powerValue != null)
{
case SensorType.None:
break;
case SensorType.Cadence:
//cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
powerValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
break;
case SensorType.HeartRate:
powerValue.text = (connectedDevice as IHeartRateDevice).HeartRate.ToString();
break;
case SensorType.Power:
powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
break;
case SensorType.Speed:
break;
case SensorType.SpeedCadence:
powerValue.text = (connectedDevice as ISpeedDevice).Speed.ToString();
break;
case SensorType.Trainer:
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
break;
case SensorType.VirtualPower:
break;
default:
break;
powerValue.text = GetValue(connectedDevice);
}
}
}
string GetTitle()
{
switch (SensorType)
{
case SensorType.None:
break;
case SensorType.Cadence:
return "Cadence Sensor";
break;
case SensorType.HeartRate:
return "Heart Rate Monitor";
break;
case SensorType.Power:
return "Power Meter";
break;
case SensorType.Speed:
break;
case SensorType.SpeedCadence:
return "Speed Meter";
break;
case SensorType.Trainer:
return "Smart Trainer";
break;
case SensorType.VirtualPower:
break;
default:
break;
}
return "";
}
string GetValue(AbstractAntDevice connectedDevice)
{
switch (SensorType)
{
case SensorType.None:
break;
case SensorType.Cadence:
//cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
return (connectedDevice as ICadenceDevice).Cadence.ToString();
case SensorType.HeartRate:
return (connectedDevice as IHeartRateDevice).HeartRate.ToString();
case SensorType.Power:
return (connectedDevice as IPowerDevice).Power.ToString();
case SensorType.Speed:
break;
case SensorType.SpeedCadence:
return (connectedDevice as ISpeedDevice).Speed.ToString();
case SensorType.Trainer:
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
break;
case SensorType.VirtualPower:
break;
default:
break;
}
return "";
}
AbstractAntDevice GetCurrentDevice()
{
return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
@@ -0,0 +1,121 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.UI.Control;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class FeedbackController : PFUIPanel
{
// Start is called before the first frame update
Transform main,images;
PFUIInputField content;
Dictionary<string, string> paths;
Sprite plus;
void Awake()
{
ApiBase.SetCookie("3B7C1A274805FBB658A16F7B658F7FC3B01599154A952C20011B0F207A9F7B9709CAB23AD8B62FF5F85806DD0AD5059223FD6A582EF79B3F211E64572290202D2821928E824BA6C5313C32C4291763A3797304AE193B272DB9907F7D5AB46D53");
main = transform.Find("Main");
images = main.Find("Images");
paths = new Dictionary<string, string>();
plus = Resources.Load<Sprite>("Images/c-1");
for (int i = 0; i < images.childCount; i++)
{
var img = images.GetChild(i);
int index = i;
UIManager.AddEvent(img.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,
(e)=> AddImage(e,index));
UIManager.AddEvent(img.Find("close").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,
(e) => { DelImage(e, img,index); });
img.Find("close").gameObject.SetActive(false);
img.GetComponent<Image>().sprite = plus;
//if (i > 0) SetImageActive(img, false);
}
UIManager.AddEvent(main.Find("BtnSubmit").gameObject, EventTriggerType.PointerClick, (b) => Submit());
UIManager.AddEvent(main.Find("BtnCancel").gameObject, EventTriggerType.PointerClick, (b) => Close());
UIManager.AddEvent(main.Find("Exit").gameObject, EventTriggerType.PointerClick, (b) => Close());
content = main.Find("Content").Find("input").GetComponent<PFUIInputField>();
content.GetComponent<InputField>().onValueChanged.AddListener((s) =>
{
content.transform.Find("Number").GetComponent<Text>().text = $"<color=#9e9ead>{s.Length}</color>/200";
});
content.transform.Find("Number").GetComponent<Text>().text = $"<color=#9e9ead>0</color>/200";
LoadUserInfo();
}
public override void Show()
{
base.Show();
paths.Clear();
for (int i = 0; i < images.childCount; i++)
{
images.GetChild(i).GetComponent<Image>().sprite = plus;
//if (i > 0) SetImageActive(img, false);
}
content.Text = "";
LoadUserInfo();
}
void SetImageActive(Transform img, bool b)
{
img.GetComponent<Button>().interactable = b;
img.GetComponent<Button>().enabled = b;
img.GetComponent<CanvasGroup>().alpha = Convert.ToInt32(b);
}
void LoadUserInfo()
{
if (App.CurrentUser == null) return;
main.Find("Email").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Phone;
main.Find("ID").Find("Value").Find("Text").GetComponent<Text>().text = App.CurrentUser.Id.ToString();
main.Find("Version").Find("Value").Find("Text").GetComponent<Text>().text = App.AppVersion;
main.Find("Time").Find("Value").Find("Text").GetComponent<Text>().text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
void AddImage(BaseEventData e,int index)
{
var self = ((PointerEventData)e).pointerEnter;
Utils.OpenFile((path) =>
{
self.GetComponent<Image>().sprite = Utils.PngToSprite(path, 110, 110);
self.transform.Find("close").gameObject.SetActive(true);
paths[self.name] = path;
});
}
void DelImage(BaseEventData e,Transform self,int index)
{
self.GetComponent<Image>().sprite = plus;
paths.Remove(self.name);
self.Find("close").gameObject.SetActive(false);
//self.SetSiblingIndex(paths.Count);
//if (paths.Count < 2)
//{
// SetImageActive(images.GetChild(paths.Count+1), false);
//}
//for(int i = index)
//if (index < 2) SetImageActive(images.GetChild(index + 1), false);
//SetImageActive(images.GetChild(index), false);
}
async void Submit()
{
var list = paths.OrderBy(x => x.Key).Select(x => x.Value).ToList();
//var list = images.GetComponents<Transform>().Where(x => x.tag != null && x.tag != "Untagged").Select(x=>x.tag).ToList();
var r = await ConfigHelper.userApi.AddFeedBack(content.Text, list);
if (!r.result)
{
Utils.showToast(gameObject, r.errMsg);
}
else
{
Utils.showToast(gameObject, "已提交");
}
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1206c94b4f7d4f642ad5c7eedf233386
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,6 @@
using System.Collections;
using Assets.Scripts;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
@@ -8,7 +10,7 @@ public class QuickLoginScroll : MonoBehaviour
{
// Start is called before the first frame update
private ScrollRect scroll;
private Transform content;
private Transform content,lightbg;
private float contentSize;
private int count;
[SerializeField] Button L, R;
@@ -16,6 +18,7 @@ public class QuickLoginScroll : MonoBehaviour
{
scroll = gameObject.GetComponent<ScrollRect>();
content = gameObject.transform.Find("Viewport").Find("Content");
lightbg = transform.parent.Find("Light");
//Initial();
if (L != null)
{
@@ -34,6 +37,14 @@ public class QuickLoginScroll : MonoBehaviour
//R.onClick.AddListener(goRight);
}
}
private void doAni()
{
lightbg.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff00");
lightbg.GetComponent<Image>().gameObject.SetActive(false);
//lightbg.GetComponent<Image>().DOFade(0, 0.15f);
}
public void Initial()
{
count = content.childCount;
@@ -55,6 +66,7 @@ public class QuickLoginScroll : MonoBehaviour
void goLeft()
{
if (scroll.horizontalNormalizedPosition <= contentSize) return;
doAni();
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = -1 * contentSize / 30;
@@ -62,6 +74,7 @@ public class QuickLoginScroll : MonoBehaviour
void goRight()
{
if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
doAni();
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = contentSize / 30;
@@ -78,7 +91,10 @@ public class QuickLoginScroll : MonoBehaviour
string c;
if (i == index)
{
lightbg.GetComponent<Image>().gameObject.SetActive(true);
lightbg.GetComponent<Image>().DOFade(1, 0.2f);
content.GetChild(i).GetComponent<QuickLoginUser>().setActive();
//
}
else
{
@@ -98,7 +114,6 @@ public class QuickLoginScroll : MonoBehaviour
start = false;
scroll.horizontalNormalizedPosition = startPosition + totalScrollValue;
//Debug.Log();
SetColor();
totalScrollValue = 0;
}
@@ -40,7 +40,7 @@ public class QuickLoginUser : MonoBehaviour
// Update is called once per frame
void Update()
{
//DOTween.To(()=>)
}
async void goMain()
{
@@ -75,6 +75,7 @@ public class QuickLoginUser : MonoBehaviour
// content.Find("empty1").transform.SetSiblingIndex(0);
// content.Find("empty2").transform.SetSiblingIndex(content.childCount - 1);
//}
UIManager.Instance.userInfoIndex = 0;
content.parent.parent.GetComponent<QuickLoginScroll>().Initial();
DeleteList(index);
}
@@ -84,7 +85,10 @@ public class QuickLoginUser : MonoBehaviour
var userInfos = UIManager.Instance.userInfos;
userInfos.RemoveAt(index);
UIManager.Instance.userInfos = userInfos;
UIManager.Instance.userInfoIndex = 0;
if (userInfos.Count == 0)
{
top.GetComponent<LoginController>().goLogin(true);
}
}
public void setActive()
@@ -93,7 +97,8 @@ public class QuickLoginUser : MonoBehaviour
//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;
transform.Find("NickNameText").GetComponent<Text>().DOFade(1f, 0.3f);
//transform.Find("NickNameText").GetComponent<Text>().enabled = true;
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(true);
}
public void setNoActive()
@@ -102,7 +107,7 @@ public class QuickLoginUser : MonoBehaviour
//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;
transform.Find("NickNameText").GetComponent<Text>().DOFade(0, 0.3f);//.enabled = false;
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(false);
}
}
+4
View File
@@ -44,6 +44,10 @@ public class MainNav : MonoBehaviour
{
UIManager.ShowSettingModal();
});
UIManager.AddEvent(transform.Find("Support").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowFeedBackModal();
});
}
// Start is called before the first frame update
@@ -20,6 +20,14 @@ public class PropNames
}
public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
{
float width;
float height;
void Awake()
{
width = this.GetComponent<RectTransform>().rect.width;
height = this.GetComponent<RectTransform>().rect.height;
}
// Start is called before the first frame update
//[SerializeField] Text text;
//[SerializeField] GameObject panel;
@@ -166,4 +174,69 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
UIManager.ShowAlert(r.errMsg);
}
}
public void Show(Vector3 position, NearRouteModel model)
{
//if(position.y > position.z)
//{
// position.y = position.z;
//}
this.Move(position);
this.gameObject.SetActive(true);
//this.SetModel(model);
Initial(new MapRoute
{
Id = model.Id,
Name = model.Name,
Hard = model.Hard,
CoverImage = model.CoverImage,
Enable3D = model.Enable3D,
TheHeat = model.TheHeat,
TotalClimb = model.TotalClimb,
AverageGrade = model.AverageGrade,
CountryCode = model.CountryCode,
AltitudeGraph = model.AltitudeGraph,
Distance = model.Distance
});
}
public void Move(Vector3 position)
{
this.transform.position = position;
var localPosition = this.transform.localPosition;
Debug.Log(localPosition.y);
//localPosition.y = localPosition.y + (287 * 2);
//localPosition.x = localPosition.x - 280;
localPosition.y = localPosition.y + (width * 2);
localPosition.x = localPosition.x - height;
//if (localPosition.y > 128)
//{
// localPosition.y = 128;
//}
//if (localPosition.x < -465)
//{
// localPosition.x = -465f;
//}
//if (localPosition.x > 1080)
//{
// localPosition.x = 1080;
//}
this.transform.localPosition = localPosition;
this.transform.localScale = new Vector2(2, 2);
Debug.Log($"{ this.transform.localPosition.y }, { this.transform.localPosition.y }");
}
public void Hide()
{
DestroyImmediate(this.gameObject);
}
}
+1 -1
View File
@@ -13,6 +13,6 @@ public class RotateBg : MonoBehaviour
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(0,0,-0.01f*1/3));
transform.Rotate(new Vector3(0,0,-Time.deltaTime * 1/3));
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ using UnityEngine.UI;
public class NewsController : PFUIPanel
{
// Start is called before the first frame update
void Start()
void Awake()
{
content = transform.Find("Main").Find("Inner").Find("Content");
exit = transform.Find("Main").Find("Exit");
@@ -31,14 +31,14 @@ public class BigMapController : PFUIPanel
Sprite end;
private Dictionary<int, LineItem> linesCache = new Dictionary<int, LineItem>();
UnityEngine.Object tipsObject;
private Tips _tips;
private Tips tips
private MapItem _tips;
private MapItem tips
{
get
{
if (_tips == null)
{
_tips = ((GameObject)Instantiate(tipsObject, canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
_tips = ((GameObject)Instantiate(tipsObject, canvas.transform.Find("TipsContainer"))).GetComponent<MapItem>();
}
return _tips;
}
@@ -63,7 +63,7 @@ public class BigMapController : PFUIPanel
mapManager.MaxZoom = 4;
mapManager.OnInitialized += MapManager_OnInitialized;
mapManager.OnUpdated += MapManager_OnUpdated;
//// mapManager.OnTileFinished += MapManager_OnTileFinished;
//mapManager.SetZoom(13);
//mapManager.SetCenterLatitudeLongitude(new Mapbox.Utils.Vector2d(32.051203, 118.771572));
@@ -74,7 +74,7 @@ public class BigMapController : PFUIPanel
canvas.GetComponent<Canvas>().worldCamera = Camera.main;
var goList = canvas.transform.Find("SwitchMode");
SetRounded(goList, 64);
UIManager.AddEvent(goList.gameObject, EventTriggerType.PointerClick, (e) =>
UIManager.AddEvent(goList.Find("GoList").gameObject, EventTriggerType.PointerClick, (e) =>
{
mapManager.Destroy();
UIManager.ShowMapListPanel();
@@ -92,11 +92,13 @@ public class BigMapController : PFUIPanel
var searchBtn = input.Find("Search").gameObject;
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
tipsObject = Resources.Load("UI/Prefab/BigMap/Tips");
tipsObject = Resources.Load("UI/Prefab/MapList/MapItem");
//tips = ((GameObject)Instantiate(tipsObject, canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
//tips.Hide();
BindHeadImage();
}
/// <summary>
/// 绑定头像
@@ -276,7 +278,7 @@ public class BigMapController : PFUIPanel
lineRender.material = new Material(Shader.Find("Sprites/Default"));
line.LineObject = direct;
lineRender.startColor = lineRender.endColor = Utils.HexToColor("F93086");
lineRender.startColor = lineRender.endColor = Color.white; //Utils.HexToColor("F93086");
//设置宽度
lineRender.startWidth = 1.2f;
@@ -307,10 +309,10 @@ public class BigMapController : PFUIPanel
line.Item = iii;
iii.onClick = () =>
{
if(tips != null)
if(_tips != null)
{
tips.Hide();
tips = null;
_tips.Hide();
_tips = null;
}
if (line.Selected)
{
@@ -411,6 +413,21 @@ public class BigMapController : PFUIPanel
{
//Debug.Log(Input.mousePosition.x + "," + Input.mousePosition.y + "," + Input.mousePosition.z);
//timer += Time.deltaTime;
//鼠标点击空白处,清除选择的路线
if (Input.GetMouseButtonDown(0) && EventSystem.current.IsPointerOverGameObject() == false)
{
var line = linesCache.Select(d=>d.Value).FirstOrDefault(l => l.Selected);
if(line != null)
{
line.Selected = false;
if (_tips != null)
{
_tips.Hide();
_tips = null;
}
}
}
}
public override void Show()
@@ -427,7 +444,7 @@ public class BigMapController : PFUIPanel
//base.Close();
DestroyImmediate(this.gameObject);
}
}
class LineItem
{
@@ -454,11 +471,11 @@ public class BigMapController : PFUIPanel
var lineRender = LineObject.GetComponent<LineRenderer>();
if (value)
{
lineRender.startColor = lineRender.endColor = Color.white;
lineRender.startColor = lineRender.endColor = Utils.HexToColor("F93086");
}
else
{
lineRender.startColor = lineRender.endColor = Utils.HexToColor("F93086");
lineRender.startColor = lineRender.endColor = Color.white;
}
}
}
@@ -16,10 +16,41 @@ public class DeviceController : PFUIPanel
private Image antStatus;
private Sprite ant0;
private Sprite ant1;
private Sprite circuloCarga;
private Sprite circuloCompleto;
RectTransform circulo;
private bool _available = false;
private bool Available
{
get
{
return _available;
}
set
{
if (value == _available)
return;
_available = value;
if (_available)
{
antStatus.sprite = ant1;
//circulo.gameObject.SetActive(false);
DOTween.Kill(circulo, false);
circulo.GetComponent<Image>().sprite = circuloCompleto;
}
else
{
antStatus.sprite = ant0;
//circulo.gameObject.SetActive(true);
circulo.GetComponent<Image>().sprite = circuloCarga;
circulo.DOLocalRotate(new Vector3(0, 0, 360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
}
}
}
protected override void Awake()
{
base.Awake();
AntConnector.Instance();
Debug.Log("device awake");
}
@@ -49,9 +80,14 @@ public class DeviceController : PFUIPanel
var bg = this.transform.Find("Status").Find("Bg");
antStatus = bg.Find("Ant+").GetComponent<Image>();
circulo = bg.Find("Image").GetComponent<RectTransform>();
//circulo.DORotate(new Vector3(0, 0, 360), 1.5f, RotateMode.Fast).SetLoops(-1);
circulo.DOLocalRotate(new Vector3(0, 0, 360), 1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1);
ant0 = Resources.Load<Sprite>("Images/ANT+_0");
ant1 = Resources.Load<Sprite>("Images/ANT+_2");
circuloCarga = Resources.Load<Sprite>("Images/icon-circulo-carga");
circuloCompleto = Resources.Load<Sprite>("Images/icon-circulo-completo");
base.SetRounded(bg, 64);
}
@@ -63,27 +99,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)
Available = AntConnector.Instance().IsAvailable;
//if (AntConnector.Instance().IsAvailable)
//{
// if (!devices.ContainsKey(item.DeviceNumber))
// {
// var dev1 = Instantiate(device);
// dev1.transform.SetParent(this.grid.transform);
// var s1 = dev1.GetComponent<Assets.Scripts.UI.Devicea>();
// s1.Device = item;
// devices.Add(item.DeviceNumber, dev1);
// }
// antStatus.sprite = ant1;
//}
//else
//{
// antStatus.sprite = ant0;
//}
timer = 1.0f;
@@ -99,8 +122,8 @@ public class DeviceController : PFUIPanel
cg.DOFade(1f, 0.3f);
}
private void OnApplicationQuit()
protected override void OnDisable()
{
AntConnector.Instance().Dispose();
}
}
@@ -39,6 +39,8 @@ public class EditUserController : PFUIPanel
private Button mBackButton;
private Button mSwitchButton;
PfUIButton mChangeAvatar;
Transform linkContainer;
protected override void Awake()
{
Debug.Log(Utils.GetIP(Utils.ADDRESSFAM.IPv4));
@@ -101,7 +103,7 @@ public class EditUserController : PFUIPanel
}
});
linkContainer = transform.Find("LinkContainer");
mSexDropdown.ClearOptions();
mSexDropdown.AddOptions(new List<string>
@@ -147,7 +149,8 @@ public class EditUserController : PFUIPanel
// new Dropdown.OptionData()
//});
LoadDataSync();
LoadDataSync();
}
async Task Login()
{
@@ -199,6 +202,11 @@ public class EditUserController : PFUIPanel
mName.Text = currentUser.Contact;
mPhone.Text = currentUser.ContactPhone;
mAddr.Text = currentUser.ContactAddress;
//string.IsNullOrEmpty(currentUser.Unionid)
linkContainer.Find("Wx").GetComponent<Image>().sprite =
string.IsNullOrEmpty(currentUser.Unionid)
? Resources.Load<Sprite>("Images/Wechat_person_0")
: Resources.Load<Sprite>("Images/Wechat_person_1");
}
// Start is called before the first frame update
protected override void Start()
@@ -313,6 +321,6 @@ public class EditUserController : PFUIPanel
}
void Cancel(BaseEventData e)
{
UIManager.ShowHomePanel();
UIManager.ShowUserInfoPanel();
}
}
@@ -35,20 +35,8 @@ public class HomeController : PFUIPanel
mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
mainNav.ShowExit();
//var parent = Utils.FindUpParent(gameObject.transform);
//if (parent.Find("ToastContainer") == null)
//{
// var toast = Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
// toast.name = "ToastContainer";
// toast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
// toast.transform.parent = parent;
//}
//if (More != null)
//{
// More.onClick.AddListener(MoreFunc);
//}
BtnRide.onClick.AddListener(GoRide);
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerClick, GoRide);
var avatar = userInfo.Find("Avatar").GetComponent<RawImage>();
var rect = ((RectTransform)avatar.transform).rect;
@@ -58,41 +46,25 @@ public class HomeController : PFUIPanel
{
UIManager.ShowUserInfoPanel();
});
userInfo.Find("BtnMore").GetComponent<PfUIButton>().SetEnabled(false);
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowAlert("test");
UIManager.ShowUserInfoPanel();
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
});
GetSummary();
}
}
private async Task Login()
{
var result = await new UserApi().Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
private void GoRide()
private void GoRide(BaseEventData e)
{
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);
//DOTween.ToAlpha(() => )
//DOTween.ToAlpha(() => )
}
void SetCurrentUser(SummaryResultModel summary)
@@ -101,25 +73,29 @@ public class HomeController : PFUIPanel
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.FTP/ App.CurrentUser.Weight).ToString("0.0") }";
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = summary.Kcal +" KCAL";
userInfo.Find("IDText").GetComponent<Text>().text = "ID:" + App.CurrentUser.Id.ToString("000000");
if (!string.IsNullOrWhiteSpace(App.CurrentUser.Unionid))
{
userInfo.Find("Wx").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/Wechat_person_1");
}
if (App.CurrentUser.Sex == 2)
{
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = double.Parse(summary.Kcal).ToString("0") +" KCAL";
userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = summary.TotalDistance.ToString("0") +" KM";
userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = summary.TotalClimb +" M";
userInfo.Find("IDText").GetComponent<Text>().text = "ID:"+App.CurrentUser.Id.ToString("000000");
//var user = ConfigHelper.CurrentUser;
//Ftp.text = summary.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.WxHeadImg);
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpTime").GetComponent<Text>().text = App.CurrentUser.LastUpdateFtpTime.ToString("yyyy.MM.dd");
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightTime").GetComponent<Text>().text = App.CurrentUser.LastUpdateWeightTime.ToString("yyyy.MM.dd");
}
async void GetSummary()
void GetSummary()
{
if (App.CurrentUser == null)
{
await Login();
}
var res = ConfigHelper.userApi.GetSummary();
if (res.result)
{
@@ -50,7 +50,7 @@ public class MapListController : PFUIPanel
//ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B");
btnMapMode = this.transform.Find("SwitchMode").gameObject;
SetRounded(btnMapMode.transform, 64);
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
UIManager.AddEvent(btnMapMode.transform.Find("GoList").gameObject, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowBigMapPanel();
});
@@ -262,10 +262,10 @@ public class MapListController : PFUIPanel
string sort = "Hot",sortDire = "desc";
//string name = "";
//string name = "";
public void GetList()
async void GetList()
{
if (isEnd) return;
var res = ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
if (res.result)
{
if (res.data.Count == 0 && pageIndex != 0)
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UserInfoController : PFUIPanel
{
@@ -17,7 +18,7 @@ public class UserInfoController : PFUIPanel
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
UIManager.AddEvent(exitBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
UIManager.AddEvent(exitBtn.gameObject, EventTriggerType.PointerClick, (b) =>
{
UIManager.ShowHomePanel();
});
@@ -26,13 +27,13 @@ public class UserInfoController : PFUIPanel
// UIManager.ShowHomePanel();
//});
UIManager.AddEvent(transform.Find("InfoPanel").Find("SwitchAccountButton").gameObject,
UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
EventTriggerType.PointerClick, (b) =>
{
SceneManager.LoadScene("1-Login");
});
infoPanel = transform.Find("InfoPanel").Find("P");
Button editBtn = infoPanel.Find("EditButton").GetComponent<Button>();
UIManager.AddEvent(editBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
UIManager.AddEvent(editBtn.gameObject, EventTriggerType.PointerClick, (b) =>
{
UIManager.ShowEditUserPanel();
});
@@ -64,7 +65,7 @@ public class UserInfoController : PFUIPanel
= UIManager.Instance.loginRegOptions.GetCountryImageByName(user.Country);
infoPanel.Find("Status").Find("Wx").gameObject.SetActive(
!string.IsNullOrEmpty(user.Unionid));
infoPanel.Find("IdText").GetComponent<Text>().text = $"ID:{user.Id}";
infoPanel.Find("IdText").GetComponent<Text>().text = $"ID:{user.Id.ToString("000000")}";
infoPanel.Find("NameText").GetComponent<Text>().text = $"{user.Nickname}";
infoPanel.Find("EmailText").GetComponent<Text>().text = $"{user.Phone}";
@@ -59,6 +59,8 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
{
//btnContinue.gameObject.SetActive(false);
btnContinue.GetComponent<Button>().onClick.AddListener(GoContinue);
btnContinue.GetComponent<Button>().interactable = !(result.Progress == 1.0);
btnContinue.GetComponent<Button>().enabled = !(result.Progress == 1.0);
}
btnReRide = right.Find("BtnReRide");
if (btnReRide)
@@ -112,7 +114,8 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
{
if (f)
{
btnContinue.GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
btnContinue.GetComponent<Image>().color =
routeResult.Progress == 1? Utils.HexToColorHtml("#c8c8c880"): Utils.HexToColorHtml("#F93086");
btnReRide.GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
btnDelete.GetComponent<Image>().color = Utils.HexToColorHtml("#353543");
btnContinue.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
+12
View File
@@ -61,6 +61,14 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("SettingModal", ref this.mSettingContoller);
}
}
private FeedbackController mfeedbackController;
public FeedbackController FeedbackModal
{
get
{
return this.GetPanelInstance("FeedbackModal", ref this.mfeedbackController);
}
}
private NewsController mNewsContoller;
public NewsController NewsModal
{
@@ -322,6 +330,10 @@ public class UIManager : MonoBehaviour
{
UIManager.Show(UIManager.Instance.NewsModal, null, true);
}
public static void ShowFeedBackModal()
{
UIManager.Show(UIManager.Instance.FeedbackModal, null, true);
}
public static void ShowEditUserPanel()
{
UIManager.Show(UIManager.Instance.EditUserPanel, UIManager.Instance.MainPanel);
+49
View File
@@ -4,9 +4,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
@@ -169,5 +171,52 @@ namespace Assets.Scripts
return str;
}
/*文件转精灵*/
public static Sprite PngToSprite(string fullPath, int x, int y)
{
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) //自动双清
{
fs.Seek(0, SeekOrigin.Begin); //设定当前流的位置
byte[] bytes = new byte[fs.Length]; //创建文件长度缓冲区
fs.Read(bytes, 0, (int)fs.Length); //读取文件
Texture2D texture = new Texture2D(x, y); //创建Texture
texture.LoadImage(bytes);
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one / 2);
}
}
/*文件转精灵*/
/*打开文件*/
public delegate void OpenFileCallBack(string path);
public static void OpenFile(OpenFileCallBack callBack,string filter = null)
{
OpenFileName ofn = new OpenFileName();
ofn.structSize = Marshal.SizeOf(ofn);
ofn.filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)\0*.jpg;*.png;*.jpeg;*.bmp\0";
if (filter != null) ofn.filter = filter;
ofn.file = new string(new char[256]);
ofn.maxFile = ofn.file.Length;
ofn.fileTitle = new string(new char[64]);
ofn.maxFileTitle = ofn.fileTitle.Length;
ofn.initialDir = UnityEngine.Application.dataPath;//默认路径
ofn.title = "Open Project";
ofn.defExt = "JPG";//显示文件的类型
//注意 一下项目不一定要全选 但是0x00000008项不要缺少
ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
if (Win32.GetOpenFileName(ofn))
{
callBack(ofn.file);
}
}
/*打开文件*/
}
}