_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/LqUiScripts/EditPanel.cs

81 lines
2.4 KiB
C#
Raw Normal View History

2024-12-10 12:01:29 +08:00
using Newtonsoft.Json;
2024-11-25 22:18:57 +08:00
using System.Collections;
using System.Collections.Generic;
2024-12-10 12:01:29 +08:00
using TMPro;
2024-11-25 22:18:57 +08:00
using UnityEngine;
2024-12-10 12:01:29 +08:00
using UnityEngine.SceneManagement;
2024-11-25 22:18:57 +08:00
using UnityEngine.UI;
2024-12-10 12:01:29 +08:00
public class EditPanel : Base
2024-11-25 22:18:57 +08:00
{
2024-12-10 12:01:29 +08:00
public UserInfomation14 userInfomation14;
public InputField UserInputField;
public Text username;
public PerSonalCenterPanel perSonalCenterPanel;
2024-11-25 22:18:57 +08:00
// Start is called before the first frame update
2024-12-10 12:01:29 +08:00
async void Start()
2024-11-25 22:18:57 +08:00
{
2024-12-10 12:01:29 +08:00
Dictionary<string, string> head14 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// <20><EFBFBD><ECB2BD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
Debug.Log("1.4<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ" + response14);
userInfomation14 = JsonConvert.DeserializeObject<UserInfomation14>(response14);
username.text = "" + userInfomation14.data.nickName;
2024-11-25 22:18:57 +08:00
}
// Update is called once per frame
void Update()
{
}
2024-12-10 12:01:29 +08:00
public async void SetEditPanel()
2024-11-25 22:18:57 +08:00
{
2024-12-10 12:01:29 +08:00
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("<22><><EFBFBD><EFBFBD>"+ 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<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>Ϣ"+ loginResponse);
perSonalCenterPanel.GetPlayerInfo();
2024-12-10 12:16:31 +08:00
Global.global.scene_Main_Jiekou.getPlayerInfo();
2024-12-10 12:01:29 +08:00
}
else
{
addEventPopUp(response.message);
}
Debug.Log(response);
2024-11-25 22:18:57 +08:00
transform.gameObject.SetActive(false);
}
}
2024-12-10 12:01:29 +08:00
public class ChangeDetailbody//<2F><>¼<EFBFBD><C2BC>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
{
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;
}