Beispiel #1
0
    /// <summary>
    /// 获取城市信息
    /// </summary>
    /// <param name="_strCityName"></param>
    /// <param name="callback"></param>
    public static void GetCityInfo(string _strCityName, Action <string> callback)
    {
        if (_strCityName.Contains(" "))
        {
            Debug.LogWarning("城市名称[" + _strCityName + "]包含空格,请留意!");
            _strCityName = _strCityName.Trim();
        }

        WWWManager.Instance.Get("cities/fetch_city", new NameValueCollection()
        {
            { "city_name", _strCityName }
        }, resp =>
        {
            if (resp.Error != HttpResp.ErrorType.None)
            {
                InfoTips.LogInfo("Get Material Error: " + resp.ToString());
                callback(resp.ToString());
            }
            else
            {
                //Debug.LogWarning("加载出来的CmpConfig:" + resp.WwwText);
                //MonoHelper.Instance.SaveInfo(resp.WwwText);
                callback(resp.WwwText);
            }
        });
    }
Beispiel #2
0
 /// <summary>
 /// 获取临时数据接口:name,type 不指定,获取的是所有临时数据
 /// </summary>
 /// <param name="_strName"></param>
 /// <param name="_strType"></param>
 /// <param name="callback"></param>
 public static void GetTempData(string _strName, string _strType, Action <string> callback, Action <string> _failCb = null)
 {
     WWWManager.Instance.Get("temp_buildings/fetch_info", new NameValueCollection()
     {
         { "name", _strName },
         { "type", _strType }
     }, resp =>
     {
         if (resp.Error != HttpResp.ErrorType.None)
         {
             InfoTips.LogInfo("temp_buildings/fetch_info" + resp.ToString());
             if (_failCb != null)
             {
                 _failCb(resp.WwwText);
             }
             else
             {
                 callback(resp.ToString());
             }
         }
         else
         {
             callback(resp.WwwText);
         }
     });
 }
Beispiel #3
0
 public static void GetCmpConfig(string _strCmpName, Action <string> callback)
 {
     WWWManager.Instance.Get("components/fetch_info", new NameValueCollection()
     {
         { "name", _strCmpName }
     }, resp =>
     {
         if (resp.Error != HttpResp.ErrorType.None)
         {
             InfoTips.LogInfo("Get Material Error: " + resp.ToString());
             callback(resp.ToString());
         }
         else
         {
             //Debug.LogWarning("加载出来的CmpConfig:" + resp.WwwText);
             //MonoHelper.Instance.SaveInfo(resp.WwwText,"原始组件配置");
             callback(resp.WwwText);
         }
     });
 }
Beispiel #4
0
    public static bool HasRespError(HttpResp resp, bool autoShowError = true)
    {
        var hasError = resp.Error != HttpResp.ErrorType.None;

        if (hasError)
        {
            lastErrorMsg = resp.ToString();

            if (resp.Error == HttpResp.ErrorType.AccessExpired)
            {
            }
            else if (autoShowError)
            {
                //Dialog.ShowLastHttpError();
                //new WindowAlertDialog(resp.Error.ToString()).Show();
            }
            InfoTips.LogInfo("网络错误" + resp.Error.ToString() + ": " + resp.WwwText);
        }

        return(hasError);
    }