更新页面 商店、主题

This commit is contained in:
2025-09-18 14:06:53 +08:00
parent 015bc1c2f7
commit 246d83f7bc
134 changed files with 14949 additions and 4424 deletions
@@ -1,21 +1,18 @@
import { _decorator, Component, Label, Node } from "cc";
import li_BaseView from "../../../Main/Common/li_BaseView";
import Utils from "../../../Main/Common/Utils";
import { CommercialData } from "../../data/CommercialData";
import { ConfigManager } from "../../manager/ConfigManager";
import { GButton } from "../../../Main/Common/GButton";
import { PurchasePanelItem } from "../../uiitems/PurchasePanelItem";
import { ViewManager } from "../../../Main/Manager/ViewManager";
import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { InnerEventCode, InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
import { DataManager, DataId } from "../../data/DataManager";
import { WalletData } from "../../data/WalletData";
import { ShopData } from "../../data/ShopData";
import { GirlData } from "../../data/GirlData";
import { ShopService } from "db://assets/Scripts/chat18x/network/services/ShopService";
import { PaymentService } from "db://assets/Scripts/chat18x/payment/PaymentService";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
import GameRootUI from "../../../Main/Common/GameRootUI";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { NavigationManager } from "../../manager/NavigationManager";
const { ccclass, property } = _decorator;
@@ -45,11 +42,15 @@ export class PurchasePanel extends li_BaseView {
//订阅商业化数据事件
Utils.addInnerEL(InnerMsgCode.BalanceChange, this, () => {
this.onBalanceChange();
});
});
Utils.addInnerEL(InnerMsgCode.VipExpireChange, this, () => {
this.onVipExpireChange();
});
});
for (let index = 0; index < this.items.length; index++) {
const element = this.items[index];
element.init(this);
}
this.Show();
}
@@ -70,10 +71,10 @@ export class PurchasePanel extends li_BaseView {
// 购买30天会员
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const memberId = shopData.get30DayMemberId();
this.reqBuyGood(memberId);
this.reqBuyGood(memberId);
},
this
);
);
GButton.BandClick(
this._nodeTab.ReturnBtn,
() => {
@@ -86,9 +87,7 @@ export class PurchasePanel extends li_BaseView {
async Show() {
// 请求商城数据
const reqData = {
};
const reqData = {};
let res = await ShopService.I.reqShopList(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
// 保存数据
@@ -96,27 +95,32 @@ export class PurchasePanel extends li_BaseView {
shopData.goods = res.data;
// 根据数据,刷新界面
this.updateView();
this.updateShops();
}
}
shopData: ShopData;
updateView() {
this.getPlayerMerData();
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
this.shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
// VIP会员
const memberId7 = shopData.get7DayMemberId();
const price7 = shopData.getOriginalPriceById(memberId7);
const memberId7 = this.shopData.get7DayMemberId();
const price7 = this.shopData.getOriginalPriceById(memberId7);
this.vipPrice7.string = `$ ${price7}`;
const memberId30 = shopData.get30DayMemberId();
const price30 = shopData.getOriginalPriceById(memberId30);
const memberId30 = this.shopData.get30DayMemberId();
const price30 = this.shopData.getOriginalPriceById(memberId30);
this.vipPrice30.string = `$ ${price30}`;
// 充值商品
const rechargeIds = shopData.getRechargeIds();
}
// 0:cash 1:web3
updateShops(type: number = 0) {
// 充值商品 缺:分开获取现金充值或者web3币充值
const rechargeIds = this.shopData.getRechargeIds();
for (let index = 0; index < this.items.length; index++) {
const element = this.items[index];
element.init(this, rechargeIds[index]);
element.refresh(rechargeIds[index]);
}
this.items.forEach((item) => item.show());
}
setDiamondTag(id: number) {
@@ -125,6 +129,9 @@ export class PurchasePanel extends li_BaseView {
if (isRechargeId) {
// 需要外部支付进行购买
this.startPayment(id);
} else {
//是u币充值,打开页面
NavigationManager.Instance.openSubPanel("Web3PopPanel", this.node);
}
}
@@ -143,7 +150,7 @@ export class PurchasePanel extends li_BaseView {
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
const balance = walletData.getOriginalBalance();
this.coinNum.string = balance.toString();
}
}
onVipExpireChange() {
this.refreshVipExpire();
@@ -156,8 +163,8 @@ export class PurchasePanel extends li_BaseView {
const leftTime = Utils.formatVipLeftTime(vipExpire);
this.vipLeftTime.string = LanguageUtils.getText(
"purchasepanel.vip_left"
).replace("${leftTime}", leftTime);
}
).replace("${leftTime}", leftTime);
}
// 使用余额购买商品
async reqBuyGood(goodId: number) {
@@ -176,15 +183,14 @@ export class PurchasePanel extends li_BaseView {
walletData.balance = Number(resData.balance);
walletData.vipExpire = Number(resData.vipExpire);
// 刷新界面
}
}
}
// 创建订单
async startPayment(goodId: number) {
// 请求数据
const reqData = {
goodId
goodId,
};
let res = await PaymentService.I.startPayment(reqData);
console.log("支付完成的响应数据:", res);
@@ -196,18 +202,21 @@ export class PurchasePanel extends li_BaseView {
console.log("支付成功!!!");
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
walletData.balance = Number(res.balance);
walletData.vipExpire = Number(res.vipExpire);
walletData.vipExpire = Number(res.vipExpire);
}
}
}
}
onClickCashBtn() {
this.updateShops(0);
}
onClickWeb3Btn() {
this.updateShops(1);
}
onDestroy() {
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {
});
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {
});
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {});
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {});
super.onDestroy();
}
}
+10 -16
View File
@@ -43,7 +43,6 @@ export class ThemePanel extends li_BaseView {
private _nodeTab: any = {};
coinNum: Label;
uid: Label;
itemInst: ThemeItem;
content: Node;
private vipLeftTime: Label;
@@ -65,7 +64,6 @@ export class ThemePanel extends li_BaseView {
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.recPic.getComponent(Sprite);
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
@@ -113,7 +111,7 @@ export class ThemePanel extends li_BaseView {
const accountData = DataManager.I.getDataById<AccountData>(
DataId.Account
);
this.uid.string = "uid: " + accountData.accId;
//this.uid.string = "uid: " + accountData.accId;
this.recId = 1;
// 检查是否已被取消
@@ -253,19 +251,15 @@ export class ThemePanel extends li_BaseView {
this.recName.string = LanguageUtils.getText(this.rectNameKey);
// 加载远程资源
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
let newPath = envData.cdn + "/" + "Girls/" + avatarPath + ".png";
ResManager.I.changeRemoteSpriteFrame(
this.recSprite,
newPath,
() => {
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(
sizeTran.contentSize,
this.recSprite.node,
1
);
}
);
let newPath = envData.cdn + "/" + "Girls/" + avatarPath + ".png";
ResManager.I.changeRemoteSpriteFrame(this.recSprite, newPath, () => {
let sizeTran = this.recSprite.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(
sizeTran.contentSize,
this.recSprite.node,
1
);
});
}
/**
@@ -0,0 +1,89 @@
import { _decorator, Component, Label, Node, Sprite, Vec3 } from "cc";
import li_BaseView from "../../../Main/Common/li_BaseView";
import Utils from "../../../Main/Common/Utils";
import { GButton } from "../../../Main/Common/GButton";
const { ccclass, property } = _decorator;
@ccclass("Web3PopPanel")
export class Web3PopPanel extends li_BaseView {
private _nodeTab: any = {};
private coinIcon: Sprite;
private coinText: Label;
private selection: Node;
private curType: number;
onLoadCT(): void {
Utils.parseNode(this.node, this._nodeTab);
this.selection = this._nodeTab.Selection;
this.coinIcon = this._nodeTab.SelectedCoinIcon;
this.coinText = this._nodeTab._SelectedCoinText;
this.registerListener();
this.selection.setScale(new Vec3(1, 0, 1));
}
registerListener() {
GButton.BandClick(this._nodeTab.closeBtn, this.onClickClose, this);
GButton.BandClick(
this._nodeTab.CoinTypeSelectBtn,
this.onClickCoinTypeSelectBtn,
this
);
GButton.BandClick(this._nodeTab.CopyBtn, this.onClickCopy, this);
GButton.BandClick(
this._nodeTab.CoinType1,
() => {
this.onClickCoinType(1);
},
this
);
GButton.BandClick(
this._nodeTab.CoinType2,
() => {
this.onClickCoinType(2);
},
this
);
GButton.BandClick(
this._nodeTab.CoinType3,
() => {
this.onClickCoinType(3);
},
this
);
}
init() {
this.curType = 1;
}
refresh() {
//this.coinIcon
}
updateSelectNetwork() {}
onClickCoinTypeSelectBtn() {
this.selection.scale = new Vec3(1, 1, 1);
}
onClickCoinType(type: number) {
this.curType = type;
if (type == 1) {
} else if (type == 2) {
} else if (type == 3) {
} else {
}
this.selection.scale = new Vec3(1, 0, 1);
}
onClickCopy() {
//todo:copy 功能
}
onClickClose() {
this.close();
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "5a5ef9db-cc78-49c6-9dc9-4a6af5005ee6",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -1,9 +1,10 @@
import { _decorator, Component, Label, Node } from "cc";
import { _decorator, Component, Label, Node, Sprite } from "cc";
import { PurchasePanel } from "../ui/panels/PurchasePanel";
import { PurchaseConfig } from "../../schema/schema";
import { DataManager, DataId } from "../data/DataManager";
import { ShopData } from "../data/ShopData";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import ResManager from "../../Main/Manager/ResManager";
const { ccclass, property } = _decorator;
@@ -14,21 +15,40 @@ export class PurchasePanelItem extends Component {
@property(Label)
price: Label;
@property(Sprite)
icon: Sprite;
baseView: PurchasePanel;
goodId: number;
public init(base: PurchasePanel, goodId: number) {
public init(base: PurchasePanel) {
this.baseView = base;
this.goodId = goodId;
GButton.BandClick(this.node, this.onClickThis, this);
}
public refresh(goodId: number) {
this.goodId = goodId;
this.show();
}
public show() {
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const count = shopData.getCountById(this.goodId);
this.count.string = count.toString();
const price = shopData.getOriginalPriceById(this.goodId);
this.price.string = price.toString();
let path = "";
if (this.goodId > 2000) {
// web3币
path += "ui/shop/coin/";
} //cash
else {
path += "ui/shop/cash/";
}
path += this.goodId;
ResManager.I.changeResourceSpriteFrame(this.icon, path);
}
async onClickThis() {
+26 -9
View File
@@ -2,7 +2,10 @@ import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
import { NavigationManager, PageTransitionType } from "../manager/NavigationManager";
import {
NavigationManager,
PageTransitionType,
} from "../manager/NavigationManager";
import LanguageUtils from "../../Main/Common/LanguageUtils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { DataManager, DataId } from "../data/DataManager";
@@ -18,6 +21,8 @@ export class ThemeItem extends Component {
lockCover: Sprite;
@property(Label)
titleName: Label;
@property(UITransform)
titleNameBg: UITransform;
@property(Node)
loading: Node;
@@ -34,17 +39,28 @@ export class ThemeItem extends Component {
key: string;
protected onLoad(): void {
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
this.titleName.string = LanguageUtils.getText(this.key);
this.updateTitle();
});
}
protected onDestroy(): void {
Utils.removeInnerEL(InnerMsgCode.LanguageChange, this, () => {
this.titleName.string = LanguageUtils.getText(this.key);
this.updateTitle();
});
}
updateTitle() {
this.titleName.string = LanguageUtils.getText(this.key);
this.scheduleOnce(() => {
const size = this.titleName.getComponent(UITransform).contentSize;
this.titleNameBg.setContentSize(
size.x + 65,
this.titleNameBg.contentSize.y
);
}, 0);
}
refresh(themeId: number, parentPanel?: any) {
this.loading.active = true;
if (this.loading) this.loading.active = true;
this.parentPanel = parentPanel;
// 主题数据
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
@@ -52,9 +68,7 @@ export class ThemeItem extends Component {
!themeData.getIsReleaseById(themeId);
this.isLocked = !themeData.getIsReleaseById(themeId);
this.key = themeData.getLanKeyById(themeId);
this.titleName.string = LanguageUtils.getText(
themeData.getLanKeyById(themeId)
);
this.updateTitle();
this.category = themeData.getCategoryById(themeId);
ResManager.I.changeBundleSpriteFrame(
this.img,
@@ -63,7 +77,7 @@ 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;
if (this.loading) this.loading.active = false;
}
);
GButton.RemoveAndBandClick(this.node, this.OnClickThis, this);
@@ -74,7 +88,10 @@ export class ThemeItem extends Component {
return;
}
console.log("[ThemeItem] Opening GirlListPanel for category:", this.category);
console.log(
"[ThemeItem] Opening GirlListPanel for category:",
this.category
);
// 不使用过渡动画,直接打开
NavigationManager.Instance.navigateToGirlList(this.category);
}