PoemGalleryPreviewView.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using cfg.GfgCfg;
  2. using ET;
  3. using FairyGUI;
  4. using UI.CommonGame;
  5. using UI.Poem;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class PoemGalleryPreviewView : BaseWindow
  10. {
  11. private UI_PoemGalleryPreviewUI _ui;
  12. private int _sortType = 0;//由 GallerySortType 定义
  13. private PoemGalleryData _galleryData;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_PoemGalleryPreviewUI.PACKAGE_NAME;
  27. _ui = UI_PoemGalleryPreviewUI.Create();
  28. this.viewCom = _ui.target;
  29. isfullScreen = true;
  30. //isReturnView = true;
  31. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  32. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  33. _ui.m_btnCollect.onClick.Add(OnBtnCollectClick);
  34. _ui.m_btnVote.onClick.Add(OnBtnVoteClick);
  35. _ui.m_btnAddFriend.onClick.Add(OnBtnAddFriendClick);
  36. _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
  37. }
  38. protected override void AddEventListener()
  39. {
  40. base.AddEventListener();
  41. }
  42. protected override void OnShown()
  43. {
  44. base.OnShown();
  45. _sortType = (int)(this.viewData as object[])[0];
  46. long workId = (long)(this.viewData as object[])[1];
  47. _galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
  48. UpdateView();
  49. }
  50. private async void UpdateView()
  51. {
  52. _ui.m_c1.selectedIndex = _sortType;
  53. _ui.m_txtName.text = _galleryData.AuthorName;
  54. string themeTime = TimeUtil.FormattingTimeTo_yyyMMdd2(_galleryData.CreateTime);
  55. GalleryThemeCfg themeCfg = CommonDataManager.Tables.TblGalleryThemeCfg.GetOrDefault((int)_galleryData.ThemeId);
  56. string themeName = themeCfg.Theme;
  57. _ui.m_txtTheme.text = string.Format("{0} 主题:{1}", themeTime, themeName);// PoemGalleryDataManager.Instance.GetThemeTime();
  58. _ui.m_loaPicture.texture = _galleryData.Ntexture;
  59. _ui.m_btnCollect.selected = _galleryData.CollectOrNot;
  60. _ui.m_btnCollect.title = _galleryData.CollectCount.ToString();
  61. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  62. _ui.m_btnVote.title = _galleryData.VoteCount.ToString();
  63. _ui.m_btnAddFriend.visible = _galleryData.AuthorId != RoleDataManager.roleId && FriendDataManager.Instance.GetFriendDataById(_galleryData.AuthorId) == null;
  64. OtherRoleInfoDetailData roleInfo = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_galleryData.AuthorId);
  65. if (roleInfo != null)
  66. {
  67. _ui.m_txtLvl.text = roleInfo.roleInfo.roleLv.ToString();
  68. RoleInfoManager.Instance.UpdateHead(_ui.m_comHead, roleInfo.roleInfo.headId, roleInfo.roleInfo.headBorderId);
  69. }
  70. }
  71. protected override void OnHide()
  72. {
  73. base.OnHide();
  74. _ui.m_btnAddFriend.selected = false;
  75. _ui.m_btnAddFriend.touchable = true;
  76. }
  77. protected override void RemoveEventListener()
  78. {
  79. base.RemoveEventListener();
  80. }
  81. private void OnBtnBackClick()
  82. {
  83. ViewManager.GoBackFrom(typeof(PoemGalleryPreviewView).FullName);
  84. }
  85. private async void OnBtnCollectClick(EventContext context)
  86. {
  87. if (_galleryData.CollectOrNot)
  88. {
  89. bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(_galleryData.WorkId);
  90. if (result)
  91. {
  92. UpdateView();
  93. }
  94. }
  95. else
  96. {
  97. bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(_galleryData.WorkId);
  98. if (result)
  99. {
  100. UpdateView();
  101. }
  102. }
  103. }
  104. private async void OnBtnVoteClick(EventContext context)
  105. {
  106. if (_galleryData.VoteOrNot) return;
  107. if (PoemGalleryDataManager.Instance.IsResulting())
  108. {
  109. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  110. PromptController.Instance.ShowFloatTextPrompt("排行榜数据正在结算,无法操作");
  111. return;
  112. }
  113. if (!PoemGalleryDataManager.Instance.IsCurThemeWork(_galleryData.CreateTime))
  114. {
  115. _ui.m_btnVote.selected = _galleryData.VoteOrNot;
  116. PromptController.Instance.ShowFloatTextPrompt("往期作品,无法操作");
  117. return;
  118. }
  119. bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(_galleryData.WorkId);
  120. if (result)
  121. {
  122. UpdateView();
  123. int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
  124. GalleryIntegralCfg integralCfg = CommonDataManager.Tables.TblGalleryIntegralCfg.GetOrDefault(Count);
  125. if (integralCfg != null)
  126. {
  127. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(integralCfg.ItemId);
  128. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.Name, integralCfg.Count));
  129. }
  130. }
  131. }
  132. private async void OnBtnAddFriendClick(EventContext context)
  133. {
  134. // if (_ui.m_btnAddFriend.selected == true) return;
  135. bool result = await FriendSProxy.ReqApplyForFriend(_galleryData.AuthorId);
  136. if (result)
  137. {
  138. _ui.m_btnAddFriend.selected = true;
  139. _ui.m_btnAddFriend.touchable = false;
  140. }
  141. }
  142. private void OnBtnDeleteClick(EventContext context)
  143. {
  144. AlertUI.Show("是否确认删除此照片?", "(删除的照片将清除点赞数)")
  145. .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
  146. {
  147. bool result = await PoemGallerySProxy.ReqDeleteMyWorks(_galleryData.WorkId);
  148. if (result)
  149. {
  150. this.Hide();
  151. }
  152. });
  153. }
  154. }
  155. }