122 lines
3.1 KiB
C#
122 lines
3.1 KiB
C#
using Components;
|
||
using Data;
|
||
using MobileTerminal;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author #AUTHOR#
|
||
//@create #CREATEDATE#
|
||
//@company #COMPANY#
|
||
//
|
||
//@description:
|
||
//============================================================
|
||
|
||
public class MobileTerminalController : MonoBehaviour
|
||
{
|
||
public string userViewUrl;
|
||
public string tapViewUrl;
|
||
public InputField number;
|
||
public Button outsideBtn;
|
||
public Button electricitBtn;
|
||
public Button backBtn;
|
||
|
||
public GameObject tapView;
|
||
public GameObject userView;
|
||
|
||
public Transform userContent;
|
||
public Transform tapContent;
|
||
public MobileTerminalTipsItem itemPrfab;
|
||
[HideInInspector]
|
||
public UserViewData mData = new UserViewData();
|
||
//[HideInInspector]
|
||
public TableViewData tData = new TableViewData();
|
||
public JObject jbsx;
|
||
public JObject jbxx;
|
||
public List<JObject> jlzzxx = new List<JObject>();
|
||
|
||
// Use this for initialization
|
||
private async void Start()
|
||
{
|
||
mData = await AsyncWebReq.Get<UserViewData>(userViewUrl);
|
||
tData = await AsyncWebReq.Get<TableViewData>(tapViewUrl);
|
||
|
||
|
||
string jsonData = JsonConvert.SerializeObject(mData);
|
||
AsyncWebReq.SetValue(jsonData, out jbsx, out jbxx, out jlzzxx);
|
||
|
||
foreach (var item in jbsx)
|
||
{
|
||
MobileTerminalTipsItem itemTip = Instantiate(itemPrfab, userContent);
|
||
string info = item.Key + ": " + item.Value;
|
||
itemTip.SetValue(info);
|
||
}
|
||
|
||
foreach (var item in jbxx)
|
||
{
|
||
MobileTerminalTipsItem itemTip = Instantiate(itemPrfab, userContent);
|
||
string info = item.Key + ": " + item.Value;
|
||
itemTip.SetValue(info);
|
||
}
|
||
|
||
for (int i = 0; i < jlzzxx.Count; i++)
|
||
{
|
||
foreach (var item in jlzzxx[i])
|
||
{
|
||
MobileTerminalTipsItem itemTip = Instantiate(itemPrfab, userContent);
|
||
string info = item.Key + ": " + item.Value;
|
||
itemTip.SetValue(info);
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < tData.data.Count; i++)
|
||
{
|
||
MobileTerminalTipsItem itemTip = Instantiate(itemPrfab, tapContent);
|
||
itemTip.SetValue(tData.data[i]);
|
||
}
|
||
|
||
outsideBtn.onClick.AddListener(OnOutsideView);
|
||
electricitBtn.onClick.AddListener(OnElectricitView);
|
||
backBtn.onClick.AddListener(OnBack);
|
||
SwitchView(-1);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
public void OnElectricitView()
|
||
{
|
||
SwitchView(0);
|
||
}
|
||
|
||
public void OnOutsideView()
|
||
{
|
||
SwitchView(1);
|
||
}
|
||
|
||
|
||
public void SwitchView(int index)
|
||
{
|
||
userView.SetActive(index == 0);
|
||
tapView.SetActive(index == 1);
|
||
if (index == 0 || index == 1)
|
||
{
|
||
backBtn.gameObject.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
backBtn.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
public void OnBack()
|
||
{
|
||
SwitchView(-1);
|
||
}
|
||
}
|