87 lines
2.1 KiB
C#
87 lines
2.1 KiB
C#
using Assets.MyGame.Scripts.Net.API;
|
||||
|
|
using Assets.MyGame.Scripts.Net.APIRequest.Objs;
|
|||
|
|
using Assets.MyGame.Scripts.Net.APIRequest.Params;
|
|||
|
|
using System;
|
|||
|
|
using System.Security.Cryptography;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Assets.MyGame.Scripts.Net
|
|||
|
|
{
|
|||
|
|
public static partial class APIRequestList
|
|||
|
|
{
|
|||
|
|
static void lizi()
|
|||
|
|
{
|
|||
|
|
APIRequestList.Login(
|
|||
|
|
new LoginParam { mobile = "13800138000", code = "1234" },
|
|||
|
|
res =>
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
APIRequestList.Register(
|
|||
|
|
new RegisterObj { mobile = "13800138000", code = "1234", password = "abc123" },
|
|||
|
|
res =>
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
APIRequestList.LoginWx(
|
|||
|
|
new LoginWxParam
|
|||
|
|
{
|
|||
|
|
openId = "wx_openid_123456"
|
|||
|
|
},
|
|||
|
|
res =>
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#region Login
|
|||
|
|
/// <summary>
|
|||
|
|
/// 微信用户登录(GET)
|
|||
|
|
/// Swagger Summary: 微信用户登陆
|
|||
|
|
/// 参数:
|
|||
|
|
/// openId: 微信 openId
|
|||
|
|
/// 返回:
|
|||
|
|
/// UserToken(包含 token、用户信息等)
|
|||
|
|
/// </summary>
|
|||
|
|
public static void LoginWx(LoginWxParam req, Action<UserToken> callback)
|
|||
|
|
{
|
|||
|
|
APIManager.Response<UserToken>(APIType.Login_LoginWx, req, obj =>
|
|||
|
|
{
|
|||
|
|
GameManager.Instance.user = obj;
|
|||
|
|
callback?.Invoke(obj);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 登录(GET)
|
|||
|
|
/// </summary>
|
|||
|
|
public static void Login(LoginParam req, Action<UserToken> callback)
|
|||
|
|
{
|
|||
|
|
APIManager.Response<UserToken>(APIType.Login_Login, req, obj =>
|
|||
|
|
{
|
|||
|
|
GameManager.Instance.user=obj;
|
|||
|
|
callback?.Invoke(obj);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 注册(POST)
|
|||
|
|
/// </summary>
|
|||
|
|
public static void Register(RegisterObj req, Action<UserToken> callback)
|
|||
|
|
{
|
|||
|
|
APIManager.Response<UserToken>(APIType.Login_Register, req, obj =>
|
|||
|
|
{
|
|||
|
|
callback?.Invoke(obj);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|