41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
public class BuyProduct23 : MonoBehaviour
|
|
{
|
|
public async Task<BuyProductResponse> BuyProduct(int productId, int userId, string receiveName, string receivePhone, string area, string address)
|
|
{
|
|
// 准备请求的头部信息,包含授权令牌
|
|
Dictionary<string, string> head23 = new Dictionary<string, string>
|
|
{
|
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|
};
|
|
|
|
// 请求体
|
|
BuyProductBody BuyProductBody = new BuyProductBody
|
|
{
|
|
productId = productId,
|
|
userId = userId,
|
|
receiveName = receiveName,
|
|
receivePhone = receivePhone,
|
|
area = area,
|
|
address = address
|
|
};
|
|
|
|
Debug.Log("====入参====" + JsonConvert.SerializeObject(BuyProductBody));
|
|
// 异步发送请求
|
|
string response23 = await web.SendRequest(web.URL + "/snail/product/buy", "POST", JsonConvert.SerializeObject(BuyProductBody), head23);
|
|
|
|
// 调试输出接收到的响应
|
|
Debug.Log("2.3购买商品:=============== " + response23);
|
|
|
|
// 解析响应的 JSON 数据
|
|
BuyProductResponse buyProductResponse = JsonConvert.DeserializeObject<BuyProductResponse>(response23);
|
|
return buyProductResponse;
|
|
}
|
|
}
|