diff --git a/app/pay/[weixin]/page.jsx b/app/pay/[weixin]/page.jsx
index d677db9..0ad3e9c 100644
--- a/app/pay/[weixin]/page.jsx
+++ b/app/pay/[weixin]/page.jsx
@@ -15,7 +15,7 @@ export default function Weixin({ params }) {
useEffect(() => {
var QRCode = require("qrcode");
QRCode.toDataURL(
- `https://tiefen.fun/pay/inweixin/${params.weixin}`,
+ `https://tiefen.fun/pay/jsapi/${params.weixin}`,
function (err, url) {
setQrcodeUrl(url);
}
diff --git a/app/pay/inweixin/[body]/page.jsx b/app/pay/inweixin/[body]/page.jsx
new file mode 100644
index 0000000..b649ca2
--- /dev/null
+++ b/app/pay/inweixin/[body]/page.jsx
@@ -0,0 +1,77 @@
+"use client";
+
+import React, { useState, useEffect } from "react";
+import { useRouter, useSearchParams } from "next/navigation";
+
+export default function InWeixin({ params }) {
+ const router = useRouter();
+ const searchParams = useSearchParams();
+
+ const [code, setCode] = useState("no code");
+ const [body, setBody] = useState({});
+ const [info, setInfo] = useState("no data");
+ useEffect(() => {
+ // //获取code
+ // const temCode = searchParams.get("code");
+ // setCode(temCode);
+
+ // //获取支付body
+ // const strBody = decodeURIComponent(params.body);
+ // const temBody = JSON.parse(strBody);
+ // setBody(temBody);
+
+ function onBridgeReady() {
+ WeixinJSBridge.invoke(
+ "getBrandWCPayRequest",
+ {
+ appId: "wxc28fd8aaf31984b6", //公众号ID,由商户传入
+ timeStamp: "1708438397", //时间戳,自1970年以来的秒数
+ nonceStr: "jXEwa7uEExqFjjlByZivG623Akbzg3Cv", //随机串
+ package: "prepay_id=wx2022131953635431d27a15e2c95e460000",
+ signType: "RSA", //微信签名方式:
+ paySign:
+ "0rODbhGbNidvOcdyC3+JW5pP6DEd+DZZs0Zg3oMvbQ1pC857YvISgrS8QM2yEZpJFWCnjmUmjyQijp3ZxfV5kqr4x8+l+cmNlc87sDtkXhn/pUNMSKtdt+X9KmOrykBjsLj7hztaPoFSwkGYpxHUrxwiooW+y3to5QqD550CaER7XhAAK5knItPy6pa8rGtYPpEpCn8OkcHHVkuGAcawej1a6MGw2byEv2eRusr1VbUVWENgu557qBdGA2NHoOHfRL3n/goOvt1KXTYRtb+BkwsssHJQb8gyuz0qBR/aNFcSUBb4eSBenWAm1L+Wp/ndxLMkxr1ixQblwEJ9I2NPZw==", //微信签名
+ },
+ function (res) {
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
+ // 使用以上方式判断前端返回,微信团队郑重提示:
+ //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+ setInfo("success");
+ }
+ }
+ );
+ }
+ if (typeof WeixinJSBridge == "undefined") {
+ if (document.addEventListener) {
+ document.addEventListener("WeixinJSBridgeReady", onBridgeReady, false);
+ } else if (document.attachEvent) {
+ document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
+ document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
+ }
+ } else {
+ onBridgeReady();
+ }
+ }, []);
+
+ return (
+
+ );
+}
diff --git a/app/pay/inweixin/[weixin]/page.jsx b/app/pay/inweixin/[weixin]/page.jsx
deleted file mode 100644
index 537bef7..0000000
--- a/app/pay/inweixin/[weixin]/page.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-"use client";
-
-import React, { useState, useEffect } from "react";
-import { useRouter, useSearchParams } from "next/navigation";
-
-export default function InWeixin({ params }) {
- const router = useRouter();
- const searchParams = useSearchParams();
-
- const [code, setCode] = useState("no code");
- useEffect(() => {
- const temcode = searchParams.get("code");
- setCode(temcode);
- }, []);
-
- return (
-
- );
-}
diff --git a/app/pay/jsapi/[body]/page.jsx b/app/pay/jsapi/[body]/page.jsx
index 8e7febe..a5ca633 100644
--- a/app/pay/jsapi/[body]/page.jsx
+++ b/app/pay/jsapi/[body]/page.jsx
@@ -6,12 +6,10 @@ 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
- )}`;
+ const redirect_uri = `https://tiefen.fun/pay/inweixin/${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 ;
+ return ;
}