123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- using UnityEngine.UI;
- public class KangFuItem : MonoBehaviour
- {
- public InputField input;
- public Text lun;
- public Text ting;
- public Text zhen;
- public Text ji;
- public Text wo;
- public void setData(JsonData data,int index)
- {
- lun.text = data["time"].ToString();
- float max =(float)( int.Parse(data["fting"].ToString())/ (float)( int.Parse(data["sting"].ToString()) + int.Parse(data["fting"].ToString())));
- ting.text = "正确:"+ data["sting"].ToString()+ " 错误:" + data["fting"].ToString()+" 错误率:"+(max * 100) + "%";
- zhen.text = data["zhen"].ToString();
- float maxji = (float)(int.Parse(data["fji"].ToString()) / (float)(int.Parse(data["sji"].ToString()) + int.Parse(data["fji"].ToString())));
- ji.text = "正确:" + data["sji"].ToString() + " 错误:" + data["fji"].ToString() + " 错误率:" + (maxji*100)+"%";
- wo.text = data["wo"].ToString();
- }
- public void geturl()
- {
- StartCoroutine(SendHttp("cmcc-endustry/v1/report/dairyCattle/dataToDoc", (string str) =>
- {
- JsonData data = JsonMapper.ToObject(str);
- input.text = data["data"]["downloadUrl"].ToString();
- Debug.Log("str===>?"+str);
- }));
- }
- public IEnumerator SendHttp(string methodName, Action<string> CallBack)
- {
- string url = "https://api-fat2.ghz-tech.com/" + methodName + "?userName=" + KangFuOne.choosename+ "&fileName=" + KangFuOne.choosename;
- UnityWebRequest webRequest = UnityWebRequest.Get(url);
- string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjMxNTM2MDAxNzEyNzQ0NjUxLCJpYXQiOjE3MTI3NDQ2NTEsInVzZXIiOnsiaWQiOjExLCJlbWFpbCI6IiIsInBob25lIjoieWIzIiwibmFtZSI6InliMyIsInJvbGVJZCI6M319.WGpVJHfbTr4Bp2cySjjlgCIon8nF4sJxkl58wcIion8";
- //UnityWebRequest webRequest = new UnityWebRequest(url, "GET");
- JsonData data = new JsonData();
- data["userName"] = KangFuOne.choosename;
- data["fileName"] = KangFuOne.choosename+"_"+DateTime.Now.ToString();
- webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
- webRequest.SetRequestHeader("authorization", token);//请求头文件内容
- Debug.Log(url);
- yield return webRequest.SendWebRequest();
- if (webRequest.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(webRequest.error);
- }
- else
- {
- Debug.LogError(webRequest.downloadHandler.text);
- CallBack.Invoke(webRequest.downloadHandler.text);
- }
- }
- }
|