113 lines
2.9 KiB
C#
113 lines
2.9 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ByCode : MonoBehaviour
|
|
{
|
|
public Root myroot = new Root();
|
|
public Dictionary<string, string> lineCode_dic = new Dictionary<string, string>();
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public IEnumerator getByCode(Action<string> callback)
|
|
{
|
|
yield return StartCoroutine(
|
|
CombineJSON.GetJson_GET(GameManager.Inst.Jk_URL.xllx_sc, GameManager.Inst.arguments.token, (jsonResult) =>
|
|
{
|
|
if (!string.IsNullOrEmpty(jsonResult))
|
|
{
|
|
try
|
|
{
|
|
myroot = JsonConvert.DeserializeObject<Root>(jsonResult);
|
|
if (myroot.data != null && myroot.message == "操作成功")
|
|
{
|
|
lineCode_dic.Clear();
|
|
for (int i = 0; i < myroot.data.Count; i++)
|
|
{
|
|
//if (!lineCode_dic.ContainsKey(myroot.data[i].name))
|
|
lineCode_dic.Add(myroot.data[i].name, myroot.data[i].value);
|
|
}
|
|
callback.Invoke("1");
|
|
}
|
|
else
|
|
callback.Invoke(null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Log("查询线路类型接口错误:" + e.Message + e.StackTrace);
|
|
callback.Invoke(null);
|
|
}
|
|
}
|
|
else
|
|
callback.Invoke(null);
|
|
}));
|
|
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class Data
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string id;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string code;
|
|
/// <summary>
|
|
/// 名字
|
|
/// </summary>
|
|
public string name;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string value;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
//public int deleteFlag;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string remark;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
//public int createTime;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class Root
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string code;
|
|
/// <summary>
|
|
/// 操作成功
|
|
/// </summary>
|
|
public string message;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<Data> data;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string serverTime;
|
|
}
|
|
|
|
}
|