's'
This commit is contained in:
@@ -101,7 +101,7 @@ const config = {
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
allowedHosts: ["nomadro.com", "localhost", ".nomadro.com", "hackrobot.cn"],
|
||||
allowedHosts: ["nomadro.com", "localhost", ".nomadro.com", "hackrobot.cn",".ngrok-free.app"],
|
||||
},
|
||||
|
||||
htmlPluginOption: {
|
||||
|
||||
@@ -99,7 +99,7 @@ const Book = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const payh5 = (type, total_fee = 1000) => {
|
||||
const payh52222 = (type, total_fee = 1000) => {
|
||||
// console.log("111");
|
||||
Taro.request({
|
||||
method: "POST",
|
||||
@@ -142,6 +142,51 @@ const Book = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const payh5 = (type, total_fee = 1000) => {
|
||||
Taro.request({
|
||||
method: "POST",
|
||||
url: `${process.env.TARO_API_API}/payh5`,
|
||||
data: {
|
||||
total_fee: total_fee,
|
||||
type: type,
|
||||
// callback_url 临时不传
|
||||
},
|
||||
header: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data?.status === "ok" && res.data?.xorpay_params) {
|
||||
// 创建隐藏 form POST 到 XorPay
|
||||
const form = document.createElement("form");
|
||||
form.method = "POST";
|
||||
form.action = res.data.xorpay_url;
|
||||
form.style.display = "none";
|
||||
|
||||
for (const key in res.data.xorpay_params) {
|
||||
const input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = res.data.xorpay_params[key];
|
||||
form.appendChild(input);
|
||||
}
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: "支付发起失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
Taro.showToast({
|
||||
title: "网络错误",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<View className="book_header_div"></View>
|
||||
@@ -237,7 +282,7 @@ const Book = () => {
|
||||
} else {
|
||||
if (!!isWeChat) {
|
||||
//198元
|
||||
payh5("book", 19800);
|
||||
payh5("book", 10);
|
||||
} else {
|
||||
window.location.href = `https://mp.weixin.qq.com/s/16xcMIgxEEGBPY7fanNq0g`;
|
||||
}
|
||||
|
||||
@@ -136,10 +136,29 @@ const Index = () => {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
let nowUrl = window.location.href;
|
||||
// let nowUrl = window.location.href;
|
||||
// window.localStorage.removeItem("openid");
|
||||
// // let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
// let payUrl = `https://xorpay.com/api/openid/8220&callback_url=${nowUrl}`;
|
||||
// window.location.href = payUrl;
|
||||
|
||||
// 清除旧 openid(可选,建议保留)
|
||||
window.localStorage.removeItem("openid");
|
||||
let payUrl = `https://payjs.cn/api/openid?mchid=1561724891&callback_url=${nowUrl}`;
|
||||
window.location.href = payUrl;
|
||||
|
||||
// 当前完整 URL(包括 ? 参数和 # hash)
|
||||
let nowUrl = window.location.href;
|
||||
|
||||
// 正确构造 XorPay openid 获取地址
|
||||
// 1. 参数名必须是 callback
|
||||
// 2. 值必须 encodeURIComponent 编码
|
||||
let payUrl = `https://xorpay.com/api/openid/8220?callback=${encodeURIComponent(
|
||||
nowUrl
|
||||
)}`;
|
||||
|
||||
console.log("跳转获取 openid 的 URL:", payUrl);
|
||||
// 示例输出:https://xorpay.com/api/openid/8220?callback=http%3A%2F%2F192.168.31.222%3A10086%2F%23%2Fpay
|
||||
|
||||
// window.location.href = payUrl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user