(function ($) {
var layer = layui.layer;
var table = layui.table;
$('.g-screen .addNew').click(function () {
layer.open({
type: 2,
title: '添加促销规则',
area: ["80%","70%"],
content: 'add_promotion.html',
btn:['确认','取消'],
btn1: function(index, layero) {
var body = layer.getChildFrame('body', index); (关键作用的一行)
var title = body.find("#title").val();
var promo_type = body.find(".Choice ul li.Choice-this").val();
var scope = body.find(".Scope ul li.Choice-this").val();
// console.log(title);
// console.log(promo_type);
// console.log(scope);
if(title == ''){
layer.alert('促销标题不能为空!!!')
}else if(promo_type == undefined){
layer.alert('促销方式至少选择一个!!!')
}else if(scope == undefined){
layer.alert('商品范围至少选择一个!!!')
}else{
$.ajax({
url:"add_promotion",
type:'post',
dataType:'json',//预期服务器返回的数据类型
data:{
'title':title,
'promotion_type':promo_type,
'scope':scope
},//表格数据序列化
success:function(res){
//res为响应体,function为回调函数
if(res.status==200){
layer.alert('新建成功(^_^)~~~')
}else{
layer.alert('新建失败!!!');
}
}
});
}
return false;
},
btn2:function () {
layer.msg("取消操作");
},
cancel: function(){
}
});
});
layui type2 通过url给弹窗iframe子页面传值(layui父子页面之间传值)
最新推荐文章于 2023-06-06 16:06:23 发布