微信支付测试
This commit is contained in:
parent
8ceb34ce5d
commit
897a60a7fb
|
@ -1,13 +1,16 @@
|
|||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
|
||||
export default function SafePay({ params }) {
|
||||
export default function InWeixin({ params }) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const [code, setCode] = useState("no code");
|
||||
useEffect(() => {
|
||||
const weixinUrl = decodeURIComponent(params.weixin);
|
||||
router.replace(weixinUrl);
|
||||
const temcode = searchParams.get("code");
|
||||
setCode(temcode);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
@ -27,24 +30,7 @@ export default function SafePay({ params }) {
|
|||
</svg>
|
||||
<p className="text-sm text-[#5fc157]">正在跳转...</p>
|
||||
</div>
|
||||
<button
|
||||
className="bg-red-100 p-2"
|
||||
onClick={() => router.push(decodeURIComponent(params.weixin))}
|
||||
>
|
||||
push
|
||||
</button>
|
||||
<button
|
||||
className="bg-red-200 p-2"
|
||||
onClick={() => router.replace(decodeURIComponent(params.weixin))}
|
||||
>
|
||||
replace
|
||||
</button>
|
||||
<button
|
||||
className="bg-red-300 p-2"
|
||||
onClick={() => window.open(decodeURIComponent(params.weixin))}
|
||||
>
|
||||
window
|
||||
</button>
|
||||
<p className="text-base text-black">{code}</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function JsApi({ params }) {
|
||||
const router = useRouter();
|
||||
useEffect(() => {
|
||||
const redirect_uri = `https://tiefen.fun/pay/inweixin/${encodeURIComponent(
|
||||
params.body
|
||||
)}`;
|
||||
router.replace(
|
||||
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc28fd8aaf31984b6&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
|
||||
);
|
||||
}, []);
|
||||
return <section>JsApi</section>;
|
||||
}
|
Loading…
Reference in New Issue