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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user