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();
}
}
+102 -16
View File
@@ -2,26 +2,52 @@ 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";
import { DataId, DataManager } from "../../data/DataManager";
import { OrderData } from "../../data/OrderData";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import ResManager from "../../../Main/Manager/ResManager";
import { PurchasePanel } from "./PurchasePanel";
const { ccclass, property } = _decorator;
@ccclass("Web3PopPanel")
export class Web3PopPanel extends li_BaseView {
private _nodeTab: any = {};
private amount: Label;
private coinIcon: Sprite;
private coinText: Label;
private address: Label;
private expireTimeText: Label;
private selection: Node;
private curType: number;
private curType: proto.cs.EnmNetworkType;
private orderId;
private payType;
private networkType: proto.cs.EnmNetworkType;
private goodId: number;
private base: PurchasePanel;
openUIDataCT(data: any): void {
this.refreshData(data);
this.base.web3PopPanel = this;
}
onLoadCT(): void {
Utils.parseNode(this.node, this._nodeTab);
this.amount = this._nodeTab.chargeAmount.getComponent(Label);
this.selection = this._nodeTab.Selection;
this.coinIcon = this._nodeTab.SelectedCoinIcon;
this.coinText = this._nodeTab._SelectedCoinText;
this.coinIcon = this._nodeTab.SelectedCoinIcon.getComponent(Sprite);
this.coinText = this._nodeTab.SelectedCoinText.getComponent(Label);
this.address = this._nodeTab.addressText.getComponent(Label);
this.expireTimeText = this._nodeTab.expireTimeText.getComponent(Label);
this.registerListener();
this.selection.setScale(new Vec3(1, 0, 1));
this.refreshView();
}
registerListener() {
GButton.BandClick(this._nodeTab.closeBtn, this.onClickClose, this);
@@ -33,23 +59,30 @@ export class Web3PopPanel extends li_BaseView {
GButton.BandClick(this._nodeTab.CopyBtn, this.onClickCopy, this);
GButton.BandClick(
this._nodeTab.CoinType1,
this._nodeTab.ENT_TRON,
() => {
this.onClickCoinType(1);
this.onClickCoinType(proto.cs.EnmNetworkType.ENT_TRON);
},
this
);
GButton.BandClick(
this._nodeTab.CoinType2,
this._nodeTab.ENT_TON,
() => {
this.onClickCoinType(2);
this.onClickCoinType(proto.cs.EnmNetworkType.ENT_TON);
},
this
);
GButton.BandClick(
this._nodeTab.CoinType3,
this._nodeTab.ENT_BEP,
() => {
this.onClickCoinType(3);
this.onClickCoinType(proto.cs.EnmNetworkType.ENT_BEP);
},
this
);
GButton.BandClick(
this._nodeTab.ENT_ETH,
() => {
this.onClickCoinType(proto.cs.EnmNetworkType.ENT_ETH);
},
this
);
@@ -58,8 +91,54 @@ export class Web3PopPanel extends li_BaseView {
init() {
this.curType = 1;
}
refresh() {
//this.coinIcon
refreshData(data: any): void {
this.orderId = data.orderId;
this.payType = data.payType;
this.goodId = data.goodId;
this.networkType = data.networkType;
this.base = data.base;
}
refreshView() {
const OrderData = DataManager.I.getDataById<OrderData>(DataId.Order);
const amount = OrderData.getAmountById(this.orderId);
const walletUrl = OrderData.getWalletById(this.orderId);
const expireTime = OrderData.getExpireById(this.orderId);
const retCode = OrderData.getRetCodeById(this.orderId);
this.amount.string = amount;
this.address.string = walletUrl;
switch (this.networkType) {
case proto.cs.EnmNetworkType.ENT_TRON:
ResManager.I.changeResourceSpriteFrame(
this.coinIcon,
"ui/web3pop/coinIcon/ENT_TRON"
);
this.coinText.string = "ENT_TRON";
break;
case proto.cs.EnmNetworkType.ENT_TON:
ResManager.I.changeResourceSpriteFrame(
this.coinIcon,
"ui/web3pop/coinIcon/ENT_TON"
);
this.coinText.string = "ENT_TON";
break;
case proto.cs.EnmNetworkType.ENT_ETH:
ResManager.I.changeResourceSpriteFrame(
this.coinIcon,
"ui/web3pop/coinIcon/ENT_ETH"
);
this.coinText.string = "ENT_ETH";
break;
case proto.cs.EnmNetworkType.ENT_BEP:
ResManager.I.changeResourceSpriteFrame(
this.coinIcon,
"ui/web3pop/coinIcon/ENT_BEP"
);
this.coinText.string = "ENT_BEP";
break;
}
}
updateSelectNetwork() {}
@@ -68,14 +147,21 @@ export class Web3PopPanel extends li_BaseView {
this.selection.scale = new Vec3(1, 1, 1);
}
onClickCoinType(type: number) {
onClickCoinType(type: proto.cs.EnmNetworkType) {
this.curType = type;
if (type == 1) {
} else if (type == 2) {
} else if (type == 3) {
} else {
switch (type) {
case proto.cs.EnmNetworkType.ENT_TRON:
break;
case proto.cs.EnmNetworkType.ENT_TON:
break;
case proto.cs.EnmNetworkType.ENT_ETH:
break;
case proto.cs.EnmNetworkType.ENT_BEP:
break;
}
this.base.startPayment(this.goodId, proto.cs.EnmPayType.EPT_WEB3_USD, type);
this.selection.scale = new Vec3(1, 0, 1);
}