web3coin适配

This commit is contained in:
2025-09-18 22:27:02 +08:00
parent 93b7b79c31
commit 85c8b51316
15 changed files with 700 additions and 59 deletions
@@ -12,7 +12,8 @@ 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 { NavigationManager } from "../../manager/NavigationManager";
import { NavigationManager, PanelType } from "../../manager/NavigationManager";
import { Web3PopPanel } from "./Web3PopPanel";
const { ccclass, property } = _decorator;
@@ -26,9 +27,15 @@ export class PurchasePanel extends li_BaseView {
private vipPrice30: Label;
private vipTime30: Label;
private currentPayType: proto.cs.EnmPayType =
proto.cs.EnmPayType.EPT_Cash_INR;
private defaultNetworkType: proto.cs.EnmNetworkType.ENT_TRON;
public web3PopPanel: Web3PopPanel;
@property([PurchasePanelItem])
public items: PurchasePanelItem[] = [];
getDefaultNetworkType(): proto.cs.EnmNetworkType {
return this.defaultNetworkType;
}
onLoadCT(): void {
Utils.parseNode(this.node, this._nodeTab);
this.coinNum = this._nodeTab.coinNum.getComponent(Label);
@@ -46,6 +53,9 @@ export class PurchasePanel extends li_BaseView {
Utils.addInnerEL(InnerMsgCode.VipExpireChange, this, () => {
this.onVipExpireChange();
});
Utils.addInnerEL(InnerMsgCode.PayOrderCreateSucc, this, () => {
this.createOrRefreshWeb3PayPanel;
});
for (let index = 0; index < this.items.length; index++) {
const element = this.items[index];
@@ -119,22 +129,48 @@ export class PurchasePanel extends li_BaseView {
const rechargeIds = this.shopData.getRechargeIds();
for (let index = 0; index < this.items.length; index++) {
const element = this.items[index];
element.refresh(rechargeIds[index]);
element.refresh(type, rechargeIds[index]);
}
if (type == 0) {
this.currentPayType = proto.cs.EnmPayType.EPT_Cash_INR;
} else {
this.currentPayType = proto.cs.EnmPayType.EPT_WEB3_USD;
}
}
setDiamondTag(id: number) {
purchaseGood(id: number, networkType: proto.cs.EnmNetworkType) {
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const isRechargeId = shopData.isRechargeId(id);
if (isRechargeId) {
// 需要外部支付进行购买
this.startPayment(id, proto.cs.EnmPayType.EPT_Cash_INR, proto.cs.EnmNetworkType.ENT_TRON);
} else {
//是u币充值,打开页面
NavigationManager.Instance.openSubPanel("Web3PopPanel", this.node);
this.startPayment(id, this.currentPayType, networkType);
}
}
createOrRefreshWeb3PayPanel(param: any) {
const data = {
orderId: param.orderId,
payType: param.payType,
goodId: param.goodId,
networkType: this.defaultNetworkType,
base: this,
};
if (
NavigationManager.Instance.getCurrentActivePanel() == PanelType.PERSONAL
)
if (this.web3PopPanel === null)
NavigationManager.Instance.openSubPanel(
"Web3PopPanel",
this.node,
data
);
else {
this.web3PopPanel.refreshData(data);
this.web3PopPanel.refreshView();
}
}
getPlayerMerData() {
//todo: 获取服务器玩家商业化数据
this.refreshCoinNum();
@@ -217,8 +253,15 @@ export class PurchasePanel extends li_BaseView {
}
onDestroy() {
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {});
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {});
Utils.removeInnerEL(InnerMsgCode.BalanceChange, this, () => {
this.onBalanceChange();
});
Utils.removeInnerEL(InnerMsgCode.VipExpireChange, this, () => {
this.onVipExpireChange();
});
Utils.addInnerEL(InnerMsgCode.PayOrderCreateSucc, this, () => {
this.createOrRefreshWeb3PayPanel;
});
super.onDestroy();
}
}