|
|
@@ -9,11 +9,9 @@
|
|
|
|
|
|
const userAgent = navigator.userAgent;
|
|
|
const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent);
|
|
|
-var orderInterval;
|
|
|
|
|
|
var pay =function (proId, amount, payWay, uuid) {
|
|
|
var customAmount = $("#custom-amount" + proId).val();
|
|
|
- console.log(customAmount);
|
|
|
if ($.trim(customAmount) != "") {
|
|
|
var reg = "^(([0-9]+\.[0-9]{1,2})|([0-9]*[1-9][0-9]*\.[0-9]{1,2})|([0-9]*[1-9][0-9]*))$";
|
|
|
var patt = new RegExp(reg);
|
|
|
@@ -22,11 +20,11 @@ var pay =function (proId, amount, payWay, uuid) {
|
|
|
if (parseFloat(customAmount) < 10000000) {
|
|
|
amount = customAmount;
|
|
|
} else {
|
|
|
- alert("您输入的金额过大,请不要超过一千万");
|
|
|
+ toastr.warning("您输入的金额过大,请不要超过一千万");
|
|
|
return;
|
|
|
}
|
|
|
} else {
|
|
|
- alert('输入金额有误,请正确输入金额且最多保留两位小数!');
|
|
|
+ toastr.warning('输入金额有误,请正确输入金额且最多保留两位小数!');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -36,6 +34,11 @@ var pay =function (proId, amount, payWay, uuid) {
|
|
|
amount = amount.toString().substring(0, yuanIndex);
|
|
|
}
|
|
|
|
|
|
+ if (parseFloat(amount) >= 10000000) {
|
|
|
+ toastr.warning("您输入的金额过大,请不要超过一千万");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
//获取支付方式
|
|
|
if(payWay == "支付宝") {
|
|
|
aliPay(proId, amount, payWay, uuid);
|
|
|
@@ -90,7 +93,7 @@ var wxPay = function (proId, amount, payWay, uuid) {
|
|
|
success : function(res){
|
|
|
var resJsonObj=JSON.parse(res);
|
|
|
if (resJsonObj.error != null) {
|
|
|
- alert(resJsonObj.error);
|
|
|
+ toastr.warning(resJsonObj.error);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -102,7 +105,7 @@ var wxPay = function (proId, amount, payWay, uuid) {
|
|
|
}
|
|
|
},
|
|
|
error : function() {
|
|
|
- alert('系统异常,请联系客服!');
|
|
|
+ toastr.error('系统异常,请联系客服!');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -129,7 +132,7 @@ var aliPay = function (proId, amount, payWay, uuid) {
|
|
|
document.write(data);
|
|
|
},
|
|
|
error : function() {
|
|
|
- alert('系统异常,请联系客服!');
|
|
|
+ toastr.error('系统异常,请联系客服!');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -140,48 +143,6 @@ var unionPay = function () {
|
|
|
|
|
|
/*公众号支付*/
|
|
|
var webPay = function (jsonStr) {
|
|
|
- // var xmlHttpRequest;
|
|
|
- //
|
|
|
- // $(function(){
|
|
|
- // if(window.XMLHttpRequest){
|
|
|
- // xmlHttpRequest=new XMLHttpRequest();
|
|
|
- // }else{
|
|
|
- // xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
|
|
|
- // }
|
|
|
- // //xmlHttpRequest.responseType = 'json';
|
|
|
- // //xmlHttpRequest.setRequestHeader('Content-type','application/x-www-form-urlencoded');
|
|
|
- // xmlHttpRequest.onreadystatechange = back;
|
|
|
- // xmlHttpRequest.open('POST','/wxpay/webPay',true);
|
|
|
- // xmlHttpRequest.send('jsonStr=' + jsonStr);
|
|
|
- // function back() {
|
|
|
- // if(xmlHttpRequest.status == 200 || xmlHttpRequest.readyState == 4){
|
|
|
- // alert(xmlHttpRequest.responseText);
|
|
|
- // var resJsonObj=JSON.parse(xmlHttpRequest.responseText);
|
|
|
- // if (resJsonObj.error != null) {
|
|
|
- // alert(resJsonObj.error);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- //
|
|
|
- // alert("0");
|
|
|
- //
|
|
|
- // if (typeof WeixinJSBridge == "undefined") {
|
|
|
- // alert("1");
|
|
|
- // if (document.addEventListener) {
|
|
|
- // document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
|
|
|
- // } else if (document.attachEvent) {
|
|
|
- // document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
|
|
|
- // document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // alert("2");
|
|
|
- // onBridgeReady(resJsonObj);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // });
|
|
|
-
|
|
|
-
|
|
|
$.ajax({
|
|
|
url : '/wxpay/webPay',
|
|
|
method : 'post',
|
|
|
@@ -193,12 +154,11 @@ var webPay = function (jsonStr) {
|
|
|
},
|
|
|
success : function(res) {
|
|
|
if (res.error != null) {
|
|
|
- alert(res.error);
|
|
|
+ toastr.info(res.error);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (typeof WeixinJSBridge == "undefined") {
|
|
|
- alert("2");
|
|
|
if (document.addEventListener) {
|
|
|
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
|
|
|
} else if (document.attachEvent) {
|
|
|
@@ -210,7 +170,7 @@ var webPay = function (jsonStr) {
|
|
|
}
|
|
|
},
|
|
|
error : function() {
|
|
|
- alert('系统异常,请联系客服!');
|
|
|
+ toastr.error('系统异常,请联系客服!');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -262,16 +222,15 @@ function onBridgeReady(resJsonObj){
|
|
|
function (res) {
|
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回 ok,但并不保证它绝对可靠。
|
|
|
if (res.err_msg == 'get_brand_wcpay_request:ok') {
|
|
|
- alert("支付成功");
|
|
|
+ toastr.success("支付成功!");
|
|
|
//window.location.href = "${returnUrl}";
|
|
|
}else if(res.err_msg == 'get_brand_wcpay_request:cancel'){
|
|
|
- alert("取消支付");
|
|
|
+ toastr.info("取消支付!");
|
|
|
}else{
|
|
|
- alert("支付失败");
|
|
|
+ toastr.error("支付失败!");
|
|
|
} // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回 ok,但并不保证它绝对可靠。
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-
|