Cute_demon_attacks/meng_yao/Assets/script/serveTestScript/test1.cs
2024-12-27 18:14:54 +08:00

326 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SocialPlatforms;
public class test1 : MonoBehaviour
{
public string token;
checkAccount checkAccount = new checkAccount();
// Start is called before the first frame update
async void Start()
{
//Register();
//Login();
//Debug.Log(MyGlobal.global.loginResponse.Data.access_token+"====================");
}
// 创建请求头,使用最新的 token
public Dictionary<string, string> CreateHeadersTologin()
{
return new Dictionary<string, string>
{
//{ "Authorization","Bearer "+MyGlobal.global.loginResponse.Data.access_token },
{ "client-info", "{\"platform\":\"ios\",\"phone_product\":\"apple\",\"phone_model\":\"iPhone_8\",\"system_version\":\"12.0\",\"screen_size\":\"750*1334\",\"device_no\":\"e3e277810fff9d955ebdd7037eff51a8\",\"version\":\"1.0.0\"}" }
};
}
public Dictionary<string, string> CreateHeaders()
{
if (string.IsNullOrEmpty(MyGlobal.global.loginResponse.Data.access_token))
{
Debug.LogWarning("尝试创建请求头时token 未设置。");
return new Dictionary<string, string>();
}
return new Dictionary<string, string>
{
{ "Authorization","Bearer "+MyGlobal.global.loginResponse.Data.access_token },
{ "client-info", "{\"platform\":\"ios\",\"phone_product\":\"apple\",\"phone_model\":\"iPhone_8\",\"system_version\":\"12.0\",\"screen_size\":\"750*1334\",\"device_no\":\"e3e277810fff9d955ebdd7037eff51a8\",\"version\":\"1.0.0\"}" }
};
}
// Update is called once per frame
void Update()
{
}
// =======登录=========================================================================================================================
//public async void Login()
//{
// loginBody body = new loginBody();
// body.client_id = "app";
// body.username = "13502712157";
// body.password = "9527123";
// body.type = "code";
// //Debug.Log(JsonConvert.SerializeObject(body) + "入参=========");
// string response = await myWeb.SendRequest(myWeb.URL + "/api/oauth/login", "POST", JsonConvert.SerializeObject(body), CreateHeadersTologin());
// Debug.Log("登录" + response);
// loginResponse apifox = JsonConvert.DeserializeObject<loginResponse>(response);
// Debug.Log(MyGlobal.global.loginResponse.Data);
// MyGlobal.global.loginResponse.Data.access_token = apifox.Data.access_token;
// Debug.Log(MyGlobal.global.loginResponse.Data.access_token);
// //checkAccount.CheckAccount();
//}
//===============注册=======================================================================================================================
//public async void Register()
//{
// register body = new register();
// body.account = "18821995938";
// body.password = "A123456";
// body.invite_code = "";
// body.code = "9527123";
// Debug.Log(JsonConvert.SerializeObject(body) + "入参=========");
// //Debug.Log(JsonConvert.SerializeObject(CreateHeaders()) + "==========头=========");
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/register", "POST", JsonConvert.SerializeObject(body), CreateHeadersTologin());
// Debug.Log("注册"+response);
// RegisterResponse register = JsonConvert.DeserializeObject<RegisterResponse>(response);
// Debug.Log("=====zhuce======"+register.data.token.expires_in);
//}
//============退出登录============================================================================================
//public async void Logout()
//{
// string response = await myWeb.SendRequest(myWeb.URL + "/api/oauth/logout", "POST", "{}", CreateHeaders());
// Debug.Log("退出登录"+response);
//}
//==================发送验证码================================================================================
//public async Task<bool> SendCode()
//{
// SendCodeBody body = new SendCodeBody();
// body.account = "13502712157";
// body.scene = 0;
// //Debug.Log(JsonConvert.SerializeObject(body) + "入参=========");
// //Debug.Log(JsonConvert.SerializeObject(CreateHeaders()) + "==========头=========");
// string response = await myWeb.SendRequest(myWeb.URL + "/api/captcha/send_code", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
// Debug.Log("发送验证码"+response);
// SendCodeResponse sendCode = JsonConvert.DeserializeObject<SendCodeResponse>(response);
// myResponse CheckCodeResponse = JsonConvert.DeserializeObject<myResponse>(response);
// bool isSucceed;
// if (CheckCodeResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// return isSucceed;
//}
//=====================验证码校验===========================================================================
//public async Task<bool> CheckCode()
//{
// CheckCodeBody body = new CheckCodeBody();
// body.account = "13502712157";
// body.scene = 0;
// body.code = "9527123";
// //Debug.Log(JsonConvert.SerializeObject(body) + "入参=========");
// //Debug.Log(JsonConvert.SerializeObject(CreateHeaders()) + "==========头=========");
// string response = await myWeb.SendRequest(myWeb.URL + "/api/captcha/verify", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
// Debug.Log("验证码校验"+response);
// SendCodeResponse sendCodeResponse = JsonConvert.DeserializeObject<SendCodeResponse>(response);
// bool isSucceed;
// if (sendCodeResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// return isSucceed;
//}
//==================用户详情====================================================================================
//public async Task<PlayerIndfo> PalyerInfo()
//{
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/detail", "GET", "{}", CreateHeaders());
// Debug.Log("用户详情" + response);
// PlayerIndfo playerIndfo = JsonConvert.DeserializeObject<PlayerIndfo>(response);
// Debug.Log("======"+playerIndfo.Data.account);
// return playerIndfo;
//}
//==================账号校检【注册前检查】=====================================================================
//public async Task<bool> CheckAccount()
//{
// PlayerIndfo playerIndfo =await PalyerInfo();//这里重新定义一个playerinfo变量重新获取一次PlayerInfo
// CheckAccountBody body = new CheckAccountBody();
// Debug.Log(playerIndfo.Data.account);
// body.account = playerIndfo.Data.account;
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/check_account", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
// Debug.Log("账号校验" + response);
// myResponse CheckAccountResponse = JsonConvert.DeserializeObject<myResponse>(response);
// bool isSucceed;
// if (CheckAccountResponse.code == 200) { isSucceed = true; }else{ isSucceed = false; }
// return isSucceed;
//}
//======================转增密码设置====================================================================
//public async Task<bool> ModifyTradePassword(string newPassword,string code)
//{
// ModifyTradePasswordBody body = new ModifyTradePasswordBody();
// body.code = code;
// body.password = newPassword;
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/modify_trade_password", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
// Debug.Log("转增密码设置" + response);
// myResponse ModifyTradePasswordResponse = JsonConvert.DeserializeObject<myResponse>(response);
// bool isSucceed;
// if (ModifyTradePasswordResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// return isSucceed;
//}
//=========用户信息更新=============================================================================
//public async Task<bool> UpdatePlayerInfo(string field, string value)//呢称需要包含中文可以跟字母组合,但必须大于两个//只能更新名字头像
//{
// string body = $"{{\"{field}\":\"{value}\"}}";
// Debug.Log("====="+body);
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/update_info", "POST", body, CreateHeaders());
// Debug.Log("用户信息更新" + response);
// //myResponse ModifyTradePasswordResponse = JsonConvert.DeserializeObject<myResponse>(response);
// bool isSucceed=true;
// //if (ModifyTradePasswordResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// return isSucceed;
//}
//===========实名认证==============================================================================================
//public async Task<bool> RealNameAuthentication(string name, string identity_card_no)//呢称需要包含中文可以跟字母组合,但必须大于两个//只能更新名字头像
//{
// RealNameBody body = new RealNameBody();
// body.name = name;
// body.identity_card_no = identity_card_no;
// Debug.Log("=====" + body);
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/certify/commit", "POST", JsonConvert.SerializeObject(body), CreateHeaders());
// Debug.Log("实名认证" + response);
// myResponse RealNameResponse = JsonConvert.DeserializeObject<myResponse>(response);
// bool isSucceed = true;
// if (RealNameResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// return isSucceed;
//}
//===================团队信息========================================================================================
//public async Task<TeamInfo> TeamInfo()
//{
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/team_data", "GET", "{}", CreateHeaders());
// Debug.Log("团队信息" + response);
// TeamInfo teamInfo = JsonConvert.DeserializeObject<TeamInfo>(response);
// Debug.Log(teamInfo.data);
// return teamInfo;
//}
//public async Task<TeamInfoResponse> TeamInfo()
//{
// string response = await myWeb.SendRequest(myWeb.URL + "/api/user/team_data", "GET", "{}", CreateHeaders());
// Debug.Log("团队信息" + response);
// TeamInfoResponse teamInfo = JsonConvert.DeserializeObject<TeamInfoResponse>(response);
// Debug.Log(teamInfo.Data.Info.Nickname);
// return teamInfo;
//}
}
//====================
//public class loginBody//登录请求体
//{
// public string client_id;
// public string username;
// public string password;
// public string type;
//}
//public class register//注册请求体
//{
// public string account;
// public string password;
// public string invite_code;
// public string code;
//}
//============================================
//public class SendCodeBody
//{
// public string account;
// public int scene;
//}
//public class SendCodeResponse:myResponse
//{
// public string data;
//}
//============================================
//public class CheckCodeBody
//{
// public string account;
// public int scene;
// public string code;
//}
//=======用户详情返回值===================
//public class PlayerIndfo:myResponse
//{
// public PlayerInfoData Data;
//}
//public class PlayerInfoData
//{
// public string uid;
// public string account;
// public string nickname;
// public string avatar_url;
// public string invite_code;
// public int trade_password_status;
// public int certify_status;
// public string certify_name;
// public string identity_card_no;
// public string location;
// public int location_status;
// public long gem;
// public long gold;
// public long forge;
// public long water;
// public int level;
// public string level_name;
// public string level_icon;
//}
//============账号校验=======================================================
//public class CheckAccountBody
//{
// public string account;
//}
//============转增密码设置===============================================
//public class ModifyTradePasswordBody
//{
// public string password;
// public string code;
//}
//================实名认证=============================================
//public class RealNameBody
//{
// public string name;
// public string identity_card_no;
//}
//=========团队信息====================================================
//public class TeamInfoResponse
//{
// public TeamInfoData Data { get; set; }
//}
//public class TeamInfoData
//{
// public TeamInfoInfo Info { get; set; }
// public List<TeamInfoItem> Items { get; set; }
//}
//public class TeamInfoInfo
//{
// public string Uid { get; set; }
// public string Account { get; set; }
// public string Nickname { get; set; }
// public string AvatarUrl { get; set; }
// public string InviteCode { get; set; }
// public int CertifyStatus { get; set; }
// public string CreateTime { get; set; }
// public string LastLoginTime { get; set; }
// public int TeamCount { get; set; }
// public int DirectlyCount { get; set; }
// public double KpiGold { get; set; }
// public double TeamKpiGold { get; set; }
// public double TeamMinKpiGold { get; set; }
// public int Level { get; set; }
// public string LevelName { get; set; }
// public string LevelIcon { get; set; }
//}
//public class TeamInfoItem
//{
// public string Title { get; set; }
// public string Desc { get; set; }
// public double NowVal { get; set; }
// public double ReqVal { get; set; }
// public double Percentage { get; set; }
// public int Style { get; set; }
//}