diff --git a/app/pay/inweixin/[weixin]/page.jsx b/app/pay/inweixin/[weixin]/page.jsx index 0025f80..537bef7 100644 --- a/app/pay/inweixin/[weixin]/page.jsx +++ b/app/pay/inweixin/[weixin]/page.jsx @@ -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 }) {

正在跳转...

- - - +

{code}

); } diff --git a/app/pay/jsapi/[body]/page.jsx b/app/pay/jsapi/[body]/page.jsx new file mode 100644 index 0000000..8e7febe --- /dev/null +++ b/app/pay/jsapi/[body]/page.jsx @@ -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
JsApi
; +}