生成系统通知表和我的消息表
This commit is contained in:
@@ -18,23 +18,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">邮箱绑定</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="email-info">
|
||||
<span id="emailAddress">未绑定</span>
|
||||
<button type="button" class="layui-btn layui-btn-primary" onclick="bindEmail()">绑定邮箱</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">两步验证</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="twoFactor" lay-skin="switch" lay-text="开启|关闭">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -85,11 +69,6 @@ layui.use(['form', 'layer'], function(){
|
||||
|
||||
// 加载用户安全信息
|
||||
loadSecurityInfo();
|
||||
|
||||
// 监听两步验证开关
|
||||
form.on('switch(twoFactor)', function(data){
|
||||
updateTwoFactor(data.elem.checked);
|
||||
});
|
||||
});
|
||||
|
||||
// 加载安全信息
|
||||
@@ -99,11 +78,6 @@ function loadSecurityInfo() {
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
document.getElementById('phoneNumber').textContent = data.data.phone || '未绑定';
|
||||
document.getElementById('emailAddress').textContent = data.data.email || '未绑定';
|
||||
// 设置两步验证开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: data.data.twoFactor
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -127,44 +101,4 @@ function bindPhone() {
|
||||
content: '/index/user/component/bindPhone'
|
||||
});
|
||||
}
|
||||
|
||||
// 绑定邮箱
|
||||
function bindEmail() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '绑定邮箱',
|
||||
area: ['500px', '400px'],
|
||||
content: '/index/user/component/bindEmail'
|
||||
});
|
||||
}
|
||||
|
||||
// 更新两步验证状态
|
||||
function updateTwoFactor(enabled) {
|
||||
fetch('/index/user/updateTwoFactor', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({enabled: enabled})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 0) {
|
||||
layer.msg(enabled ? '两步验证已开启' : '两步验证已关闭', {icon: 1});
|
||||
} else {
|
||||
layer.msg(data.msg || '操作失败', {icon: 2});
|
||||
// 恢复开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: !enabled
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
layer.msg('操作失败,请重试', {icon: 2});
|
||||
// 恢复开关状态
|
||||
layui.form.val('securityForm', {
|
||||
twoFactor: !enabled
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user