You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
5.0 KiB
144 lines
5.0 KiB
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>微信支付</title>
|
|
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
|
|
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
|
<style>
|
|
</style>
|
|
<script type="text/javascript">
|
|
function onBridgeReady() {
|
|
|
|
}
|
|
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();
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
let url = window.location.href.split('?')[0];
|
|
let payId = orderId.split('-')[8];
|
|
let reqUrl = "https://huoliqiang-xcx-websocket.yingxiong.com/pay/MiniJSAPICall";
|
|
if(payId == 8){
|
|
reqUrl = "https://anhei-xcx-websocket.zealshow.com/pay/MiniJSAPICall";
|
|
}else if(payId == 9){
|
|
reqUrl = "https://anhei-xcx-websocket.zealshow.com/pay230/MiniJSAPICall";
|
|
}
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: reqUrl+"?orderId="+orderId+"&uid="+uid+"&url="+url,
|
|
dataType: 'jsonp', // 指定为jsonp类型
|
|
jsonpCallback: 'callbackFunction', // 服务器端用于包装响应的函数名
|
|
success: function(data) {
|
|
console.log("success"+data); // 处理响应数据
|
|
//alert(data);
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
//alert("fail");
|
|
console.log('JSONP request failed: ' + textStatus);
|
|
wx.closeWindow();
|
|
}
|
|
});
|
|
|
|
});
|
|
function callbackFunction(arr) {
|
|
// 处理data
|
|
if(arr[0] == -1) {
|
|
alert(arr[1]);
|
|
wx.closeWindow();
|
|
return;
|
|
}
|
|
this.appId = arr[1];
|
|
this.timestamp = arr[2];
|
|
this.nonceStr = arr[3];
|
|
this.package = arr[4];
|
|
this.paySign = arr[6];
|
|
this.signature = arr[7];
|
|
|
|
console.log(this.appId);
|
|
console.log(this.timestamp);
|
|
console.log(this.nonceStr);
|
|
console.log(this.package);
|
|
console.log(this.paySign);
|
|
console.log(this.signature);
|
|
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
|
"appId": appId , //公众号ID,由商户传入
|
|
"timeStamp": timestamp, //时间戳,自1970年以来的秒数
|
|
"nonceStr": nonceStr, //随机串
|
|
"package": package,
|
|
"signType": "RSA", //微信签名方式:
|
|
"paySign": paySign //微信签名
|
|
},
|
|
function(res) {
|
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
alert("支付成功");
|
|
}
|
|
wx.closeWindow();
|
|
});
|
|
|
|
}
|
|
function getUrlParams(url, paramName) {
|
|
const queryString = url.split('?')[1];
|
|
|
|
if (!queryString) {
|
|
return {};
|
|
}
|
|
|
|
const queryParams = {};
|
|
queryString.split('&').forEach(param => {
|
|
let s = param.split('=');
|
|
let key = s[0];
|
|
let value = s[1];
|
|
if (queryParams[key]) {
|
|
if (Array.isArray(queryParams[key])) {
|
|
queryParams[key].push(decodeURIComponent(value));
|
|
} else {
|
|
queryParams[key] = [queryParams[key], decodeURIComponent(value)];
|
|
}
|
|
} else {
|
|
queryParams[key] = decodeURIComponent(value);
|
|
}
|
|
});
|
|
|
|
if (!paramName) {
|
|
return queryParams;
|
|
}
|
|
|
|
if (queryParams[paramName]) {
|
|
return queryParams[paramName];
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
|
|
let p = getUrlParams(window.location.href)
|
|
console.log(p);
|
|
const uid = p.uid;
|
|
const orderId = p.orderId;
|
|
var appId = "";
|
|
var nonceStr = "";
|
|
var package = "";
|
|
var paySign = "";
|
|
var timestamp = "";
|
|
var signature = "";
|
|
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|