69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using UnityEngine;
|
||
using WXGame.Network;
|
||
using Cysharp.Threading.Tasks;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using MotionFramework;
|
||
|
||
namespace DefaultNamespace
|
||
{
|
||
/// <summary>
|
||
/// 用户数据网络管理类
|
||
/// </summary>
|
||
public class UserDataNetworkManager:ModuleSingleton<UserDataNetworkManager>, IModule
|
||
{
|
||
/// <summary>
|
||
/// 获取我的好友(异步方式)
|
||
/// </summary>
|
||
/// <returns>UniTask<FriendResponse></returns>
|
||
public async UniTask<FriendResponse> GetMyFriend()
|
||
{
|
||
Debug.Log("开始异步获取好友列表...");
|
||
|
||
try
|
||
{
|
||
// 构建POST请求参数(urlencoded格式)
|
||
string postData = $"page={1}";
|
||
|
||
Debug.Log(postData);
|
||
|
||
// 使用异步方式发送POST请求
|
||
var result = await WebRequestManager.Instance.PostRequestAsync(
|
||
url: Apis.GetMyFriend(),
|
||
signParams: new Dictionary<string, string>()
|
||
{
|
||
{ "page", "1" },
|
||
}
|
||
);
|
||
|
||
Debug.Log($"好友列表请求成功!状态码: {result.ResponseCode}");
|
||
Debug.Log($"响应内容: {result.ResponseText}");
|
||
|
||
FriendResponse friendResponse = JsonUtility.FromJson<FriendResponse>(result.ResponseText);
|
||
return friendResponse;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Debug.LogError($"获取好友列表失败: {ex.Message}");
|
||
throw;
|
||
}
|
||
}
|
||
|
||
public void OnCreate(object createParam)
|
||
{
|
||
}
|
||
|
||
public void OnUpdate()
|
||
{
|
||
}
|
||
|
||
public void OnDestroy()
|
||
{
|
||
}
|
||
|
||
public void OnGUI()
|
||
{
|
||
}
|
||
}
|
||
|
||
} |