151 lines
6.2 KiB
JavaScript
151 lines
6.2 KiB
JavaScript
layui.use(['form', 'layedit', 'laydate', 'element'], function () {
|
||
var form = layui.form
|
||
, layer = layui.layer
|
||
, layedit = layui.layedit
|
||
, element = layui.element
|
||
, laydate = layui.laydate;
|
||
});
|
||
|
||
layui.use('jquery', function () {
|
||
var $ = layui.jquery;
|
||
|
||
$(function () {
|
||
|
||
var firstStep = '提交支付订单';
|
||
var twoStep = "<span id='two_back'>返回</span> | 选择支付方式";
|
||
var payRes = '支付结果';
|
||
|
||
$("body").on("click", "#two_back", function () {
|
||
$(".pay-jd div.first-step").show();
|
||
$(".pay-jd div.two-step").hide();
|
||
$(".pay-res").hide();
|
||
$(".tit").html(firstStep);
|
||
$(".pay-jd ul").removeClass("two-step")
|
||
});
|
||
$(".sbt-btn").on("click", function () {
|
||
if (parseFloat($("#amount").val()) <= 0 || $("#amount").val() == "") {
|
||
layer.msg("请输入正确的充值金额!");
|
||
$("#amount").focus();
|
||
return false;
|
||
}
|
||
$(".pay-jd div.first-step").hide();
|
||
$(".pay-jd div.two-step").show();
|
||
$(".pay-res").hide(), $(".tit").html(twoStep);
|
||
$(".pay-jd ul").addClass("two-step");
|
||
});
|
||
$(".sbpay-btn").on("click", function () {
|
||
|
||
if ($("#channelID").val() == "") {
|
||
layer.msg("选择一种支付方式!");
|
||
return false;
|
||
}
|
||
if ($("#channelID").val() == 'weixin' || $("#channelID").val() == 'QQbao') {
|
||
if (parseFloat($("#amount").val()) < 1) {
|
||
layer.msg("充值金额不能少于1元!");
|
||
//$("#amount").val("");
|
||
$("#amount").focus();
|
||
$(".pay-jd div.first-step").show();
|
||
$(".pay-jd div.two-step").hide();
|
||
$(".pay-res").hide();
|
||
$(".tit").html(firstStep);
|
||
$(".pay-jd ul").removeClass("two-step");
|
||
return false;
|
||
}
|
||
} else if ($("#channelID").val() == 'uniopnpay') {
|
||
if (parseFloat($("#amount").val()) < 10) {
|
||
layer.msg("充值金额不能少于10元!");
|
||
//$("#amount").val("");
|
||
$(".pay-jd div.first-step").show();
|
||
$(".pay-jd div.two-step").hide();
|
||
$(".pay-res").hide();
|
||
$(".tit").html(firstStep);
|
||
$(".pay-jd ul").removeClass("two-step")
|
||
$("#amount").focus();
|
||
return false;
|
||
}
|
||
}
|
||
$(".pay-jd div.first-step").hide();
|
||
$(".pay-jd div.two-step").show();
|
||
$(".pay-res").hide();
|
||
$(".tit").html(twoStep);
|
||
$(".pay-jd ul").addClass("three-step");
|
||
$(".confirm-pop").show();
|
||
$("#FormPay").submit();
|
||
});
|
||
$(".pay-label li input").on("click", function () {
|
||
//console.log($(this).val());
|
||
$("#channelID").val($(this).val());
|
||
});
|
||
$(".change-pay").on("click", function () {
|
||
var num = Math.floor(Math.random() * 9999999999999999999);
|
||
$("#orderID").val(num);
|
||
$("#strOrder").html(num);
|
||
$(".pay-jd div.first-step").hide(), $(".pay-jd div.two-step").show(), $(".pay-res").hide(), $(".tit").html(twoStep), $(".pay-jd ul").addClass("two-step"), $(".pay-jd ul").removeClass("three-step"),
|
||
$(".confirm-pop").hide();
|
||
});
|
||
$(".finish-btn").on("click", function () {
|
||
$(".confirm-pop").hide();
|
||
var loading = layer.load(0, {shade: false});
|
||
var OrderId = $("#orderID").val();
|
||
window.location.href='user/order';
|
||
// $.ajax({
|
||
// type: 'POST',
|
||
// url: 'http://pay.suibipay.com/Payapi_Index_orderSearch.html',
|
||
// data: 'OrderId=' + OrderId + '&channelID=' + $("#channelID").val(),
|
||
// dataType: 'json',
|
||
// success: function (result) {
|
||
// layer.close(loading);
|
||
// if (result.status == true) {
|
||
//
|
||
// layer.open({
|
||
// type: 1
|
||
// , offset: 'auto'
|
||
// , id: 'layerMsg'
|
||
// , content: '<div style="padding: 20px 100px;">支付成功</div>'
|
||
// , btn: '确定'
|
||
// , btnAlign: 'c'
|
||
// , shade: 0
|
||
// , closeBtn: 0
|
||
// , yes: function (index) {
|
||
// $(".tit").html(payRes)
|
||
// $(".pay-jd").hide();
|
||
// $("#pay-success").show();
|
||
// $("#pay-error").hide();
|
||
// location.reload();
|
||
// }
|
||
// });
|
||
//
|
||
// } else {
|
||
// $(".pay-jd").hide(), $("#pay-success").hide(), $("#pay-error").show(), $(".tit").html(payRes);
|
||
// layer.msg("支付失败!");
|
||
// }
|
||
// }
|
||
// });
|
||
});
|
||
$(".back-demo-btn").on("click", function () {
|
||
location.reload();
|
||
});
|
||
$(".gocheckorderid").on("click", function () {
|
||
var loading = layer.load(0, {shade: false});
|
||
var OrderId = $("#orderID").val();
|
||
console.log(OrderId);
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: 'http://pay.suibipay.com/Payapi_Index_orderSearch.html',
|
||
data: 'OrderId=' + OrderId + '&channelID=' + $("#channelID").val(),
|
||
dataType: 'json',
|
||
success: function (result) {
|
||
layer.close(loading);
|
||
if (result.status == true) {
|
||
|
||
layer.msg("支付成功!");
|
||
|
||
} else {
|
||
layer.msg("支付失败!");
|
||
}
|
||
}
|
||
});
|
||
})
|
||
|
||
});
|
||
}); |