WebRequest_URLs.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. /* 在此代码页面存放所有的url以及自定义的url获取方法 */
  6. namespace EZXR.Glass.Network.WebRequest
  7. {
  8. public partial class UnityWebRequest :MonoBehaviour
  9. {
  10. // public class KeyValuePair
  11. // {
  12. // string key;
  13. // string value;
  14. //
  15. // public KeyValuePair(string _key, string _value)
  16. // {
  17. // key = _key;
  18. // value = _value;
  19. // }
  20. // }
  21. public Dictionary<string ,string> urlDic = new Dictionary<string, string>()
  22. {
  23. // { "getProductCategories","https://ar.hz.netease.com/furnishing/getProductCategories.do" },
  24. // { "getProducts","https://ar.hz.netease.com/furnishing/getProducts.do" },
  25. { "getProductCategories","https://mmtest.hz.netease.com/yqm11_8282/furnishing/getProductCategories.do" },
  26. { "getProducts","https://mmtest.hz.netease.com/yqm11_8282/furnishing/getProducts.do" },
  27. { "productCollect","https://mmtest.hz.netease.com/yqm11_8282/furnishing/productCollect.do" }
  28. };
  29. public string GetURL(string urlKey)
  30. {
  31. if (urlDic.ContainsKey(urlKey))
  32. {
  33. string url = urlDic[urlKey] + "?t=" + Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds).ToString() + "&v=1.0";
  34. Debug.Log("GetURL:" + url);
  35. return url;
  36. }
  37. else
  38. {
  39. return "";//如果urlDic中没有指定urlKey的键值则返回空字符串
  40. }
  41. }
  42. }
  43. }