swal() 弹出层的用法

swal()方法是一个提示框;

swal({ 
		  title: "", 
		  text: "请扫描用户手机上的付款码",
		  type: "input", 
		  showCancelButton: true, 
		  closeOnConfirm: false, 
		  cancelButtonText: "取消", 
		  confirmButtonText: "确认", 
		  imageUrl: "/assets/images/icon/scancode.gif",
		  inputPlaceholder: "请填写付款码数字",
		  showLoaderOnConfirm: true
		},function(inputValue){ 
			if(inputValue){
				if (inputValue === "") { 
				    swal.showInputError("请填写付款码数字");
				    return false 
				}else{
					$("input[name='authCode']").val(inputValue);
					var form = cashierFrom.serialize();
					$.post("/cashier/order", form, function(data) {
						var result = $.parseJSON(data);
						if (result.code == 'SUCCESS') {
							swal({
								title : "支付成功",
								type : "success",
								confirmButtonText : "确定",
								closeOnConfirm : false
							});
						} else {
							if(result.subCode=='USER_PAYING'){
								var html = '<div class="q-btn-box"><button type="button" class="btn btn-primary waves-effect waves-light">取消</button></div>';
								showLoadAlert('等待用户输入密码..',html);
								var no = result.outTradeNo;
								queryInterval = self.setInterval("cashierOrderQuery('"+no+"',true)",3000);
							}else{
								swal({
									title : "支付失败",
									type : "error",
									text : result.msg,
									confirmButtonText : "确定",
									closeOnConfirm : false
								});
							}
						}
					});
				}
			}
		});

 swal() 增加确认及取消的方法

swal({
  title: "确认删除?",
  text: "Your will not be able to recover this imaginary file!",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "确认",
  cancelButtonText: "取消",
  closeOnConfirm: false,
  closeOnCancel: false
},
function(isConfirm){
  if (isConfirm) {
    swal("Deleted!", "Your imaginary file has been deleted.", "success");
  } else {
	    swal("Cancelled", "Your imaginary file is safe :)", "error");
  }
});

  可参考地址:

http://www.dglives.com

转载于:https://www.cnblogs.com/lvxisha/p/9729692.html

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值