From 098c9e31864e7b46fd64d3bbc6988bf7faa62912 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 14 Jun 2019 21:06:41 +0800 Subject: [PATCH] modify --- app/views/trainings/pay.html.erb | 86 ++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/app/views/trainings/pay.html.erb b/app/views/trainings/pay.html.erb index 5b683b30..690e73a6 100644 --- a/app/views/trainings/pay.html.erb +++ b/app/views/trainings/pay.html.erb @@ -172,9 +172,8 @@ //延迟支付,直接提交 $('#delayPayBtn').on('click', function () { - if($("#billDemand").attr("status")==2){ - $(".billInput").val(''); - } + if(!checkBillInfo()){ return } + alert("报名成功,请尽快支付"); $('form').submit(); }); @@ -184,10 +183,8 @@ }) //立即支付 $('#payBtn').on('click', function () { + if(!checkBillInfo()){ return } - if($("#billDemand").attr("status")==2){ - $(".billInput").val(''); - } var postData = $('form').serialize(); postData += '&js=true' console.log(postData); @@ -236,15 +233,12 @@ //线下支付提交 $('#submitFormBtn').on('click', function () { - if($("#billDemand").attr("status")==2){ - $(".billInput").val(''); - } + if(!checkBillInfo()){ return } $('form').submit(); }); $('#laterSubmitFormBtn').on('click', function () { - if($("#billDemand").attr("status")==2){ - $(".billInput").val(''); - } + if(!checkBillInfo()){ return } + $('#offline_later_pay').val('true'); $('form').submit(); }); @@ -381,36 +375,62 @@ var unit = $(".billUnit").val(); var tax = $(".taxNumber").val(); //只有选择了单位时才需要判断三个是否都已经填写 + if (type == "单位" || type == "个人") { + if (unit == "") { + $(".billUnit").addClass("nullVal"); + return; + } else { + $(".billUnit").removeClass("nullVal"); + } + } if (type == "单位") { - if (unit == "") { - $(".billUnit").addClass("nullVal"); - return; - } else { - $(".billUnit").removeClass("nullVal"); - } - if (tax == "") { - $(".taxNumber").addClass("nullVal"); - return; - } else { - $(".taxNumber").removeClass("nullVal"); - } + if (tax == "") { + $(".taxNumber").addClass("nullVal"); + return; + } else { + $(".taxNumber").removeClass("nullVal"); + } } //选择单位或者个人都要判断是否填写了发票内容 - if (type == "单位" || type == "个人") { - var remark = $("input[name='invoice_content']").val(); - if (remark == "") { - $("input[name='invoice_content']").addClass("nullVal"); - return; - } else { - $("input[name='invoice_content']").removeClass("nullVal"); - } - } + // if (type == "单位" || type == "个人") { + // var remark = $("input[name='invoice_content']").val(); + // if (remark == "") { + // $("input[name='invoice_content']").addClass("nullVal"); + // return; + // } else { + // $("input[name='invoice_content']").removeClass("nullVal"); + // } + // } $("#billDemand").html(type); //记录选中的发票类型 $("#billDemand").attr("status",$(".billType li.active").index()); hideNav($(".billDownNav")); } + function checkBillInfo() { + var bill = $("#billLine"); + var billNav = $(".billDownNav"); + var status = $("#billDemand").attr("status"); + if(status == 2){ + $(".billInput").val(''); + } + + var billUnit = $('.billUnit').val(); + var taxNumber = $('.taxNumber').val(); + if(status == 1 && billUnit == ''){ + alert('请将发票信息填写完整'); + showNav(bill, billNav, "down"); + return false; + } + if(status == 0 && (billUnit == '' || taxNumber == '')){ + alert('请将发票信息填写完整'); + showNav(bill, billNav, "down"); + return false; + } + + return true; + } + function InitPhoto() { var tmpl = '
  • ', $gallery = $("#gallery"), $galleryImg = $("#galleryImg"),