From fa1d8cddecb7a2028ed4fd8d12200b29a4e8b8a8 Mon Sep 17 00:00:00 2001 From: hackrobot Date: Tue, 10 Sep 2024 13:04:42 +0800 Subject: [PATCH] update --- src/pages/index/index.jsx | 106 +++++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 24 deletions(-) diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index 2b54055..2048618 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -34,6 +34,7 @@ import qrcode from "../../images/qrcode.png"; import meetup from "../../images/meetup.jpg"; import bookqr from "../../images/bookqr.jpg"; +import loft from "../../images/loft.png"; // export default class Index extends Component { const Index = () => { @@ -52,6 +53,7 @@ const Index = () => { const [meetupToast, setmeetupToast] = useState(false); const [joinMeetup, setjoinMeetup] = useState(false); + const [bookpay, setbookpay] = useState(0); const [isWeChat, setisWeChat] = useState(false); @@ -255,6 +257,11 @@ const Index = () => { } }, []); + useEffect(() => { + // alert(window.localStorage.getItem("bookpay")) + setbookpay(window.localStorage.getItem("bookpay")); + }, []); + const goBack = () => { Taro.navigateBack({}); }; @@ -263,6 +270,50 @@ const Index = () => { // window.alert(value) setopen(value); }; + + const payh5 = (type, total_fee = 1000) => { + // console.log("111"); + Taro.request({ + method: "POST", + url: "/api/payh5", //仅为示例,并非真实的接口地址 + // url: "https://pay.hackrobot.cn/api/payh5", //仅为示例,并非真实的接口地址 + + data: { + callback_url: window.location.href, + openid: window.localStorage.getItem("openid"), + total_fee: total_fee, // 金额,单位:分 + type: type, //订单类型 book/meetup/video/vip + }, + header: { + "content-type": "application/json", // 默认值 + }, + success: function (res) { + console.log(res.data); + // window.alert(res.data.jsapi); + WeixinJSBridge.invoke( + "getBrandWCPayRequest", + { + // 以下6个支付参数通过payjs的jsapi接口获取 + // appId: "wxc5205a653b0259bf", + // timeStamp: "1701401644", + // nonceStr: "KhOYB0wFV6j9qyQK", + // package: "prepay_id=wx01113404850024729b35f4d69b73500000", + // signType: "MD5", + // paySign: "2A823C8D47CCF871C6C65A56DC228CF8", + ...(res?.data?.jsapi ?? {}), + }, + function (res) { + // 支付成功 + if (res.err_msg == "get_brand_wcpay_request:ok") { + window.localStorage.setItem(type, 1); //订单类型 book/meetup/video/vip + WeixinJSBridge.call("closeWindow"); + } + } + ); + }, + }); + }; + return ( {/*