zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    bzoj1432_[ZJOI2009]Function
    Luogu1681_ 最大正方形II
    初等数论-Base-2(扩展欧几里得算法,同余,线性同余方程,(附:裴蜀定理的证明))
    [bzoj2456] mode
    初等数论-Base-1(筛法求素数,欧拉函数,欧几里得算法)
    小程序之Tab切换
    vue-axios基本用法
    vue-过渡动画
    vue-router实例
    永恒之蓝漏洞利用复现
  • 原文地址:https://www.cnblogs.com/lvxisha/p/9729692.html
Copyright © 2011-2022 走看看