_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Login/WebConnact.cs

194 lines
6.0 KiB
C#
Raw Normal View History

2024-11-11 19:48:32 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
using UnityEngine;
using UnityEngine.Networking;
using System.Threading.Tasks;
public class WebConnact : MonoBehaviour
{
void Start()
{
//<2F><><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD>¼ע<C2BC><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼<EFBFBD>󷵻ص<F3B7B5BB>token
//<2F><><EFBFBD>˵<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ڴ˷<DAB4><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1>
//<2F><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ص<EFBFBD><D8B5>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>token<65><6E><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LoginAndGetToken.OnTokenReceived += HandleTokenReceived;
//Loding();
}
void HandleTokenReceived(string token)
{
// ʹ<><CAB9> token
//string loginToken=token;
Debug.Log("HandleTokenReceived:"+token);
Loding(token);
}
public async void Loding(string token)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ֵ
string Authorization = token;
Debug.Log("Loding(Authorization)"+Authorization);
//loginbody body = new loginbody();
//body.userName = "15151658596";// + 15151658596;
//body.password = "123456";// + 123456;
//body.verifyCode = 111111;
//string regisestrespose = await web.SendRequest("http://121.40.42.41:8080/snail/user/register", "POST", JsonUtility.ToJson(body));
//Debug.Log(regisestrespose);
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><>ͨ<EFBFBD><CDA8>
//loginbody body = new loginbody();
//body.userName = "15151658596";// + 15151658596;
//body.password = "123456";// + 123456;
//body.verifyCode = 111111;
//string loginResponse = await web.SendRequest("http://121.40.42.41:8080/snail/user/login", "POST", JsonUtility.ToJson(body));
//Debug.Log(loginResponse);
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>//<2F><>ͨ<EFBFBD><CDA8>
//1.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϣ
// User_InformationHead user = new User_InformationHead();
// Dictionary<string, string> head13 = new Dictionary<string, string>
//{
// { "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
// };
// user.nickName = "wulongxiao";
// user.headImg = "https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png";
// user.gender = "<22><>";
// user.birthday = "20010506";
// string UserNewInfoBody = "{\"nickName\":\"wulongxiao\",\"headImg\":\"https://fantasymonster-app.oss-cn-hangzhou.aliyuncs.com/upload/imgs/127e4e42d7c0405aab53359c1b278a9c.png\",\"gender\":\"<22><>\",\"birthday\":\"20010506\"}";
// string response13 = await web.SendRequest("http://121.40.42.41:8080/snail/user/update", "POST", UserNewInfoBody, head13);
// Debug.Log(response13);
//Mall_List mall_virtual = new Mall_List();
//mall_virtual.productType = 0;
//mall_virtual.pageNo = 1;
//mall_virtual.pageSize = 20;
//string mall_virtualponse = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mall_virtual));
//Debug.Log(mall_virtualponse);
//Mall_List mall = new Mall_List();
//mall.productType = 1;
////mall.pageNo = 1;
////mall.pageSize = 20;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ʡ<EFBFBD>Բ<EFBFBD>д<EFBFBD><D0B4>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>1<EFBFBD><31>20
//string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/page", "POST", JsonUtility.ToJson(mall));
//Debug.Log(response);
//Product_Details product = new Product_Details();
//product.productId = 1;
//string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/info", "POST", JsonUtility.ToJson(product));
//Debug.Log(response);
// Mall_buy mall_Buy = new Mall_buy();
//string Authorization = "7083e9cb0de74c9dbb3c02f37ec339b8";
// mall_Buy.userId = 106;
// mall_Buy.productId = 1;
// string response = await web.SendRequest("http://121.40.42.41:8080/snail/product/buy", "POST", JsonUtility.ToJson(mall_Buy),Authorization);
// Debug.Log(response);
//Query_Announcement query_Announcement = new Query_Announcement();
//query_Announcement.userId = 106;
//query_Announcement.pageNo = 1;
//query_Announcement.pageSize = 20;
//string response = await web.SendRequest("http://121.40.42.41:8080/snail/notice/page", "POST", JsonUtility.ToJson(query_Announcement));
//Debug.Log(response);
//string response = await web.SendRequest($"http://121.40.42.41:8080/snail/notice/info?noticeId=${<7B><><EFBFBD><EFBFBD>id}", "Get");
//Debug.Log(response);
//5.1<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ
// Dictionary<string, string> head51 = new Dictionary<string, string>
//{
// { "Authorization", Authorization }, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͷ
// };
// //head.Add("Authorization", token);
// string response51 = await web.SendRequest("http://121.40.42.41:8080/snail/gameEscape/queryLatest", "POST", "{}", head51);
// Debug.Log(response51);//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
//<2F><>ͨ<EFBFBD><CDA8>
//===========================================getToken================================================================================
}
void OnDestroy()
{
LoginAndGetToken.OnTokenReceived -= HandleTokenReceived;
}
// Update is called once per frame
void Update()
{
}
}
[Serializable]
public class Search_room//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
{
public int userId;
}
//[Serializable]
//public class loginbody//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//{
// public string userName;
// public string password;
// public int verifyCode;
//}
[System.Serializable]
public class User_InformationHead //<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
{
public string nickName;
public string headImg;
public string gender;
public string birthday;
}
[Serializable]
public class Query_Announcement //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
{
public int userId;
public int pageNo;
public int pageSize;
}
[Serializable]
public class Mall_List //<2F><>ȡ<EFBFBD>̳<EFBFBD><CCB3>б<EFBFBD>
{
public int productType;
public int pageNo;
public int pageSize;
}
[Serializable]
public class Product_Details//<2F><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public int productId;
}
[Serializable]
public class Mall_buy
{ public int productId;
public int userId;
}