42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import { macro } from 'cc';
|
|
import { Account } from '../src/game/denglu/account';
|
|
import { MsgPayResult } from '../src/shared/protocols/msg_s2c/MsgPayResult';
|
|
|
|
export class Diff {
|
|
static orderNo: { orderNo: string; token: string; };
|
|
static diff() {
|
|
|
|
|
|
Account.getServerList = async () => {
|
|
return (await fly.get(`${macro.serverToolUrl}/client/getServerList`)).data;
|
|
};
|
|
|
|
Pay.sendPay = async (payId: string, args: { success?: (res?: MsgPayResult['data']) => void, fail?: (res?: MsgPayResult) => void; }, extData?: any) => {
|
|
|
|
G.event.off('paysuccess');
|
|
G.event.on('paysuccess', async (res: MsgPayResult) => {
|
|
if (res.code == 1) {
|
|
hongdian.getHdDataByKey([]);
|
|
Tip.show(lng.chongzhi_7);
|
|
args.success?.(res.data);
|
|
G.event.off('paysuccess');
|
|
G123Event.emit(G123EventType.g_payend, { order_no: this.orderNo.orderNo });
|
|
} else if (res.code == 200) {
|
|
fly.post(`${macro.serverToolUrl}/pay/getOrderNo`, G123.getPayPostArgs(payId, extData || {})).then(v => {
|
|
G123Event.emit(G123EventType.g_payrequest);
|
|
let orderNo = this.orderNo = v.data as { orderNo: string; token: string; };
|
|
CpSdk?.SendPayment({ ...orderNo });
|
|
});
|
|
} else {
|
|
Tip.show(lng.chongzhi_8);
|
|
args.fail?.(res);
|
|
}
|
|
}, this);
|
|
let payExtData = null;
|
|
if(extData) {
|
|
payExtData = {popup_id:extData.popup_id} || {}
|
|
}
|
|
Net.sendMsg('msg_c2s/Pay', { id: payId, args: payExtData });
|
|
};
|
|
}
|
|
} |