Merge branch 'main_fix'
# Conflicts: # assets/Scripts/Sub/MainScene.ts
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,228 +0,0 @@
|
||||
import {
|
||||
_decorator,
|
||||
Component,
|
||||
Node,
|
||||
instantiate,
|
||||
Label,
|
||||
Sprite,
|
||||
UITransform,
|
||||
} from "cc";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import { ThemeItem } from "../../uiitems/ThemeItem";
|
||||
import { NavigationManager } from "../../manager/NavigationManager";
|
||||
import { GirlListItem } from "../../uiitems/GirlListItem";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
|
||||
import { ThemeService } from "db://assets/Scripts/chat18x/network/services/ThemeService";
|
||||
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
|
||||
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { ThemeData } from "../../data/ThemeData";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import { AccountData } from "../../data/AccountData";
|
||||
|
||||
import { ShopData } from "../../data/ShopData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("MainPanel")
|
||||
export class MainPanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
coinNum: Label;
|
||||
uid: Label;
|
||||
itemInst: GirlListItem;
|
||||
content: Node;
|
||||
private vipLeftTime: Label;
|
||||
recId: number;
|
||||
recName: Label;
|
||||
recSprite: Sprite;
|
||||
|
||||
cache: ThemeItem[] = [];
|
||||
|
||||
onLoadCT() {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
|
||||
this.uid = this._nodeTab.uid.getComponent(Label);
|
||||
this.recName = this._nodeTab.characterNameText.getComponent(Label);
|
||||
this.recSprite = this._nodeTab.recPicSlot.getComponent(Sprite);
|
||||
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
||||
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
||||
this.itemInst.node.active = false;
|
||||
this.content = this._nodeTab.allThemecontent;
|
||||
|
||||
this.Show();
|
||||
}
|
||||
|
||||
rectNameKey: string;
|
||||
async Show() {
|
||||
//some temp data
|
||||
this.refreshCoinNum();
|
||||
this.refreshVipExpire();
|
||||
const accountData = DataManager.I.getDataById<AccountData>(DataId.Account);
|
||||
this.uid.string = "uid: " + accountData.accId;
|
||||
this.recId = 1;
|
||||
if (this.cache) {
|
||||
for (let i = this.cache.length - 1; i >= 0; i--) {
|
||||
this.cache[i].node.destroy();
|
||||
}
|
||||
}
|
||||
this._nodeTab.loadingRec.active = true;
|
||||
// 请求主题数据
|
||||
const reqData = {};
|
||||
let res = await ThemeService.I.reqHallTheme(reqData);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
// 保存数据
|
||||
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
||||
themeData.themes = res.data;
|
||||
// 根据数据,刷新界面
|
||||
const themeIds = themeData.themeIds;
|
||||
for (let id of themeIds) {
|
||||
let newNode = instantiate(this.itemInst.node);
|
||||
let item = newNode.getComponent(ThemeItem);
|
||||
item.refresh(id);
|
||||
newNode.active = true;
|
||||
this.cache.push(item);
|
||||
this.content.addChild(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
// 请求每日推荐
|
||||
const reqData2 = {};
|
||||
let res2 = await GirlService.I.reqDailyRecommend(reqData2);
|
||||
if (res2 && res2.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
girlData.setDailyRecommend(res2.data);
|
||||
// 根据数据,刷新界面
|
||||
this.recId = girlData.getRecommendGirlId();
|
||||
this.rectNameKey = girlData.getRecommendGrilName();
|
||||
let avatarPath = girlData.getRecommendGrilAvatar();
|
||||
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.recSprite,
|
||||
avatarPath,
|
||||
"Girls",
|
||||
() => {
|
||||
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(
|
||||
sizeTran.contentSize,
|
||||
this.recSprite.node,
|
||||
1
|
||||
);
|
||||
this._nodeTab.loadingRec.active = false;
|
||||
},
|
||||
() => {
|
||||
this._nodeTab.loadingRec.active = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 获取商品列表,提前把数据拿下来
|
||||
this.reqShopList();
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
GButton.BandClick(this._nodeTab.settingBtn, this.openSetting, this);
|
||||
GButton.BandClick(this._nodeTab.msgBoxBtn, this.openMsgBox, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.ChatWithRecBtn, this.chatWithRec, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.ShopPanelEntry, this.enterShop, this);
|
||||
|
||||
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
||||
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
||||
});
|
||||
Utils.addInnerEL(InnerMsgCode.BalanceChange, this, () => {
|
||||
this.refreshCoinNum();
|
||||
});
|
||||
Utils.addInnerEL(InnerMsgCode.VipExpireChange, this, () => {
|
||||
this.refreshVipExpire();
|
||||
});
|
||||
}
|
||||
|
||||
enterShop() {
|
||||
ViewManager.I.openBundlesView("PurchasePanel");
|
||||
}
|
||||
|
||||
chatWithRec() {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
// 是否已经解锁
|
||||
const isRelease = girlData.getIsRelease(
|
||||
girlData.getGrilCategoryById(this.recId).toString(),
|
||||
this.recId
|
||||
);
|
||||
const isFree =
|
||||
girlData.getGrilPrice(
|
||||
girlData.getGrilCategoryById(this.recId).toString(),
|
||||
this.recId
|
||||
) == 0;
|
||||
if (isRelease || isFree) {
|
||||
NavigationManager.Instance.navigateToGirlDetail(this.recId);
|
||||
GameRootUI.I.hideDefaultView();
|
||||
} else {
|
||||
//未解锁
|
||||
ViewManager.I.openBundlesPopupView("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: girlData.getGrilCategoryById(this.recId),
|
||||
id: this.recId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
openSetting() {
|
||||
ViewManager.I.openBundlesView("SettingPanel");
|
||||
}
|
||||
|
||||
openMsgBox() {
|
||||
console.log("打开信箱");
|
||||
}
|
||||
|
||||
// 刷新余额
|
||||
private refreshCoinNum() {
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const balance = walletData.getOriginalBalance();
|
||||
this.coinNum.string = balance.toString();
|
||||
}
|
||||
|
||||
// 刷新 vip失效时间戳
|
||||
private refreshVipExpire() {
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const vipExpire = walletData.vipExpire;
|
||||
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
// 获取商品列表
|
||||
async reqShopList() {
|
||||
// 请求购买商品
|
||||
const reqData = {};
|
||||
let res = await ShopService.I.reqShopList(reqData);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
shopData.goods = res.data;
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(): void {
|
||||
Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
||||
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
||||
});
|
||||
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {});
|
||||
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {});
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "07c2bbbb-c191-4393-87d2-5c233eb8f756",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -77,7 +77,6 @@ export class ThemePanel extends li_BaseView {
|
||||
this.cache[i].node.destroy();
|
||||
}
|
||||
}
|
||||
this._nodeTab.loadingRec.active = true;
|
||||
// 请求主题数据
|
||||
const reqData = {};
|
||||
let res = await ThemeService.I.reqHallTheme(reqData);
|
||||
@@ -119,10 +118,6 @@ export class ThemePanel extends li_BaseView {
|
||||
this.recSprite.node,
|
||||
1
|
||||
);
|
||||
this._nodeTab.loadingRec.active = false;
|
||||
},
|
||||
() => {
|
||||
this._nodeTab.loadingRec.active = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,6 @@ export class DetailImageItem extends Component {
|
||||
@property(Label)
|
||||
videoPrice: Label;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
|
||||
base: GirlDetailPanel;
|
||||
url: string;
|
||||
isImage: boolean;
|
||||
@@ -149,8 +146,6 @@ export class DetailImageItem extends Component {
|
||||
|
||||
this.test_resID = this.node.getChildByName("resID");
|
||||
|
||||
this.loading.active = true;
|
||||
|
||||
this.test_resID.getComponent(Label).string =
|
||||
this.girlId.toString() + this.resId;
|
||||
|
||||
@@ -216,7 +211,6 @@ export class DetailImageItem extends Component {
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Girls", () => {
|
||||
this.question.active = false; // 图片加载成功后隐藏问号
|
||||
this.scaleToFillItem();
|
||||
this.loading.active = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,6 @@ export class GirlListItem extends Component {
|
||||
@property(Node)
|
||||
chatIcon: Node;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
|
||||
@property(Node)
|
||||
starParent: Node;
|
||||
|
||||
@@ -140,7 +137,7 @@ export class GirlListItem extends Component {
|
||||
this.category.toString(),
|
||||
this.id
|
||||
);
|
||||
this.loading.active = true;
|
||||
|
||||
//listAvatarPath = listAvatarPath.replace("Avatar", "avatar"); //临时
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.avatar,
|
||||
@@ -153,7 +150,6 @@ export class GirlListItem extends Component {
|
||||
this.avatar.node,
|
||||
2
|
||||
);
|
||||
this.loading.active = false;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ export class ThemeItem extends Component {
|
||||
@property(Label)
|
||||
titleName: Label;
|
||||
|
||||
@property(Node)
|
||||
loading: Node;
|
||||
|
||||
@property(Sprite)
|
||||
img: Sprite;
|
||||
|
||||
@@ -42,16 +39,13 @@ export class ThemeItem extends Component {
|
||||
}
|
||||
|
||||
refresh(themeId: number) {
|
||||
this.loading.active = true;
|
||||
// 主题数据
|
||||
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
||||
this.lockImg.node.active = this.lockCover.node.active =
|
||||
!themeData.getIsReleaseById(themeId);
|
||||
this.isLocked = !themeData.getIsReleaseById(themeId);
|
||||
this.key = themeData.getLanKeyById(themeId);
|
||||
this.titleName.string = LanguageUtils.getText(
|
||||
themeData.getLanKeyById(themeId)
|
||||
);
|
||||
this.titleName.string = LanguageUtils.getText(themeData.getLanKeyById(themeId));
|
||||
this.category = themeData.getCategoryById(themeId);
|
||||
ResManager.I.changeBundleSpriteFrame(
|
||||
this.img,
|
||||
@@ -60,7 +54,6 @@ export class ThemeItem extends Component {
|
||||
() => {
|
||||
let sizeTran = this.img.node.parent.getComponent(UITransform);
|
||||
Utils.adjustBgPixelRatioToSize(sizeTran.contentSize, this.img.node, 3);
|
||||
this.loading.active = false;
|
||||
}
|
||||
);
|
||||
GButton.RemoveAndBandClick(this.node, this.OnClickThis, this);
|
||||
|
||||
Reference in New Issue
Block a user