更新页面 商店、主题
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user