PoemPhotoSProxy.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Net;
  5. using System.Net.Http;
  6. using ET;
  7. using FairyGUI;
  8. using UnityEngine;
  9. using UnityEngine.Networking;
  10. namespace GFGGame
  11. {
  12. public static class PoemPhotoSProxy
  13. {
  14. //获取玩家所有相册数据协议
  15. public static async ETTask<bool> ReqAllPhotoInfos()
  16. {
  17. S2C_GetAllAlbumInfo response = null;
  18. response = (S2C_GetAllAlbumInfo)await MessageHelper.SendToServer(new C2S_GetAllAlbumInfo());
  19. if (response != null)
  20. {
  21. if (response.Error == ErrorCode.ERR_Success)
  22. {
  23. for (int i = 0; i < response.PictureInfosA.Count; i++)
  24. {
  25. PoemPhotoData photoData = new PoemPhotoData();
  26. photoData.PictureId = response.PictureInfosA[i].PictureId;
  27. photoData.CreationTime = response.PictureInfosA[i].CreationTime;
  28. photoData.ToppingStatus = response.PictureInfosA[i].ToppingStatus;
  29. photoData.LockingStatus = response.PictureInfosA[i].LockingStatus;
  30. photoData.SourceType = response.PictureInfosA[i].SourceType;
  31. photoData.PictureTempUrl = response.PictureInfosA[i].PictureTempUrl;
  32. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.PersonalAlbum);
  33. }
  34. Timers.inst.StartCoroutine(PictureStorageHelper.Download(PoemPhotoDataManager.Instance.PersonalPhotoInfos));
  35. for (int i = 0; i < response.PictureInfosB.Count; i++)
  36. {
  37. PoemPhotoData photoData = new PoemPhotoData();
  38. photoData.PictureId = response.PictureInfosB[i].PictureId;
  39. photoData.CreationTime = response.PictureInfosB[i].CreationTime;
  40. photoData.ToppingStatus = response.PictureInfosB[i].ToppingStatus;
  41. photoData.LockingStatus = response.PictureInfosB[i].LockingStatus;
  42. photoData.SourceType = response.PictureInfosB[i].SourceType;
  43. photoData.TravelLocationId = response.PictureInfosB[i].TravelLocationId;
  44. photoData.TravelSuitId = response.PictureInfosB[i].TravelSuitId;
  45. photoData.SuitResIndex = response.PictureInfosB[i].TravelSuitResourceIndex;
  46. photoData.PositionIndex = response.PictureInfosB[i].PositionIndex;
  47. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.WanShuiQianShan);
  48. }
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. //获取图片的临时上传地址协议
  55. public static async ETTask<object[]> ReqTempPictureUrl()
  56. {
  57. ViewManager.Show<ModalStatusView>("上传中...");
  58. S2C_GetTempPictureUrl response = null;
  59. response = (S2C_GetTempPictureUrl)await MessageHelper.SendToServer(new C2S_GetTempPictureUrl() { PictureType = (int)PictureType.jpg });
  60. if (response != null)
  61. {
  62. if (response.Error == ErrorCode.ERR_Success)
  63. {
  64. return new object[] { response.TempPictureUrl, response.PictureId };
  65. }
  66. }
  67. else
  68. {
  69. ViewManager.Hide<ModalStatusView>();
  70. PromptController.Instance.ShowFloatTextPrompt("获取上传地址失败");
  71. }
  72. return null;
  73. }
  74. //保存成功后,添加图片至相册
  75. public static async ETTask<long> ReqAddTophoto(long pictureId)
  76. {
  77. S2C_AddPicture response = null;
  78. response = (S2C_AddPicture)await MessageHelper.SendToServer(new C2S_AddPicture() { PictureId = pictureId });
  79. ViewManager.Hide<ModalStatusView>();
  80. if (response != null)
  81. {
  82. if (response.Error == ErrorCode.ERR_Success)
  83. {
  84. PoemPhotoData photoData = new PoemPhotoData();
  85. photoData.PictureId = response.PictureInfo.PictureId;
  86. photoData.CreationTime = response.PictureInfo.CreationTime;
  87. photoData.ToppingStatus = response.PictureInfo.ToppingStatus;
  88. photoData.LockingStatus = response.PictureInfo.LockingStatus;
  89. photoData.PictureTempUrl = response.PictureInfo.PictureTempUrl;
  90. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.PersonalAlbum);
  91. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  92. PromptController.Instance.ShowFloatTextPrompt("已保存至相册");
  93. return response.PictureInfo.PictureId;
  94. }
  95. }
  96. PromptController.Instance.ShowFloatTextPrompt("存储数据失败");
  97. return 0;
  98. }
  99. //批量删除玩家相册
  100. public static async ETTask<bool> ReqRemovedPhoto(List<long> pictureIds, int sourceType)
  101. {
  102. S2C_RemovedPictures response = null;
  103. response = (S2C_RemovedPictures)await MessageHelper.SendToServer(new C2S_RemovedPictures() { PictureIds = pictureIds });
  104. if (response != null)
  105. {
  106. if (response.Error == ErrorCode.ERR_Success)
  107. {
  108. PoemPhotoDataManager.Instance.Remove(response.PictureIds, sourceType);
  109. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. //修改图片锁定状态
  116. public static async ETTask<bool> ReqChangeLockingState(long pictureId, bool state, int sourceType)
  117. {
  118. S2C_UpPictureLockingStatus response = null;
  119. response = (S2C_UpPictureLockingStatus)await MessageHelper.SendToServer(new C2S_UpPictureLockingStatus() { PictureId = pictureId, Status = state });
  120. if (response != null)
  121. {
  122. if (response.Error == ErrorCode.ERR_Success)
  123. {
  124. PoemPhotoDataManager.Instance.ChangeLockingState(response.PictureId, response.Status, sourceType);
  125. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. //修改图片置顶状态
  132. public static async ETTask<bool> ReqChangeToppingState(long pictureId, bool state, int sourceType)
  133. {
  134. S2C_UpPictureToppingStatus response = null;
  135. response = (S2C_UpPictureToppingStatus)await MessageHelper.SendToServer(new C2S_UpPictureToppingStatus() { PictureId = pictureId, Status = state });
  136. if (response != null)
  137. {
  138. if (response.Error == ErrorCode.ERR_Success)
  139. {
  140. PoemPhotoDataManager.Instance.ChangeToppingState(response.PictureId, response.Status, sourceType);
  141. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. }
  148. }