碼迷,mamicode.com
首頁 > 其他好文 > 詳細

swal() 彈出層的用法

時間:2018-09-30 16:32:41      閱讀:17282      評論:0      收藏:0      [點我收藏+]

標簽:參考   primary   彈出層   cti   icon   file   NPU   成功   ble   

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

swal() 彈出層的用法

標簽:參考   primary   彈出層   cti   icon   file   NPU   成功   ble   

原文地址:https://www.cnblogs.com/lvxisha/p/9729692.html

(12)
(17)
   
舉報
評論 一句話評論(0
登錄后才能評論!
? 2014 mamicode.com 版權所有 京ICP備13008772號-2
迷上了代碼!
河北十一选五基本走势