using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Networking; /// /// 学生提问 /// public class RepairSenderManager : SingletonMono { private string url = "http://172.16.1.254:13030/Handler/Repair.ashx?action=add"; // 点击提交按钮调用 public void OnClickSend(TMP_InputField inputContent) { string content = inputContent.text; if (string.IsNullOrEmpty(content)) { Debug.Log("请输入内容!"); return; } StartCoroutine(SendRepair("学生咨询", content)); // 标题固定 } IEnumerator SendRepair(string title, string content) { WWWForm form = new WWWForm(); form.AddField("action", "add"); form.AddField("RepairName", title); form.AddField("RepairContent", content); form.AddField("user_id", LoginManager.Instance.loginRespons.data.user_id); UnityWebRequest request = UnityWebRequest.Post(url, form); // 发送请求 yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.Success) { Debug.Log("发送成功!后端返回:" + request.downloadHandler.text); } else { Debug.LogError("发送失败:" + request.error); } } }