@ -0,0 +1,47 @@
|
||||
.commit-button{
|
||||
width: 100%;
|
||||
border-radius: 25px;
|
||||
background-color: #ED2424;
|
||||
color: #FFFFFF;
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
border: 0px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
label{
|
||||
color: #9B9B9B;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.bill-info-right{
|
||||
float: right;
|
||||
}
|
||||
|
||||
.margin-body{
|
||||
margin: 15px
|
||||
}
|
||||
|
||||
.row-line-height{
|
||||
height: 20px;
|
||||
margin: 15px 0px 15px -15px;
|
||||
}
|
||||
|
||||
.row-line-height-plus{
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
}
|
||||
|
||||
.border-top-line{
|
||||
border-top: 1px solid #EEEEEE
|
||||
}
|
||||
|
||||
.border-button-line{
|
||||
border-bottom: 1px solid #EEEEEE;
|
||||
|
||||
}
|
||||
|
||||
#timer{
|
||||
font-weight: 600;
|
||||
color: #ED2424;
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
body{
|
||||
padding: 3% 10%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.head{
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #DCDCDC;
|
||||
}
|
||||
|
||||
.pc-cash{
|
||||
font-size: 28px;
|
||||
position: absolute;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
.order-box{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.count-down{
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
margin: 20px;
|
||||
line-height: 97px;
|
||||
background-color: #FEF4F4;
|
||||
}
|
||||
|
||||
label{
|
||||
color: #ED2424;
|
||||
font-size: 20px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.bill-info-right{
|
||||
float: right;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.margin-body{
|
||||
margin: 15px
|
||||
}
|
||||
|
||||
.row-line-height{
|
||||
height: 20px;
|
||||
margin: 15px 0px 15px -15px;
|
||||
}
|
||||
|
||||
.row-line-height-plus{
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
}
|
||||
|
||||
.border-top-line{
|
||||
border-top: 1px solid #EEEEEE
|
||||
}
|
||||
|
||||
.border-button-line{
|
||||
border-bottom: 1px solid #EEEEEE;
|
||||
padding: 20px 5px;
|
||||
}
|
||||
|
||||
#timer{
|
||||
font-weight: 600;
|
||||
color: #ED2424;
|
||||
}
|
||||
|
||||
.info-body{
|
||||
background-color: #FEF4F4;
|
||||
height: 650px;
|
||||
margin-top: 20px;
|
||||
border-radius: 10px 10px 0px 0px;
|
||||
}
|
||||
.info-body-title{
|
||||
background: #ED2424;
|
||||
line-height: 50px;
|
||||
font-size: 25px;
|
||||
color: #FFF;
|
||||
border-radius: 10px 10px 0px 0px;
|
||||
}
|
||||
|
||||
.pay-fun{
|
||||
font-family: PingFang-SC-Bold;
|
||||
font-size: 20px;
|
||||
color: #ED2424;
|
||||
font-weight: 600;
|
||||
margin: 50px;
|
||||
}
|
||||
|
||||
#commit-btn{
|
||||
width: 30%;
|
||||
border-radius: 5px;
|
||||
background-color: #ED2424;
|
||||
color: #FFFFFF;
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
border: 0px;
|
||||
margin: 100px 0px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.select-pay-fun{
|
||||
text-align: center;
|
||||
width: 80%;
|
||||
height: 120% ;
|
||||
border: 1px solid #ED2424;
|
||||
padding: 10px 0px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.no-select-pay-fun{
|
||||
text-align: center;
|
||||
width: 80%;
|
||||
height: 120% ;
|
||||
border: 1px solid #EAEAEA;
|
||||
padding: 10px 0px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
}
|
||||
|
||||
#qrImg{
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.img-size{
|
||||
height: 58px;
|
||||
}
|
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1,252 @@
|
||||
/**
|
||||
* Created by dulingling on 2020-03-25.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
var paymentFun = '';
|
||||
var selectPaymentHTML = " <img src='/static/templates/billCode/img/bill_select.png'>";
|
||||
var maxtime = window.maxtime;
|
||||
var hasPayment =true;//可支付
|
||||
|
||||
if(window.openmobilefun == 'wechat'|| window.openmobilefun == 'other'){
|
||||
paymentFun = 'Wechat'
|
||||
}else{
|
||||
paymentFun = 'Alipay'
|
||||
$(".select_wechat").empty();
|
||||
$(".select_alipay").append(selectPaymentHTML);
|
||||
$(".select_bank").empty();
|
||||
}
|
||||
|
||||
setInterval(function(){
|
||||
if(maxtime>0){
|
||||
var countdown=document.getElementById("timer");
|
||||
maxtime=maxtime-1;
|
||||
var minute=parseInt(maxtime/60);
|
||||
var second=parseInt(maxtime%60);
|
||||
countdown.innerHTML=minute+'分'+second+'秒';
|
||||
}else{
|
||||
$('#commit-btn').css({"background-color":"#eee",});
|
||||
hasPayment = false;
|
||||
}
|
||||
},1000);
|
||||
|
||||
|
||||
$("#select_wechat").click(function(){
|
||||
if(paymentFun != 'Wechat'){
|
||||
paymentFun = 'Wechat'
|
||||
$(".select_wechat").append(selectPaymentHTML);
|
||||
$(".select_alipay").empty();
|
||||
$(".select_bank").empty();
|
||||
}
|
||||
})
|
||||
$("#select_alipay").click(function(){
|
||||
if(paymentFun != 'Alipay'){
|
||||
paymentFun = 'Alipay'
|
||||
$(".select_wechat").empty();
|
||||
$(".select_alipay").append(selectPaymentHTML);
|
||||
$(".select_bank").empty();
|
||||
}
|
||||
})
|
||||
$("#select_bank").click(function(){
|
||||
if(paymentFun != 'Bank'){
|
||||
paymentFun = 'Bank'
|
||||
$(".select_wechat").empty();
|
||||
$(".select_alipay").empty();
|
||||
$(".select_bank").append(selectPaymentHTML);
|
||||
}
|
||||
})
|
||||
|
||||
$("#commit-btn").click(function () {
|
||||
if(hasPayment){
|
||||
if(window.openmobilefun != 'other'){
|
||||
appPayment()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function appPayment(){
|
||||
var payUrl = getShareLink();
|
||||
$("#commit-btn").css({"background-color":"#eee",});
|
||||
$("#commit-btn").val("订单创建中...");
|
||||
hasPayment = false;
|
||||
$.ajax({
|
||||
url: payUrl,
|
||||
method: 'get',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if(paymentFun == 'Wechat'){
|
||||
if( window.openmobilefun == 'wechat'){
|
||||
invokePay(res.order_id,res.jsapi);
|
||||
}else{
|
||||
redirectH5Payment(res.partner_order_id,res.client_moniker)
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Alipay'){
|
||||
if(window.openmobilefun == 'alipay'){
|
||||
callPayment(res);
|
||||
}else{
|
||||
redirectH5Payment(res.partner_order_id,res.client_moniker)
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Bank'){
|
||||
cbbankPayment(res);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseJSON.message);
|
||||
$("#commit-btn").css({"background-color":"#ED2424",});
|
||||
$("#commit-btn").val("支付");
|
||||
if(maxtime>0){
|
||||
hasPayment = true;
|
||||
}else{
|
||||
hasPayment = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function redirectH5Payment(orderId,clientMoniker){
|
||||
window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/pay';
|
||||
}
|
||||
|
||||
function getShareLink(){
|
||||
var paymentLink = ''
|
||||
if(window.sharetype != 'app'){
|
||||
//PC端扫码访问
|
||||
if(paymentFun == 'Wechat'){
|
||||
if(window.openmobilefun == 'wechat'){
|
||||
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/wechat/mobile';
|
||||
}else{
|
||||
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Wechat';
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Alipay'){
|
||||
if(window.openmobilefun == 'alipay'){
|
||||
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile';
|
||||
}else{
|
||||
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay';
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Bank'){
|
||||
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/cbbank/mobile?partner_moniker='+window.clientmoniker;
|
||||
}
|
||||
}else{
|
||||
//app扫码访问
|
||||
if(paymentFun == 'Wechat'){
|
||||
if(window.openmobilefun == 'wechat'){
|
||||
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/wechat/share_link';
|
||||
}else{
|
||||
paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Wechat';
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Alipay'){
|
||||
if(window.openmobilefun == 'alipay'){
|
||||
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/alipay/share_link'
|
||||
}else{
|
||||
paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay';
|
||||
|
||||
}
|
||||
}
|
||||
if(paymentFun == 'Bank'){
|
||||
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/cbbank/share_link?partner_moniker='+window.clientmoniker;
|
||||
}
|
||||
}
|
||||
return paymentLink;
|
||||
}
|
||||
|
||||
//微信支付方式
|
||||
function invokePay(orderId,paydata) {
|
||||
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
||||
'appId': paydata.appId,
|
||||
'timeStamp': paydata.timeStamp,
|
||||
'nonceStr': paydata.nonceStr,
|
||||
'package': paydata.package,
|
||||
'signType': paydata.signType,
|
||||
'paySign': paydata.paySign
|
||||
}, function (res) {
|
||||
var redirect = "/api/payment/v1.0/wechat_jsapi_payment/partners/" + window.clientmoniker + "/orders/" + orderId+"?";
|
||||
if (res.err_msg == 'get_brand_wcpay_request:ok') {
|
||||
startCheckOrder(orderId,redirect + (redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true')
|
||||
} else {
|
||||
if (res.err_msg == 'get_brand_wcpay_request:cancel') {
|
||||
hasPayment = true;
|
||||
$("#commit-btn").css({"background-color":"#ED2424",});
|
||||
$("#commit-btn").val("支付");
|
||||
}
|
||||
if( res.err_msg == 'get_brand_wcpay_request:fail'){
|
||||
hasPayment = true;
|
||||
$("#commit-btn").css({"background-color":"#ED2424",});
|
||||
$("#commit-btn").val("支付");
|
||||
location.href = redirect + (redirect.indexOf('?') < 0 ? '?' : '&') + 'success=false';
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//支付宝支付方式
|
||||
function callPayment(paydata) {
|
||||
try {
|
||||
if(typeof paydata.trade_no == 'undefined'){
|
||||
window.location.href = paydata.mweb_url
|
||||
}else {
|
||||
AlipayJSBridge.call('tradePay', {
|
||||
tradeNO: paydata.trade_no
|
||||
}, function (res) {
|
||||
if (res.resultCode == '9000') {
|
||||
AlipayJSBridge.call('startApp', {
|
||||
appId: '20000056',
|
||||
param: {
|
||||
actionType: 'showSuccPage',
|
||||
payResult: res.result
|
||||
},
|
||||
closeCurrentApp: false
|
||||
});
|
||||
startCheckOrder(paydata.order_id, '/api/v1.0/alipay_direct/partners/' + window.clientmoniker + '/orders/' + paydata.order_id + '/result');
|
||||
} else {
|
||||
hasPayment = true;
|
||||
$("#commit-btn").css({"background-color": "#ED2424",});
|
||||
$("#commit-btn").val("支付");
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
alert(err);
|
||||
$('#wdiv').hide();
|
||||
}
|
||||
}
|
||||
|
||||
//银联支付方式
|
||||
function cbbankPayment(res){
|
||||
if('SUCCESS' !== res.return_code && typeof res.return_code !== 'undefined'){
|
||||
$("#commit-btn").css({"background-color":"#ED2424",});
|
||||
if(maxtime>0){
|
||||
hasPayment = true;
|
||||
}else{
|
||||
hasPayment = false;
|
||||
}
|
||||
}else {
|
||||
location.href = res.pay_url;
|
||||
}
|
||||
}
|
||||
|
||||
//调用查询订单状态方法
|
||||
function startCheckOrder(orderId, url) {
|
||||
function checkOrderStd() {
|
||||
$.ajax({
|
||||
url: '/api/v1.0/payment/orders/' + orderId + '/status',
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.paid) {
|
||||
location.href = url;
|
||||
} else {
|
||||
setTimeout(checkOrderStd, 500);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
checkOrderStd();
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,159 @@
|
||||
/**
|
||||
* Created by dulingling on 2020-03-25.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
var paymentFun = 'Wechat';
|
||||
var maxtime = window.maxtime;
|
||||
var hasPayment =true;//可支付
|
||||
|
||||
if(document.documentElement.clientWidth<500){
|
||||
$('.img-size').css({"height":"28px",})
|
||||
}
|
||||
|
||||
if(window.clientInfo.enable_wechat){
|
||||
var paymentFun = 'Wechat';
|
||||
showQRcode();
|
||||
}else if(window.clientInfo.enable_alipay){
|
||||
var paymentFun = 'Alipay';
|
||||
showQRcode();
|
||||
}else if(window.clientInfo.enable_cb_bankpay){
|
||||
var paymentFun = 'Bank';
|
||||
showQRcode();
|
||||
}
|
||||
|
||||
startCheckOrder();
|
||||
|
||||
setInterval(function(){
|
||||
if(maxtime>0){
|
||||
var countdown=document.getElementById("timer");
|
||||
maxtime=maxtime-1;
|
||||
var minute=parseInt(maxtime/60);
|
||||
var second=parseInt(maxtime%60);
|
||||
countdown.innerHTML=minute+'分'+second+'秒';
|
||||
}else{
|
||||
hasPayment = false;
|
||||
$('#qrImg').empty();
|
||||
}
|
||||
},1000);
|
||||
|
||||
|
||||
$("#select_wechat").click(function(){
|
||||
if(paymentFun != 'Wechat'){
|
||||
paymentFun = 'Wechat'
|
||||
$("#select_wechat").removeClass("no-select-pay-fun").addClass("select-pay-fun");
|
||||
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
showQRcode();
|
||||
}
|
||||
})
|
||||
$("#select_alipay").click(function(){
|
||||
if(paymentFun != 'Alipay'){
|
||||
paymentFun = 'Alipay'
|
||||
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
$("#select_alipay").removeClass("no-select-pay-fun").addClass("select-pay-fun");
|
||||
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
showQRcode();
|
||||
}
|
||||
})
|
||||
$("#select_bank").click(function(){
|
||||
if(paymentFun != 'Bank'){
|
||||
paymentFun = 'Bank'
|
||||
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
|
||||
$("#select_bank").removeClass("no-select-pay-fun").addClass("select-pay-fun");
|
||||
showQRcode();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function showQRcode() {
|
||||
if (hasPayment) {
|
||||
var payUrl = '';
|
||||
var orderId = window.clientmoniker + dateFormat() + String(Math.random()).substring(2, 8).toUpperCase();
|
||||
var channelName = paymentFun == 'Wechat' ? '微信' : '支付宝'
|
||||
if (paymentFun == 'Wechat') {
|
||||
$('#qrImg').empty();
|
||||
document.getElementById("qrImg").style.display = 'block';
|
||||
var selectPaymentHTML =
|
||||
"<p style='font-size: 20px;font-weight: 800'>请使用" + channelName + "客户端扫码支付</p>" +
|
||||
"<img src='" + window.wechatqrcode + "'>";
|
||||
$('#qrImg').append(selectPaymentHTML)
|
||||
} else if (paymentFun == 'Alipay') {
|
||||
$('#qrImg').empty();
|
||||
document.getElementById("qrImg").style.display = 'block';
|
||||
var selectPaymentHTML =
|
||||
"<p style='font-size: 20px;font-weight: 800'>请使用" + channelName + "客户端扫码支付</p>" +
|
||||
"<img src='" + window.alipayqrcode + "'>";
|
||||
$('#qrImg').append(selectPaymentHTML)
|
||||
} else if (paymentFun == 'Bank') {
|
||||
$('#qrImg').empty();
|
||||
document.getElementById("qrImg").style.display = 'block';
|
||||
if( hasPayment){
|
||||
createCBBankOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createCBBankOrder() {
|
||||
$.ajax({
|
||||
url: window.cbbankpaymentlink,
|
||||
method: 'get',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
cbbankPayment(res);
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseJSON.message);
|
||||
if(maxtime>0){
|
||||
hasPayment = true;
|
||||
}else{
|
||||
hasPayment = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function cbbankPayment(res){
|
||||
if('SUCCESS' !== res.return_code && typeof res.return_code !== 'undefined'){
|
||||
}else {
|
||||
location.href = res.pay_url;
|
||||
}
|
||||
}
|
||||
|
||||
//做个每5秒查询查询一次订单状态
|
||||
function startCheckOrder(orderId) {
|
||||
//通知URL
|
||||
|
||||
function checkOrderStd() {
|
||||
$.ajax({
|
||||
url: '/api/v1.0/payment/billOrder/' + window.billInfo.client_order_id + '/status',
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.paid) {
|
||||
location.href = res.redirect;
|
||||
} else {
|
||||
setTimeout(checkOrderStd, 500);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
checkOrderStd();
|
||||
}
|
||||
|
||||
function dateFormat() {
|
||||
var date = new Date();
|
||||
var formatTimeStr = '';
|
||||
formatTimeStr += date.getFullYear();
|
||||
formatTimeStr += date.getMonth()+1;
|
||||
formatTimeStr += date.getDate();
|
||||
formatTimeStr += date.getHours();
|
||||
formatTimeStr += date.getMinutes();
|
||||
formatTimeStr += date.getSeconds();
|
||||
return formatTimeStr;
|
||||
}
|
||||
});
|