From f5435e38371369a0fee4ce7b245c3ba5ecbcb072 Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Tue, 16 Dec 2025 19:02:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AE=9E=E5=90=8D=E5=88=B6-?= =?UTF-8?q?=E6=96=BD=E5=B7=A5=E4=BA=BA=E5=91=98=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/login/js/user.js | 116 +++++++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 31 deletions(-) diff --git a/public/login/js/user.js b/public/login/js/user.js index 197b0ab..9e2f3f1 100644 --- a/public/login/js/user.js +++ b/public/login/js/user.js @@ -134,6 +134,8 @@ function init() { var html = ''; html += buttonEdits(id,); html += buttonDel(id); + html += buttonReset(id); + html += buttonPassword(id); return html; } }, @@ -179,37 +181,7 @@ function insertTeamManager() { * */ function del(id) { var data = {"id": id}; - layer.confirm("确定删除吗?", { - title: '删除确认', - btn: ['确定', '取消'], - // 关键:固定位置在屏幕中央 - offset: '200px', // 距离顶部的固定偏移 - fixed: true, // 固定定位 - scrollbar: false, // 不锁定滚动条 - // 或者使用百分比 - // offset: '30%', - // 或者自动计算 - // offset: 'auto', - // 或者限制在可视区域内 - success: function (layero) { - // 对话框创建后的回调,确保在可视区域内 - var $layer = $(layero); - var top = $layer.css('top'); - var topNum = parseInt(top); - - // 如果 top 值太大,调整到合理位置 - if (topNum > 500) { - $layer.css('top', '100px'); - } - - // 确保对话框可见 - $layer.css({ - 'display': 'block', - 'visibility': 'visible' - }); - } - }, function (index) { - layer.close(index); + layer.confirm("确定删除吗?",function () { $.ajax({ type: 'post', contentType: "application/json; charset=utf-8", @@ -241,6 +213,79 @@ function buttonEdits(id) { return btn.prop("outerHTML"); } +// 重置密码 +function buttonReset(id) { + var btn = $(""); + return btn.prop("outerHTML"); +} + +// 修改密码 +function buttonPassword(id) { + var btn = $(""); + return btn.prop("outerHTML"); +} + +/** + * 修改密码 + * @param id + */ +function updatePassword(id){ + layer.prompt({ + formType: 0, + value: '', + title: '请输入重置后密码', + btn:['确定','取消'], + btnAlign:'c', + }, function(value, index, elem){ + if (!password_reg(value)){ + layer.msg("您的密码复杂度太低(密码中必须包含大小字母、数字、特殊字符)!",{icon:0}); + return false; + }else{ + $.ajax({ + type: 'post', + url: request_url + '/realname/publicLogin/resetPassword', + contentType: "application/json; charset=utf-8", + data: JSON.stringify({"id": id,"password":value}), + success: function (data) { + // 无论成功失败都关闭弹窗 + layer.close(index); + if (data.code == 200) { + layer.alert(data.msg, {icon: 1}); + example.ajax.reload(); // 刷新页面 + } else { + layer.msg("修改失败", {icon: 2}); + example.ajax.reload(); // 刷新页面 + } + } + }) + } + }); +} + +/** + * 重置密码 + * @param id + */ +function reset(id) { + layer.confirm("确定重置密码吗?",function () { + $.ajax({ + type: 'post', + url: request_url + '/realname/publicLogin/resetPassword', + contentType: "application/json; charset=utf-8", + data: JSON.stringify({"id": id}), + success: function (data) { + if (data.code == 200) { + layer.alert(data.msg, {icon: 1}); + example.ajax.reload(); // 刷新页面 + } else { + layer.msg("重置失败", {icon: 2}); + example.ajax.reload(); // 刷新页面 + } + } + }) + }); +} + /** * 编辑页面 */ @@ -281,3 +326,12 @@ function edit(id) { } }) } + + +const password_reg = function (str) { + var str_reg = new RegExp('(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,20}'); + if (!str_reg.test(str)) { + return false; + } + return true; +}