chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
layui.define(['form', 'http'], function (exports) {
|
||||
var form = layui.form;
|
||||
function refreshVerifyCode() {
|
||||
const verifyImg = document.querySelector('[lay-filter="verifyCode"]');
|
||||
if (verifyImg) {
|
||||
verifyImg.style.opacity = '0.7';
|
||||
setTimeout(() => {
|
||||
const baseSrc = verifyImg.src.split('?')[0];
|
||||
verifyImg.src = baseSrc + '?' + Date.now();
|
||||
verifyImg.style.opacity = '1';
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
const verifyImg = document.querySelector('[lay-filter="verifyCode"]');
|
||||
if (verifyImg) {
|
||||
verifyImg.addEventListener('click', refreshVerifyCode);
|
||||
}
|
||||
form.on('submit(dataSubmit)', function (obj) {
|
||||
let data = obj.field;
|
||||
layui.http.post("save", data)
|
||||
.then(function (res) {
|
||||
if (res.code != 0) {
|
||||
layer.msg(res.message);
|
||||
refreshVerifyCode();
|
||||
} else {
|
||||
layer.alert('请稍后!', {
|
||||
time: 1500,
|
||||
end: function () {
|
||||
if (window.self !== window.top) {
|
||||
// 在 iframe 中,跳转顶级页面
|
||||
window.top.location.href = "/admin";
|
||||
} else {
|
||||
// 顶级窗口,直接跳转
|
||||
window.location.href = "/admin";
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
exports('login', {});
|
||||
})
|
||||
Reference in New Issue
Block a user