123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using Blue;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using Agora.Rtc.LitJson;
- namespace GHZLangChao
- {
- public class DeviceInfo_Item : AbstractController
- {
- private DeviceParameters DeviceParameter;
- public Transform currentPos;
- public DataItem item;
- public TMP_Text deviceName;
- public TMP_Text type;
- public TMP_Text model;
- public TMP_Text ip;
- [SerializeField] private Button DetailsBtn;
- private IQueueSystem mQueueSystem;
- private void Start()
- {
- DetailsBtn.onClick.AddListener(ClickDetails);
- }
- int i;
- public void Init(DeviceParameters DeviceParameter, int i, DataItem item)
- {
- this.DeviceParameter = DeviceParameter;
- this.i = i;
- this.item = item;
- deviceName.text = DeviceParameter.cabinetNumber;
- type.text = DeviceParameter.deviceType;
- model.text = DeviceParameter.deviceBrand;
- ip.text = DeviceParameter.managementIP;
- }
- public void InitNull()
- {
- SettingNull();
- }
- private void ClickDetails()
- {
- // DeviceParameter.deviceModel = "NetView400" + i;
- // Vector3 currentPos = transform.position; // 为了将详情面板移动到面前
- // 从后台获取UI详情
- JsonData data = new JsonData();
- data["cabinetNumber"] = DeviceParameter.cabinetNumber;
- data["u"] = DeviceParameter.u;
- // string jsondata = JsonConvert.SerializeObject(data);
- Debug.Log(data.ToJson());
- StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.bladeServer, data.ToJson(), BladeServerCallBack));
- // HttpLangChaoTool.Instance.Post(HttpLangChaoAction.bladeServer, jsondata, BladeServerCallBack);
-
- // item.gameObject.SetActive(false);
- }
- private void SettingNull()
- {
- DetailsBtn.interactable = false;
- transform.GetComponent<Image>().enabled = false;
- for (int i = 0; i < transform.childCount; i++)
- {
- transform.GetChild(i).gameObject.SetActive(false);
- }
- }
- private void BladeServerCallBack(string msg)
- {
- Debug.Log(msg);
- JObject json = JObject.Parse(msg);
- if (json["code"].ToString() == "200")
- {
- string data = json["data"]["list"][0].ToString();
- Debug.Log(data);
- this.DeviceParameter = JsonConvert.DeserializeObject<DeviceParameters>(data);
- Debug.Log(JsonConvert.SerializeObject(this.DeviceParameter));
- this.SendCommand(new DeviceDetailsUpdataDataCommand(DeviceParameter, currentPos, item)); // 触发事件,打开面板,更新数据
- }
- else
- {
- Debug.LogError(" 请求刀片机详情参数出错 !!! " + HttpActionLang.bladeServer);
- }
- }
- private void OnEnable()
- {
- if (mQueueSystem == null)
- mQueueSystem = this.GetService<IQueueSystem>();
- mQueueSystem.Add(gameObject);
- }
- private void OnDestroy()
- {
- mQueueSystem.Remove(gameObject);
- }
- }
- }
|