From 897a60a7fb26ec90689e7784eef7f57855c244ac Mon Sep 17 00:00:00 2001 From: yezian Date: Tue, 20 Feb 2024 20:07:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pay/inweixin/[weixin]/page.jsx | 32 +++++++++--------------------- app/pay/jsapi/[body]/page.jsx | 17 ++++++++++++++++ 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 app/pay/jsapi/[body]/page.jsx 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
; +} -- 2.41.0