支付相关

This commit is contained in:
chen wei bo
2025-09-11 15:36:31 +08:00
parent 5accb0b507
commit a7e1724cc6
8 changed files with 118 additions and 34 deletions
@@ -32,12 +32,12 @@ export class PaymentService {
}
/** 发起支付:创建订单→打开URL→回到App后开始轮询 */
async startPayment(req: proto.cs.ICSCreateOrderReq, open: OpenStrategy = "system"): Promise<proto.cs.ICSQueryOrderRes | null> {
async startPayment(req: proto.cs.ICSCreateOrderReq, open: OpenStrategy = "system"): Promise<proto.cs.ICSQueryOrderRes> {
// 下单
const create = await PaymentApi.I.createOrder(req);
console.log("创建订单的响应数据:", create);
if (create.code !== proto.cs.EnmRetCode.SUCCESS || !create.data) {
return { status: -1, retCode: -1 };
return { status: -1, retCode: -1, balance: 0, vipExpire: 0};
}
const { orderId, payUrl } = create.data;
this.bus.emit(PaymentEvents.Started, { orderId });
@@ -108,6 +108,7 @@ export class PaymentService {
return new Promise<void>((resolve) => {
let finished = false;
const finish = () => {
console.log("应用回到 finish");
if (finished) return;
finished = true;
// 安全移除监听
@@ -117,6 +118,7 @@ export class PaymentService {
const onShow = () => {
// 应用回到前台
console.log("应用回到了前台");
finish();
};