|
@@ -6,6 +6,21 @@ using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
|
+ class TabType
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 首页
|
|
|
+ /// </summary>
|
|
|
+ public static int RECOVER = 0;
|
|
|
+ /// <summary>
|
|
|
+ /// 投稿
|
|
|
+ /// </summary>
|
|
|
+ public static int JOIN = 1;
|
|
|
+ /// <summary>
|
|
|
+ /// 收藏
|
|
|
+ /// </summary>
|
|
|
+ public static int FAVORITES = 2;
|
|
|
+ }
|
|
|
class RecommendType
|
|
|
{
|
|
|
/// <summary>
|
|
@@ -38,7 +53,8 @@ namespace GFGGame
|
|
|
{
|
|
|
private UI_PoemGalleryUI _ui;
|
|
|
private GList _list;
|
|
|
- private List<PoemGalleryData> _galleryDatas = new List<PoemGalleryData>();
|
|
|
+ // private List<PoemGalleryData> _galleryDatas = new List<PoemGalleryData>();
|
|
|
+ private List<long> _galleryDatas = new List<long>();
|
|
|
private int _sortType = 0;//由GallerySortType定义
|
|
|
private int _pageCount = 10;
|
|
|
private int _tabIndex = 0;//当前选中大页签下标,首页0投稿1收藏2
|
|
@@ -123,8 +139,8 @@ namespace GFGGame
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _tabIndex = 0;
|
|
|
- _subtabIndex = 0;
|
|
|
+ _tabIndex = TabType.RECOVER;
|
|
|
+ _subtabIndex = RecommendType.RECOMMEND;
|
|
|
_ui.m_comNormal.m_comBoBox.selectedIndex = 0;
|
|
|
_ui.m_comNormal.m_c1.selectedIndex = _subtabIndex;
|
|
|
_ui.m_comFavorites.m_c1.selectedIndex = _subtabIndex;
|
|
@@ -171,15 +187,32 @@ namespace GFGGame
|
|
|
ViewManager.GoBackFrom(typeof(PoemGalleryView).FullName);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 积分商店
|
|
|
+ /// </summary>
|
|
|
+ private void OnBtnShopClick()
|
|
|
+ {
|
|
|
+ object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
|
|
|
+ ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas }, true);
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 排行榜奖励
|
|
|
+ /// </summary>
|
|
|
+ private void OnBtnRewardClick()
|
|
|
+ {
|
|
|
+ ViewManager.Show<PoemGalleryRewardView>(null, new object[] { typeof(PoemGalleryView).FullName, this.viewData });
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ /********************************************************页签切换*************************************************/
|
|
|
/// <summary>
|
|
|
/// 首页
|
|
|
/// </summary>
|
|
|
private void OnBtnRecoverClick()
|
|
|
{
|
|
|
|
|
|
- if (_tabIndex == 0 && _ui.m_comNormal.m_c1.selectedIndex == RecommendType.RECOMMEND)//当前在推荐页要刷新
|
|
|
+ if (_tabIndex == TabType.RECOVER && _ui.m_comNormal.m_c1.selectedIndex == RecommendType.RECOMMEND)//当前在推荐页要刷新
|
|
|
{
|
|
|
PullDown();
|
|
|
onPullDownRelease();
|
|
@@ -226,7 +259,8 @@ namespace GFGGame
|
|
|
_subtabIndex = _ui.m_comNormal.m_c1.selectedIndex;
|
|
|
if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)//排行榜
|
|
|
{
|
|
|
-
|
|
|
+ _galleryDatas = PoemGalleryDataManager.Instance.RankDatas;
|
|
|
+ ReqGalleryRankList();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -281,6 +315,8 @@ namespace GFGGame
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /********************************************************请求更新列表*************************************************/
|
|
|
+
|
|
|
//分页刷新
|
|
|
private void onScroll()
|
|
|
{
|
|
@@ -298,36 +334,38 @@ namespace GFGGame
|
|
|
{
|
|
|
PoemGallerySProxy.ReqGalleryList(_sortType, startIndex, _pageCount).Coroutine();
|
|
|
}
|
|
|
-
|
|
|
private void UpdateGalleryList()
|
|
|
{
|
|
|
_list.numItems = _galleryDatas.Count;
|
|
|
UpdateView();
|
|
|
}
|
|
|
+
|
|
|
+ //请求排行榜刷新
|
|
|
+ private void ReqGalleryRankList()
|
|
|
+ {
|
|
|
+ PoemGallerySProxy.ReqRankList().Coroutine();
|
|
|
+ }
|
|
|
private void UpdateGalleryRankList()
|
|
|
{
|
|
|
_ui.m_comNormal.m_listRank.numItems = _galleryDatas.Count;
|
|
|
UpdateView();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 积分商店
|
|
|
- /// </summary>
|
|
|
- private void OnBtnShopClick()
|
|
|
+ private void RefreshList()
|
|
|
{
|
|
|
- object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
|
|
|
- ViewManager.Show<ClothingShopView>(new object[] { ConstStoreId.GALLERY_STORE_ID }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas }, true);
|
|
|
+ if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)
|
|
|
+ {
|
|
|
+ _ui.m_comNormal.m_listRank.RefreshVirtualList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _list.RefreshVirtualList();
|
|
|
+ }
|
|
|
+ UpdateView();
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 排行榜奖励
|
|
|
- /// </summary>
|
|
|
- private void OnBtnRewardClick()
|
|
|
- {
|
|
|
- ViewManager.Show<PoemGalleryRewardView>(null, new object[] { typeof(PoemGalleryView).FullName, this.viewData });
|
|
|
- }
|
|
|
|
|
|
+ /********************************************************界面更新*************************************************/
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
GalleryThemeCfg themeCfg = GalleryThemeCfgArray.Instance.GetCfg((int)PoemGalleryDataManager.Instance.ThemeId);
|
|
@@ -335,10 +373,13 @@ namespace GFGGame
|
|
|
_ui.m_comNormal.m_txtRank.text = string.Format("我的排名:{0}", PoemGalleryDataManager.Instance.MyRank);
|
|
|
_ui.m_comNormal.m_txtRewardCount.text = string.Format("奖励次数:{0}/{1}", PoemGalleryDataManager.Instance.VoteCount, GalleryRewardCfgArray.Instance.dataArray.Length);
|
|
|
_ui.m_comNormal.m_txtTime.text = PoemGalleryDataManager.Instance.GetThemeTime();
|
|
|
+ _ui.m_comNormal.m_grpResult.visible = PoemGalleryDataManager.Instance.IsResulting();
|
|
|
}
|
|
|
+
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
- // PoemGalleryData data = _galleryDatas[index];
|
|
|
+ // long workId = _galleryDatas[index];
|
|
|
+ // PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
|
|
|
UI_ListItem item = UI_ListItem.Proxy(obj);
|
|
|
// item.m_loaIcon.height = 550 + Random.Range(40, 100);
|
|
|
// if (index > 1)
|
|
@@ -357,17 +398,17 @@ namespace GFGGame
|
|
|
// {
|
|
|
// item.m_loaIcon.onClick.Add(OnLoaIconClick);
|
|
|
// }
|
|
|
- // item.m_loaIcon.data = data;
|
|
|
+ // item.m_loaIcon.data = workId;
|
|
|
// if (item.m_btnCollect.data == null)
|
|
|
// {
|
|
|
// item.m_btnCollect.onClick.Add(OnBtnCollectClick);
|
|
|
// }
|
|
|
- // item.m_btnCollect.data = data;
|
|
|
+ // item.m_btnCollect.data = workId;
|
|
|
// if (item.m_btnVote.data == null)
|
|
|
// {
|
|
|
// item.m_btnVote.onClick.Add(OnBtnVoteClick);
|
|
|
// }
|
|
|
- // item.m_btnVote.data = data;
|
|
|
+ // item.m_btnVote.data = workId;
|
|
|
UI_ListItem.ProxyEnd();
|
|
|
|
|
|
}
|
|
@@ -375,67 +416,119 @@ namespace GFGGame
|
|
|
|
|
|
private void RenderListRankItem(int index, GObject obj)
|
|
|
{
|
|
|
+ // long workId = _galleryDatas[index];
|
|
|
+ // PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
|
|
|
+ // UI_ListRankItem item = UI_ListRankItem.Proxy(obj);
|
|
|
+ // item.m_loaIcon.height = 550 + Random.Range(40, 100);
|
|
|
+
|
|
|
+ // item.target.height = item.m_loaIcon.height + 80;
|
|
|
+ // item.m_loaIcon.texture = data.Ntexture;
|
|
|
+ // item.m_txtName.text = data.AuthorName;
|
|
|
+ // item.m_btnCollect.title = data.CollectCount.ToString();
|
|
|
+ // item.m_btnCollect.selected = data.CollectOrNot;
|
|
|
+ // item.m_btnVote.title = data.VoteCount.ToString();
|
|
|
+ // item.m_btnVote.selected = data.VoteOrNot;
|
|
|
+ // item.m_c1.selectedIndex = index < 3 ? index : 3;
|
|
|
|
|
|
+ // if (item.m_loaIcon.data == null)
|
|
|
+ // {
|
|
|
+ // item.m_loaIcon.onClick.Add(OnLoaIconClick);
|
|
|
+ // }
|
|
|
+ // item.m_loaIcon.data = workId;
|
|
|
+ // if (item.m_btnCollect.data == null)
|
|
|
+ // {
|
|
|
+ // item.m_btnCollect.onClick.Add(OnBtnCollectClick);
|
|
|
+ // }
|
|
|
+ // item.m_btnCollect.data = workId;
|
|
|
+ // if (item.m_btnVote.data == null)
|
|
|
+ // {
|
|
|
+ // item.m_btnVote.onClick.Add(OnBtnVoteClick);
|
|
|
+ // }
|
|
|
+ // item.m_btnVote.data = workId;
|
|
|
+ // UI_ListRankItem.ProxyEnd();
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
private void OnLoaIconClick(EventContext context)
|
|
|
{
|
|
|
GObject obj = context.data as GObject;
|
|
|
- PoemGalleryData data = obj.data as PoemGalleryData;
|
|
|
+ // PoemGalleryData data = obj.data as PoemGalleryData;
|
|
|
+ long workId = (long)obj.data;
|
|
|
object[] gobackParamDatas = new object[] { _tabIndex, _subtabIndex, _ui.m_comNormal.m_comBoBox.selectedIndex };
|
|
|
- ViewManager.Show<PoemGalleryPreviewView>(new object[] { _sortType, data }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas });
|
|
|
+ ViewManager.Show<PoemGalleryPreviewView>(new object[] { _sortType, workId }, new object[] { typeof(PoemGalleryView).FullName, gobackParamDatas });
|
|
|
}
|
|
|
|
|
|
private async void OnBtnCollectClick(EventContext context)
|
|
|
{
|
|
|
GObject obj = context.data as GObject;
|
|
|
- PoemGalleryData galleryData = obj.data as PoemGalleryData;
|
|
|
+ long workId = (long)obj.data;
|
|
|
+ PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
|
|
|
+
|
|
|
if (galleryData.CollectOrNot)
|
|
|
{
|
|
|
- bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(galleryData.WorkId);
|
|
|
+ bool result = await PoemGallerySProxy.ReqCancelCollecteGalleryWorks(workId);
|
|
|
if (result)
|
|
|
{
|
|
|
- galleryData.CollectOrNot = false;
|
|
|
- galleryData.CollectCount = galleryData.CollectCount - 1;
|
|
|
- UpdateView();
|
|
|
- if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)
|
|
|
+ // galleryData.CollectOrNot = false;
|
|
|
+ // galleryData.CollectCount = galleryData.CollectCount - 1;
|
|
|
+
|
|
|
+ if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
|
|
|
{
|
|
|
- _ui.m_comNormal.m_listRank.RefreshVirtualList();
|
|
|
+ ReqGalleryList(0);//当前为收藏页要重新拉取数据
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _list.RefreshVirtualList();
|
|
|
+ RefreshList();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(galleryData.WorkId);
|
|
|
+ bool result = await PoemGallerySProxy.ReqCollecteGalleryWorks(workId);
|
|
|
if (result)
|
|
|
{
|
|
|
- galleryData.CollectOrNot = true;
|
|
|
- galleryData.CollectCount = galleryData.CollectCount + 1;
|
|
|
- UpdateView();
|
|
|
- if (_ui.m_comNormal.m_c1.selectedIndex == RecommendType.RANK)
|
|
|
+ // galleryData.CollectOrNot = true;
|
|
|
+ // galleryData.CollectCount = galleryData.CollectCount + 1;
|
|
|
+ if (_tabIndex == TabType.FAVORITES && _subtabIndex == FavoritesType.FAVORITE)
|
|
|
{
|
|
|
- _ui.m_comNormal.m_listRank.RefreshVirtualList();
|
|
|
+ ReqGalleryList(0);//当前为收藏页要重新拉取数据
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _list.RefreshVirtualList();
|
|
|
+ RefreshList();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void OnBtnVoteClick(EventContext context)
|
|
|
+ private async void OnBtnVoteClick(EventContext context)
|
|
|
{
|
|
|
GObject obj = context.data as GObject;
|
|
|
- PoemGalleryData data = obj.data as PoemGalleryData;
|
|
|
+ // PoemGalleryData galleryData = obj.data as PoemGalleryData;
|
|
|
+ long workId = (long)obj.data;
|
|
|
+ PoemGalleryData galleryData = PoemGalleryDataManager.Instance.GetGalleryDataById(workId);
|
|
|
+
|
|
|
+ if (galleryData.VoteOrNot) return;
|
|
|
+ bool result = await PoemGallerySProxy.ReqVoteGalleryWorks(workId);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ // galleryData.VoteOrNot = true;
|
|
|
+ // galleryData.CollectCount = galleryData.CollectCount + 1;
|
|
|
+ RefreshList();
|
|
|
|
|
|
+ int Count = GameGlobal.myNumericComponent.GetAsInt(NumericType.LikeGalleryWorksCountDaily);
|
|
|
+ GalleryIntegralCfg integralCfg = GalleryIntegralCfgArray.Instance.GetCfg(Count);
|
|
|
+ if (integralCfg != null)
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(integralCfg.itemId);
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt(string.Format("{0} +{1}", itemCfg.name, integralCfg.Count));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /********************************************************下拉刷新*************************************************/
|
|
|
private void PullDown()
|
|
|
{
|
|
|
if (_ui.m_comNormal.m_listRecommend.numItems > 0) _ui.m_comNormal.m_listRecommend.ScrollToView(0);
|
|
@@ -456,6 +549,7 @@ namespace GFGGame
|
|
|
_ui.m_comNormal.m_listRecommend.scrollPane.LockHeader(header.sourceHeight);
|
|
|
Timers.inst.Add(2, 1, OnTimeComplete);
|
|
|
}
|
|
|
+
|
|
|
private void OnTimeComplete(object param)
|
|
|
{
|
|
|
GComponent header = _ui.m_comNormal.m_listRecommend.scrollPane.header;
|