《前端》swal()方法

showSwal()

 

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章