_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/LqUiScripts/EditPanel.cs
2024-12-10 12:16:31 +08:00

81 lines
2.4 KiB
C#

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class EditPanel : Base
{
public UserInfomation14 userInfomation14;
public InputField UserInputField;
public Text username;
public PerSonalCenterPanel perSonalCenterPanel;
// Start is called before the first frame update
async void Start()
{
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步查询玩家信息
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4查询玩家信息" + response14);
userInfomation14 = JsonConvert.DeserializeObject<UserInfomation14>(response14);
username.text = "" + userInfomation14.data.nickName;
}
// Update is called once per frame
void Update()
{
}
public async void SetEditPanel()
{
Dictionary<string, string> head13 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
ChangeDetailbody body= new ChangeDetailbody();
body.nickName = UserInputField.text;
Debug.Log(UserInputField.text);
body.birthday = userInfomation14.data.birthday;
body.gender= userInfomation14.data.gender;
body.headImg = userInfomation14.data.headImg;
Debug.Log("入参"+ JsonUtility.ToJson(body));
string loginResponse = await web.SendRequest(web.URL + "/snail/user/update", "POST", JsonUtility.ToJson(body), head13);
ChangeReturn response = JsonUtility.FromJson<ChangeReturn>(loginResponse);
if (response.code==200)
{
Debug.Log("1.3完善用户信息"+ loginResponse);
perSonalCenterPanel.GetPlayerInfo();
Global.global.scene_Main_Jiekou.getPlayerInfo();
}
else
{
addEventPopUp(response.message);
}
Debug.Log(response);
transform.gameObject.SetActive(false);
}
}
public class ChangeDetailbody//登录和注册用
{
public string nickName = "";
public string headImg = "";
public int gender = 0;
public string birthday = "";
}
public class ChangeReturn
{
public int code;
public string message;
public bool data;
}