浏览器嵌入,国旗文件
This commit is contained in:
1 parent
e7a3214cb5
commit
07feba912c
552 files changed
+39279
-8128
No files matched your search
@@ -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,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
/// 已连接到Strava
|
||||
/// </summary>
|
||||
public bool ConnectedToStrava { 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;
|
||||
@@ -67,7 +68,7 @@ namespace Assets.Scripts.Apis
|
||||
//todo: check local database, insert new user
|
||||
|
||||
//PubCommData.CurrentUser = user;
|
||||
|
||||
user.cookie = cookies[0].Value;
|
||||
return new JsonResult<UserResultModel>() { result = true, data = user };
|
||||
}
|
||||
else
|
||||
@@ -93,5 +94,48 @@ 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user