123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- using UnityEngine.UI;
- public class KangFuOne : MonoBehaviour
- {
- public Toggle tg;
- public List<Toggle> dd =new List<Toggle>();
- public static string choosename;
- public void gotoSet()
- {
- for (int i = 0; i < WindowManager.Instance.KangFuDaList.Count; i++)
- {
- WindowManager.Instance.KangFuDaList[i].SetActive(false);
- }
- WindowManager.Instance.KangFuDaList[2].SetActive(true);
- }
- public void gotoinfo()
- {
- for (int j = 0; j < dd.Count;j++)
- {
- if(dd[j].isOn)
- {
- choosename = dd[j].GetComponentInChildren<Text>().text;
- for (int i = 0; i < WindowManager.Instance.KangFuDaList.Count; i++)
- {
- WindowManager.Instance.KangFuDaList[i].SetActive(false);
- }
- WindowManager.Instance.KangFuDaList[1].SetActive(true);
- return;
- }
- }
- }
- public void back()
- {
- WindowManager.Instance.back();
- }
- private void Start()
- {
- }
- public Text debugtxt;
- private void OnEnable()
- {
- for (int i = 0; i < dd.Count; i++)
- {
- Destroy(dd[i].gameObject);
- }
- dd.Clear();
- StartCoroutine(SendHttp("cmcc-endustry/v1/report/dairyCattle/userList",(string str)=> {
- debugtxt.text += "\n"+str;
- JsonData data = JsonMapper.ToObject(str);
- for (int i = 0; i < data["data"]["list"].Count; i++)
- {
- Toggle dddata = GameObject.Instantiate(tg,tg.transform.parent);
- dddata.gameObject.SetActive(true);
- dddata.GetComponentInChildren<Text>().text = data["data"]["list"][i].ToString();
- dd.Add(dddata);
- }
- // choosename = data["data"]["list"][0].ToString();
- }));
- }
- public IEnumerator SendHttp(string methodName, Action<string> CallBack)
- {
- string url = "https://api-fat2.ghz-tech.com/" + methodName;
- debugtxt.text += "\n"+url;
- UnityWebRequest webRequest = UnityWebRequest.Get(url);
- webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
- webRequest.SetRequestHeader("Content-Type", "application/json");
- webRequest.SetRequestHeader("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjMxNTM2MDAxNzEyNzQ0NjUxLCJpYXQiOjE3MTI3NDQ2NTEsInVzZXIiOnsiaWQiOjExLCJlbWFpbCI6IiIsInBob25lIjoieWIzIiwibmFtZSI6InliMyIsInJvbGVJZCI6M319.WGpVJHfbTr4Bp2cySjjlgCIon8nF4sJxkl58wcIion8");
- yield return webRequest.SendWebRequest();
- if (webRequest.result == UnityWebRequest.Result.ConnectionError)
- {
- debugtxt.text += "\nwebRequest.error" + webRequest.error;
- Debug.Log(webRequest.error);
- }
- else
- {
- debugtxt.text += "\nwebRequest.text" + webRequest.downloadHandler.text;
- Debug.LogError(webRequest.downloadHandler.text);
- CallBack.Invoke(webRequest.downloadHandler.text);
- }
- }
- }
|