This commit is contained in:
eric
2026-03-16 11:45:38 -05:00
parent 3e73917ad1
commit c5e057f0ed
9 changed files with 482 additions and 72 deletions

View File

@@ -5,6 +5,8 @@ import { createPortal } from "react-dom";
import {
getPayEnv,
redirectToPay,
redirectToPayH5,
payWechatXorpaySync,
getDeviceFromEnv,
} from "@/app/lib/payment";
import type { PayChannel } from "@/app/lib/payment";
@@ -70,15 +72,20 @@ export default function JoinModal({ isOpen, onClose, initialEmail = "", vipOnly
return;
}
const returnUrl = typeof window !== "undefined" ? `${window.location.origin}/join/paid` : "/join/paid";
const env = getPayEnv();
const channel: PayChannel = "wxpay";
redirectToPay({
const device = getDeviceFromEnv(getPayEnv());
const base = {
user_id: data.user_id,
return_url: returnUrl,
channel,
device: getDeviceFromEnv(env),
channel: "wxpay" as PayChannel,
useJoinConfig: true,
});
};
if (device === "wechat") {
payWechatXorpaySync(base);
} else if (device === "h5") {
await redirectToPayH5(base);
} else {
redirectToPay({ ...base, device });
}
} catch (err) {
setError(err instanceof Error ? err.message : "操作失败");
} finally {