layui小封装方法
//打开加载动画
function LayerLoad() {
layui.use('layer', function () {
var layer = layui.layer;
layer.load(1, {
shade: [0.1, '#fff']
});
});
}
//关闭加载动画
function LoadClose() {
layui.use('layer', function () {
var layer = layui.layer;
layer.closeAll('loading');
});
}
//关闭Layer弹出层
function LayerAllClose() {
layui.use('layer', function () {
var layer = layui.layer;
layer.closeAll();
});
}
//弹出提示框
function ErrorMsg(msg) {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg(msg);
});
}
//弹出提示框
function LayerMsg(data) {
if (data.Msg && data.Msg != "") {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg(data.Msg);
});
}
if (data.Status == "true") {
if (data.ReUrl && data.ReUrl != "") {
window.location.href = data.ReUrl;
} else {
window.location.href = window.location.href;
}
}
}
//弹出询问框
function LayerConfirm(Title, StrOK, StrCanel, FunOK) {
layui.use('layer', function () {
var layer = layui.layer;
layer.confirm(Title, {
btn: [StrOK, StrCanel]
}, function () {
layer.closeAll('dialog');
FunOK();
});
});
}
//弹出Iframe框
function OpenLayerIframe(url, titlename) {
if (titlename == null || titlename == undefined)
{
titlename = "请选择";
}
layui.use('layer', function () {
var layer = layui.layer;
if (IsMobile()) {
var layerOpenID = layer.open({
type: 2,
title: titlename,
shadeClose: true,
shade: 0.8,
area: ['100%', '100%'],
content: url
});
return layerOpenID;
} else {
var layerOpenID = layer.open({
type: 2,
title: titlename,
shadeClose: true,
shade: 0.8,
area: ['80%', '60%'],
content: url
});
return layerOpenID;
}
});
}