|
|
@@ -1,12 +1,11 @@
|
|
|
-import { _decorator, Button, Color, EditBox, instantiate, Label, Node, NodePool, Prefab, ProgressBar, RichText, Sprite, SpriteFrame, UITransform } from 'cc';
|
|
|
+import { _decorator, instantiate, Label, Node, NodePool, Prefab, ProgressBar } from 'cc';
|
|
|
import { UIView } from '@scripts/framework/ui/UIView';
|
|
|
import { AppKernel } from '@scripts/app/AppKernel';
|
|
|
import { UIViewID } from '@scripts/define/UIDefine';
|
|
|
-import { UICloseReason } from '@scripts/framework/ui/UILayer';
|
|
|
-import { formatCurrency } from '@scripts/utils/Helper';
|
|
|
import { addBtnClick } from '@scripts/utils/UIHelper';
|
|
|
import { RewardItem, RewardType } from './Tasks/RewardItem';
|
|
|
import { NodeItem } from './Prize/NodeItem';
|
|
|
+import VirtualList from '@scripts/components/virtualList/VirtualList';
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -23,75 +22,69 @@ export class SeasonPassView extends UIView {
|
|
|
readonly viewId = UIViewID.SeasonPassView;
|
|
|
|
|
|
@property(Node)
|
|
|
- btn_close: Node = null;
|
|
|
+ private btn_close: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- btn_tasks: Node = null;
|
|
|
+ private btn_tasks: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- btn_prize: Node = null;
|
|
|
+ private btn_prize: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- btn_buyPass: Node = null;
|
|
|
+ private btn_buyPass: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- tasks: Node = null;
|
|
|
+ private tasks: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- prize: Node = null;
|
|
|
+ private prize: Node = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- season_end: Label = null;
|
|
|
+ private season_end: Label = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- tasks_daily_done: Label = null;
|
|
|
+ private tasks_daily_done: Label = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- tasks_daily_reset: Label = null;
|
|
|
+ private tasks_daily_reset: Label = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- tasks_daily_content: Node = null;
|
|
|
+ private tasks_daily_content: Node = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- tasks_seasonal_done: Label = null;
|
|
|
+ private tasks_seasonal_done: Label = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- tasks_seasonal_reset: Label = null;
|
|
|
+ private tasks_seasonal_reset: Label = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- tasks_seasonal_content: Node = null;
|
|
|
+ private tasks_seasonal_content: Node = null;
|
|
|
|
|
|
@property(Prefab)
|
|
|
- tasks_reward_item: Prefab = null;
|
|
|
+ private tasks_reward_item: Prefab = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- prize_content: Node = null;
|
|
|
-
|
|
|
- @property(Prefab)
|
|
|
- prize_node_item: Prefab = null;
|
|
|
+ private prize_fixed_dlx: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- prize_fixed_dlx: Node = null;
|
|
|
+ private redPoint_tasks: Node = null;
|
|
|
|
|
|
@property(Node)
|
|
|
- redPoint_tasks: Node = null;
|
|
|
-
|
|
|
- @property(Node)
|
|
|
- redPoint_prize: Node = null;
|
|
|
+ private redPoint_prize: Node = null;
|
|
|
|
|
|
@property(ProgressBar)
|
|
|
- progressBar: ProgressBar = null;
|
|
|
+ private progressBar: ProgressBar = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- progress_label: Label = null;
|
|
|
+ private progress_label: Label = null;
|
|
|
|
|
|
@property(Label)
|
|
|
- next_need_exp: Label = null;
|
|
|
+ private next_need_exp: Label = null;
|
|
|
|
|
|
- @property(Node)
|
|
|
- scrollView_content: Node = null;
|
|
|
+ @property(VirtualList)
|
|
|
+ private scrollView: VirtualList;
|
|
|
|
|
|
- private _seasonPassData: any = null;
|
|
|
+ private _store: any = {};
|
|
|
|
|
|
private _dailyItemPool: NodePool = new NodePool();
|
|
|
private _dailyUsedItems: Node[] = [];
|
|
|
@@ -99,39 +92,44 @@ export class SeasonPassView extends UIView {
|
|
|
private _seasonalItemPool: NodePool = new NodePool();
|
|
|
private _seasonalUsedItems: Node[] = [];
|
|
|
|
|
|
- private _prizeItemPool: NodePool = new NodePool();
|
|
|
- private _prizeUsedItems: Node[] = [];
|
|
|
-
|
|
|
|
|
|
|
|
|
protected async onBeforeOpen(_params: unknown): Promise<boolean> {
|
|
|
- const seasonPassStore = AppKernel.stores.seasonPassStore;
|
|
|
- const res = await seasonPassStore.reqSeasonPassInfo();
|
|
|
+ const res = await this._store.reqSeasonPassInfo();
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
protected onCreate(): void | Promise<void> {
|
|
|
+ this._store = AppKernel.stores.seasonPassStore;
|
|
|
+
|
|
|
AppKernel.events.on('seasonPass:update', this.updateSeasonPassView, this);
|
|
|
AppKernel.events.on('checkIn:update', this.handleCheckInUpdate, this);
|
|
|
addBtnClick(this.btn_close, this.onBtnCloseClick, this);
|
|
|
addBtnClick(this.btn_tasks, this.onBtnTasksClick, this);
|
|
|
addBtnClick(this.btn_prize, this.onBtnPrizeClick, this);
|
|
|
addBtnClick(this.btn_buyPass, this.onBtnBuyPassClick, this);
|
|
|
+
|
|
|
this.initView();
|
|
|
}
|
|
|
|
|
|
- // protected onBeforeClose(_reason: UICloseReason): boolean | Promise<boolean> {
|
|
|
+ onRenderNodeItem(item: Node, index: number) {
|
|
|
+ const { pass } = this._store.data ?? {};
|
|
|
+ const { current_xp, is_deluxe } = pass ?? {};
|
|
|
|
|
|
- // return true;
|
|
|
- // }
|
|
|
+ const list = pass?.nodes ?? [];
|
|
|
+ const data = list[index];
|
|
|
+ const nodeItem = item.getComponent(NodeItem);
|
|
|
+ nodeItem.initItem({ node: data, current_xp, is_deluxe });
|
|
|
+ item.active = true;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private handleCheckInUpdate() {
|
|
|
- AppKernel.stores.seasonPassStore.reqSeasonPassInfo();
|
|
|
+ this._store.reqSeasonPassInfo();
|
|
|
}
|
|
|
|
|
|
private updateSeasonPassView() {
|
|
|
- this._seasonPassData = AppKernel.stores.seasonPassStore.seasonPassData;
|
|
|
+ if (this.scrollView.checkInited(false)) this.scrollView.updateAll();
|
|
|
|
|
|
this.updateTasks();
|
|
|
this.updatePrize();
|
|
|
@@ -140,7 +138,7 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
|
|
|
private updateTasks() {
|
|
|
- const { season_tasks } = this._seasonPassData ?? {};
|
|
|
+ const { season_tasks } = this._store.data ?? {};
|
|
|
|
|
|
this.updateDailyTasks();
|
|
|
this.updateSeasonalTasks();
|
|
|
@@ -151,7 +149,7 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
|
|
|
private updateDailyTasks() {
|
|
|
- const { tasks, task_end_timestamp } = this._seasonPassData ?? {};
|
|
|
+ const { tasks, task_end_timestamp } = this._store.data ?? {};
|
|
|
// 将当前正在使用的item全部回收进对象池
|
|
|
for (const node of this._dailyUsedItems) {
|
|
|
this._dailyItemPool.put(node);
|
|
|
@@ -182,7 +180,7 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
|
|
|
private updateSeasonalTasks() {
|
|
|
- const { season_tasks } = this._seasonPassData ?? {};
|
|
|
+ const { season_tasks } = this._store.data ?? {};
|
|
|
for (const node of this._seasonalUsedItems) {
|
|
|
this._seasonalItemPool.put(node);
|
|
|
}
|
|
|
@@ -216,29 +214,8 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
|
|
|
private updatePrize() {
|
|
|
- const { pass } = this._seasonPassData ?? {};
|
|
|
+ const { pass } = this._store.data ?? {};
|
|
|
const { current_xp, is_deluxe } = pass ?? {};
|
|
|
- // 将当前正在使用的item全部回收进对象池
|
|
|
- for (const node of this._prizeUsedItems) {
|
|
|
- this._prizeItemPool.put(node);
|
|
|
- }
|
|
|
- this._prizeUsedItems.length = 0;
|
|
|
-
|
|
|
- for (const node of pass?.nodes ?? []) {
|
|
|
- let itemNode: Node;
|
|
|
- if (this._prizeItemPool.size() > 0) {
|
|
|
- itemNode = this._prizeItemPool.get();
|
|
|
- } else {
|
|
|
- itemNode = instantiate(this.prize_node_item);
|
|
|
- }
|
|
|
- itemNode.active = true;
|
|
|
- itemNode.parent = this.prize_content;
|
|
|
-
|
|
|
- const itemCmp = itemNode.getComponent(NodeItem);
|
|
|
- if (itemCmp) itemCmp.initItem({ node, current_xp, is_deluxe });
|
|
|
-
|
|
|
- this._prizeUsedItems.push(itemNode);
|
|
|
- }
|
|
|
|
|
|
const activeLabel = this.prize_fixed_dlx.getChildByName('label');
|
|
|
const btn_unlock = this.prize_fixed_dlx.getChildByName('btn_unlock');
|
|
|
@@ -246,10 +223,12 @@ export class SeasonPassView extends UIView {
|
|
|
activeLabel.active = is_deluxe;
|
|
|
btn_unlock.active = !is_deluxe;
|
|
|
lock.active = !is_deluxe;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private updateRedPoint() {
|
|
|
- const { tasks, season_tasks, pass } = this._seasonPassData ?? {};
|
|
|
+ const { tasks, season_tasks, pass } = this._store.data ?? {};
|
|
|
|
|
|
const hasTaskReward = tasks?.some(task => task.status === 1) ?? false;
|
|
|
const hasSeasonalReward = season_tasks?.tasks.some(task => task.status === 1) ?? false;
|
|
|
@@ -275,7 +254,7 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
|
|
|
private updateProgress() {
|
|
|
- const { pass } = this._seasonPassData ?? {};
|
|
|
+ const { pass } = this._store.data ?? {};
|
|
|
const { current_xp, nodes } = pass ?? {};
|
|
|
const next_need_exp = nodes?.find(node => node.required_xp > current_xp)?.required_xp;
|
|
|
|
|
|
@@ -302,17 +281,12 @@ export class SeasonPassView extends UIView {
|
|
|
}
|
|
|
this._seasonalUsedItems.length = 0;
|
|
|
|
|
|
- for (const node of this._prizeUsedItems) {
|
|
|
- this._prizeItemPool.put(node);
|
|
|
- }
|
|
|
- this._prizeUsedItems.length = 0;
|
|
|
}
|
|
|
|
|
|
// 弹窗销毁,清空池子释放资源
|
|
|
protected onDestroy(): void {
|
|
|
this._dailyItemPool.clear();
|
|
|
this._seasonalItemPool.clear();
|
|
|
- this._prizeItemPool.clear();
|
|
|
this.stopAllTimer();
|
|
|
|
|
|
AppKernel.events.off('seasonPass:update', this.updateSeasonPassView, this);
|
|
|
@@ -323,38 +297,6 @@ export class SeasonPassView extends UIView {
|
|
|
|
|
|
private initView() {
|
|
|
this.onToggleSidebar("tasks");
|
|
|
-
|
|
|
-
|
|
|
- // const items_data = new Array(10).fill(0);
|
|
|
- // items_data.forEach((item, index) => {
|
|
|
- // const item_DLX = instantiate(this.item_DLX);
|
|
|
- // item_DLX.parent = this.item_DLX.parent;
|
|
|
- // item_DLX.active = true;
|
|
|
-
|
|
|
-
|
|
|
- // const item_free = instantiate(this.item_free);
|
|
|
- // item_free.parent = this.item_free.parent;
|
|
|
- // item_free.active = true;
|
|
|
-
|
|
|
-
|
|
|
- // const item_progress = instantiate(this.item_progress);
|
|
|
- // item_progress.parent = this.item_progress.parent;
|
|
|
- // item_progress.active = true;
|
|
|
-
|
|
|
-
|
|
|
- // })
|
|
|
-
|
|
|
-
|
|
|
- // this.scheduleOnce(() => {
|
|
|
- // console.log("item_DLX.parent.width", this.item_DLX.parent.getComponent(UITransform).width)
|
|
|
- // console.log("item_free.parent.width", this.item_free.parent.getComponent(UITransform).width)
|
|
|
-
|
|
|
- // console.log("item_progress.parent.width", this.item_progress.parent.getComponent(UITransform).width)
|
|
|
-
|
|
|
- // this.scrollView_content.getComponent(UITransform).width = this.item_free.parent.getComponent(UITransform).width;
|
|
|
- // })
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private onBtnCloseClick() {
|
|
|
@@ -380,10 +322,13 @@ export class SeasonPassView extends UIView {
|
|
|
|
|
|
private onBtnPrizeClick() {
|
|
|
this.onToggleSidebar("prize");
|
|
|
+
|
|
|
+ const data = this._store.data ?? {};
|
|
|
+ this.scrollView.numItems = data?.pass?.nodes?.length ?? 0;
|
|
|
}
|
|
|
|
|
|
private onBtnBuyPassClick() {
|
|
|
- const { pass } = this._seasonPassData ?? {};
|
|
|
+ const { pass } = this._store.data ?? {};
|
|
|
const gear = pass?.purchase_gear;
|
|
|
if (!gear) return;
|
|
|
|