feat: 接入payjs支付
This commit is contained in:
@@ -27,6 +27,8 @@ const Detail = () => {
|
||||
if (newId) {
|
||||
setid(newId);
|
||||
}
|
||||
let newjoinMeetup=window.localStorage.getItem('joinMeetup')
|
||||
setjoinMeetup(newjoinMeetup)
|
||||
}, []);
|
||||
|
||||
const handleClick = (value) => {
|
||||
@@ -67,17 +69,19 @@ const Detail = () => {
|
||||
}, []);
|
||||
|
||||
const joinmeet = () => {
|
||||
console.log("111");
|
||||
// console.log("111");
|
||||
Taro.request({
|
||||
method:'POST',
|
||||
url: "/api//payh5", //仅为示例,并非真实的接口地址
|
||||
data: {},
|
||||
url: "/api/payh5", //仅为示例,并非真实的接口地址
|
||||
data: {
|
||||
callback_url:window.location.href
|
||||
},
|
||||
header: {
|
||||
"content-type": "application/json", // 默认值
|
||||
},
|
||||
success: function (res) {
|
||||
console.log(res.data);
|
||||
window.alert(res.data);
|
||||
// window.alert(res.data.jsapi);
|
||||
WeixinJSBridge.invoke(
|
||||
"getBrandWCPayRequest",
|
||||
{
|
||||
@@ -88,10 +92,12 @@ const Detail = () => {
|
||||
// package: "prepay_id=wx01113404850024729b35f4d69b73500000",
|
||||
// signType: "MD5",
|
||||
// paySign: "2A823C8D47CCF871C6C65A56DC228CF8",
|
||||
...res.data,
|
||||
...res?.data?.jsapi??{},
|
||||
},
|
||||
function (res) {
|
||||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||
setjoinMeetup(true)
|
||||
window.localStorage.setItem('joinMeetup',true)
|
||||
WeixinJSBridge.call("closeWindow");
|
||||
}
|
||||
}
|
||||
@@ -144,8 +150,9 @@ const Detail = () => {
|
||||
className="bottomBtn"
|
||||
type="primary"
|
||||
onClick={() => joinmeet()}
|
||||
disabled={joinMeetup}
|
||||
>
|
||||
立即报名
|
||||
{!!joinMeetup?'已报名':'立即报名'}
|
||||
</AtButton>
|
||||
</View>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user