|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Button, EventTouch, find, instantiate, Label, Node, Prefab, ScrollView, size, Size, Sprite, Toggle, UIOpacity } from 'cc';
|
|
|
|
|
|
|
+import { _decorator, find, Label, Node, Prefab, Sprite, Toggle, UIOpacity } from 'cc';
|
|
|
import { AppKernel } from '@scripts/app/AppKernel';
|
|
import { AppKernel } from '@scripts/app/AppKernel';
|
|
|
import { UIView } from '@scripts/framework/ui/UIView';
|
|
import { UIView } from '@scripts/framework/ui/UIView';
|
|
|
import { UIViewID } from '@scripts/define/UIDefine';
|
|
import { UIViewID } from '@scripts/define/UIDefine';
|
|
@@ -10,8 +10,7 @@ import VirtualList from '@scripts/components/virtualList/VirtualList';
|
|
|
import { IGameInfo } from '@scripts/store/gameStore/data';
|
|
import { IGameInfo } from '@scripts/store/gameStore/data';
|
|
|
import { GameItem } from './GameItem';
|
|
import { GameItem } from './GameItem';
|
|
|
import { RED_POINTS } from '@scripts/app/AppRedpoint';
|
|
import { RED_POINTS } from '@scripts/app/AppRedpoint';
|
|
|
-import { formatGCNum, formatSCNum, localStorageGet, localStorageSet } from '@scripts/utils/Helper';
|
|
|
|
|
-import { LOCAL_CURRENCY_MODE } from '@scripts/constants/Localkey';
|
|
|
|
|
|
|
+import { formatGCNum, formatSCNum } from '@scripts/utils/Helper';
|
|
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
@@ -53,10 +52,10 @@ export class HomeView extends UIView {
|
|
|
private tabGameFlags: { [key: string]: Node } = {};
|
|
private tabGameFlags: { [key: string]: Node } = {};
|
|
|
|
|
|
|
|
private gameTabIndex = -1;
|
|
private gameTabIndex = -1;
|
|
|
- private coinModel: CurrencyType = CURRENCY_TYPE.GC;
|
|
|
|
|
private gameDatas: IGameInfo[] = [];
|
|
private gameDatas: IGameInfo[] = [];
|
|
|
|
|
|
|
|
private menuPopup: MenuPopup;
|
|
private menuPopup: MenuPopup;
|
|
|
|
|
+ private btnFirst: Node;
|
|
|
|
|
|
|
|
protected onCreate(): void | Promise<void> {
|
|
protected onCreate(): void | Promise<void> {
|
|
|
AppKernel.events.on('login:success', this.updateView, this);
|
|
AppKernel.events.on('login:success', this.updateView, this);
|
|
@@ -95,7 +94,7 @@ export class HomeView extends UIView {
|
|
|
addBtnClick(favsTab.node, this.onFavsTabClick, this);
|
|
addBtnClick(favsTab.node, this.onFavsTabClick, this);
|
|
|
|
|
|
|
|
const btnBuy = find("topNode/btnBuy", this.node);
|
|
const btnBuy = find("topNode/btnBuy", this.node);
|
|
|
- const btnFirst = find("topNode/btnFirst", this.node);
|
|
|
|
|
|
|
+ this.btnFirst = find("topNode/btnFirst", this.node);
|
|
|
const btnInvite = find("topNode/btnInvite", this.node);
|
|
const btnInvite = find("topNode/btnInvite", this.node);
|
|
|
const btnMail = find("topNode/btnMail", this.node);
|
|
const btnMail = find("topNode/btnMail", this.node);
|
|
|
const btnService = find("topNode/btnService", this.node);
|
|
const btnService = find("topNode/btnService", this.node);
|
|
@@ -111,7 +110,7 @@ export class HomeView extends UIView {
|
|
|
addBtnClick(this.scModel.node, this.onSCModelClick, this);
|
|
addBtnClick(this.scModel.node, this.onSCModelClick, this);
|
|
|
|
|
|
|
|
addBtnClick(btnBuy, this.onBtnBuyClick, this);
|
|
addBtnClick(btnBuy, this.onBtnBuyClick, this);
|
|
|
- addBtnClick(btnFirst, this.onBtnFirstClick, this);
|
|
|
|
|
|
|
+ addBtnClick(this.btnFirst, this.onBtnFirstClick, this);
|
|
|
addBtnClick(btnInvite, this.onBtnInviteClick, this);
|
|
addBtnClick(btnInvite, this.onBtnInviteClick, this);
|
|
|
addBtnClick(btnMail, this.onBtnMailClick, this);
|
|
addBtnClick(btnMail, this.onBtnMailClick, this);
|
|
|
addBtnClick(btnService, this.onBtnServiceClick, this);
|
|
addBtnClick(btnService, this.onBtnServiceClick, this);
|
|
@@ -128,8 +127,6 @@ export class HomeView extends UIView {
|
|
|
AppKernel.redpoint.on(RED_POINTS.Mail, mailPoint, this);
|
|
AppKernel.redpoint.on(RED_POINTS.Mail, mailPoint, this);
|
|
|
AppKernel.redpoint.on(RED_POINTS.DailyTask, taskPoint, this);
|
|
AppKernel.redpoint.on(RED_POINTS.DailyTask, taskPoint, this);
|
|
|
AppKernel.redpoint.on(RED_POINTS.DailyReward, dailyPoint, this);
|
|
AppKernel.redpoint.on(RED_POINTS.DailyReward, dailyPoint, this);
|
|
|
-
|
|
|
|
|
- this.coinModel = localStorageGet(LOCAL_CURRENCY_MODE, CURRENCY_TYPE.GC) as CurrencyType;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected onDestroy(): void {
|
|
protected onDestroy(): void {
|
|
@@ -137,8 +134,8 @@ export class HomeView extends UIView {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private updateGameModel(type: CurrencyType) {
|
|
private updateGameModel(type: CurrencyType) {
|
|
|
- this.coinModel = type;
|
|
|
|
|
- localStorageSet(LOCAL_CURRENCY_MODE, type);
|
|
|
|
|
|
|
+ const mainStore = AppKernel.stores.mainStore;
|
|
|
|
|
+ mainStore.currencyKind = type;
|
|
|
|
|
|
|
|
this.gcModel.setActive(type === CURRENCY_TYPE.GC);
|
|
this.gcModel.setActive(type === CURRENCY_TYPE.GC);
|
|
|
this.scModel.setActive(type === CURRENCY_TYPE.SC);
|
|
this.scModel.setActive(type === CURRENCY_TYPE.SC);
|
|
@@ -155,7 +152,7 @@ export class HomeView extends UIView {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private updateGameList() {
|
|
private updateGameList() {
|
|
|
- const currency = this.coinModel;
|
|
|
|
|
|
|
+ const currency = AppKernel.stores.mainStore.currencyKind;
|
|
|
const tag = GameTabValus[this.gameTabIndex];
|
|
const tag = GameTabValus[this.gameTabIndex];
|
|
|
const isHome = tag === GAME_TABS.Home;
|
|
const isHome = tag === GAME_TABS.Home;
|
|
|
const gameStore = AppKernel.stores.gameStore;
|
|
const gameStore = AppKernel.stores.gameStore;
|
|
@@ -219,7 +216,8 @@ export class HomeView extends UIView {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onBtnRedeemClick() {
|
|
private onBtnRedeemClick() {
|
|
|
- if (this.coinModel !== CURRENCY_TYPE.SC) {
|
|
|
|
|
|
|
+ const coinModel = AppKernel.stores.mainStore.currencyKind;
|
|
|
|
|
+ if (coinModel !== CURRENCY_TYPE.SC) {
|
|
|
AppKernel.ui.toast("Redeem is only available in SC mode.");
|
|
AppKernel.ui.toast("Redeem is only available in SC mode.");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -244,7 +242,7 @@ export class HomeView extends UIView {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onBtnInviteClick() {
|
|
private onBtnInviteClick() {
|
|
|
-
|
|
|
|
|
|
|
+ AppKernel.ui.open(UIViewID.UIInvite);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onBtnFirstClick() {
|
|
private onBtnFirstClick() {
|
|
@@ -260,11 +258,15 @@ export class HomeView extends UIView {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onGCModelClick() {
|
|
private onGCModelClick() {
|
|
|
|
|
+ const coinModel = AppKernel.stores.mainStore.currencyKind;
|
|
|
|
|
+ if (coinModel === CURRENCY_TYPE.GC) return;
|
|
|
this.updateGameModel(CURRENCY_TYPE.GC);
|
|
this.updateGameModel(CURRENCY_TYPE.GC);
|
|
|
this.updateGameList();
|
|
this.updateGameList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onSCModelClick() {
|
|
private onSCModelClick() {
|
|
|
|
|
+ const coinModel = AppKernel.stores.mainStore.currencyKind;
|
|
|
|
|
+ if (coinModel === CURRENCY_TYPE.SC) return;
|
|
|
this.updateGameModel(CURRENCY_TYPE.SC);
|
|
this.updateGameModel(CURRENCY_TYPE.SC);
|
|
|
this.updateGameList();
|
|
this.updateGameList();
|
|
|
}
|
|
}
|
|
@@ -276,26 +278,17 @@ export class HomeView extends UIView {
|
|
|
this.scModel.lblValue.string = formatSCNum(mainStore.scScore);
|
|
this.scModel.lblValue.string = formatSCNum(mainStore.scScore);
|
|
|
this.gcModel.lblValue.string = formatGCNum(mainStore.gcScore);
|
|
this.gcModel.lblValue.string = formatGCNum(mainStore.gcScore);
|
|
|
this.updateGameTabs(0);
|
|
this.updateGameTabs(0);
|
|
|
- this.updateGameModel(this.coinModel);
|
|
|
|
|
|
|
+ this.updateGameModel(mainStore.currencyKind);
|
|
|
this.updateGameList();
|
|
this.updateGameList();
|
|
|
this.bannerNode.init(5);
|
|
this.bannerNode.init(5);
|
|
|
|
|
|
|
|
- // // this.gameRoot.destroyAllChildren();
|
|
|
|
|
- // const gameStore = AppKernel.stores.gameStore;
|
|
|
|
|
- // const gameList = gameStore.getGameList();
|
|
|
|
|
- // // gameList.map(game => this.initGameItem(game));
|
|
|
|
|
-
|
|
|
|
|
- // LoopList.ins<IGameInfo>("HomeGameList").init(this.gameScroll, this.gameRender, 20);
|
|
|
|
|
- // LoopList.ins<IGameInfo>("HomeGameList").initData(gameList, this.gamePrefab, size(115, 140))
|
|
|
|
|
|
|
+ const payStore = AppKernel.stores.payStore;
|
|
|
|
|
+ this.btnFirst.active = payStore.firstPackVisible;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private onBtnMailClick() {
|
|
private onBtnMailClick() {
|
|
|
AppKernel.ui.open(UIViewID.MailView);
|
|
AppKernel.ui.open(UIViewID.MailView);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private onBtnStoreClick() {
|
|
|
|
|
- AppKernel.ui.open(UIViewID.StoreView);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class UserNode {
|
|
class UserNode {
|