You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.6 KiB
JavaScript
97 lines
2.6 KiB
JavaScript
1 year ago
|
/**
|
||
|
定义弹窗模块 - 自定义弹窗
|
||
|
*/
|
||
|
layui.define(['index', 'tpl', 'qrcode'], function (exports) {
|
||
|
|
||
|
exports("dialog", {
|
||
|
setIframeDialog: function (
|
||
|
title = "",
|
||
|
data = { src: "", otherconfigStyle: "" },
|
||
|
iframeArea = { width: "820px", height: "500px" },
|
||
|
dialogArea = ["600px", "500px"]
|
||
|
) {
|
||
|
var laytpl = layui.laytpl;
|
||
|
var templet =
|
||
|
" <iframe " +
|
||
|
data.otherconfigStyle +
|
||
|
' width="' +
|
||
|
iframeArea.width +
|
||
|
'" height="' +
|
||
|
iframeArea.height +
|
||
|
'" src="' +
|
||
|
data.src +
|
||
|
'"></iframe>';
|
||
|
laytpl(templet).render({}, function (html) {
|
||
|
layer.open({
|
||
|
type: 1,
|
||
|
title: title,
|
||
|
content: templet,
|
||
|
area: dialogArea,
|
||
|
success: function () { },
|
||
|
error: function (e) {
|
||
|
console.warn("setIframeDialog error:", e);
|
||
|
},
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
setTextDialog: function (
|
||
|
title = "",
|
||
|
data = { text: "" },
|
||
|
dialogArea = ["600px", "500px"]
|
||
|
) {
|
||
|
var laytpl = layui.laytpl;
|
||
|
var templet = data.text;
|
||
|
laytpl(templet).render({}, function (html) {
|
||
|
layer.open({
|
||
|
type: 1,
|
||
|
title: title,
|
||
|
content: templet,
|
||
|
area: dialogArea,
|
||
|
success: function () { },
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
showOkMsgDialog({ msg, title = "提示", btnTitle = "好的", dialogArea = ["520px", "270px"] }) {
|
||
|
layer.confirm("",
|
||
|
{
|
||
|
title: title,
|
||
|
area: dialogArea,
|
||
|
content: `<div style="margin: 50px auto;">${msg}</div>`,
|
||
|
btnAlign: 'r',
|
||
|
skin: "msg-skin",
|
||
|
btn: [btnTitle]
|
||
|
}, function (index, layero) {
|
||
|
layer.close(index);
|
||
|
}
|
||
|
);
|
||
|
},
|
||
|
setQrCodeDialog({ id = "qrcode", title = "", data = { value: "" }, showQrcodeUrl = false, qrcodeArea = {
|
||
|
width: 400,
|
||
|
height: 400
|
||
|
}, dialogArea = ["700px", "500px"] }) {
|
||
|
|
||
|
var laytpl = layui.laytpl;
|
||
|
var qrcode = layui.qrcode;
|
||
|
var templet = ' <div id="' + id + '" class="qrcode"></div>';
|
||
|
if (showQrcodeUrl) {
|
||
|
templet += '<div class="show-qrcode-value"></div>';
|
||
|
}
|
||
|
laytpl(templet).render({}, function (html) {
|
||
|
layer.open({
|
||
|
type: 1,
|
||
|
title: title,
|
||
|
content: templet,
|
||
|
area: dialogArea,
|
||
|
success: function success() {
|
||
|
qrcode.qrcode(document.getElementById(id), qrcodeArea);
|
||
|
qrcode.makeCode(data.value);
|
||
|
if (showQrcodeUrl) {
|
||
|
layui.$('.show-qrcode-value').html(layui.$('.qrcode').attr('title'));
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
});
|