增加极验验证开关设置
This commit is contained in:
parent
ebffdf180e
commit
d4017014f5
@ -413,6 +413,25 @@ class YunzerController extends Base
|
||||
Log::record('更新配置值', 0, '数据不能为空', '系统配置');
|
||||
$this->returnCode(1, '数据不能为空');
|
||||
}
|
||||
|
||||
// 获取所有配置项,检查 config_type 为 4 的项
|
||||
$allConfigs = AdminConfig::order('config_sort DESC,config_id')->select();
|
||||
foreach ($allConfigs as $config) {
|
||||
if ($config['config_type'] == 4) {
|
||||
$checkboxName = $config['config_name'] . '_checkbox';
|
||||
$configName = $config['config_name'];
|
||||
if (!isset($post[$checkboxName])) {
|
||||
// 复选框未选中,手动添加对应的值为 0
|
||||
$post[$configName] = 0;
|
||||
} else {
|
||||
// 复选框选中,确保值为 1
|
||||
$post[$configName] = 1;
|
||||
}
|
||||
// 移除 checkbox 字段
|
||||
unset($post[$checkboxName]);
|
||||
}
|
||||
}
|
||||
|
||||
$oConfig = new YzAdminConfig();
|
||||
$updateAll = $oConfig->updateAll($post);
|
||||
if (empty($updateAll)) {
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
border-radius: 8px;
|
||||
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); */
|
||||
}
|
||||
|
||||
.config-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -13,15 +14,18 @@
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.config-header span {
|
||||
font-size: 18px;
|
||||
color: #2c3e50;
|
||||
font-weight: 500;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.config-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.config-header a span {
|
||||
padding: 6px 15px;
|
||||
background: #f8f9fa;
|
||||
@ -30,56 +34,70 @@
|
||||
font-size: 14px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.config-header a span:hover {
|
||||
background: #e9ecef;
|
||||
color: #409EFF;
|
||||
}
|
||||
|
||||
.layui-form-item {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
color: #606266;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.layui-input {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.layui-input:focus {
|
||||
border-color: #409EFF;
|
||||
}
|
||||
|
||||
.layui-textarea {
|
||||
border-radius: 4px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.layui-word-aux {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.layui-btn {
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.layui-btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.upload-preview {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.upload-preview img {
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.upload-preview img:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.save-button-container {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.save-button-container .layui-btn {
|
||||
padding: 0 50px;
|
||||
height: 40px;
|
||||
@ -102,7 +120,8 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||
<div class="layui-input-inline" style="width: 350px;">
|
||||
<input type="text" class="layui-input" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}" placeholder="{$lists_v['config_desc']}" value="{$lists_v['config_value']}">
|
||||
<input type="text" class="layui-input" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}"
|
||||
placeholder="{$lists_v['config_desc']}" value="{$lists_v['config_value']}">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
|
||||
</div>
|
||||
@ -122,15 +141,17 @@
|
||||
<div class="layui-upload-list upload-preview" id="yulan_{$lists_v['config_name']}" style="width:90%;">
|
||||
{if !empty($lists_v['config_value'])}
|
||||
<div class="upload_pic_li" style="position:relative;width:120px;margin:0 10px 10px 0">
|
||||
<img style="background-color: #efefef;height:120px;object-fit:cover;" src="{$lists_v['config_value']}" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()">
|
||||
<input type="hidden" name="{$lists_v['config_name']}" value="{$lists_v['config_value']}"/>
|
||||
<img style="background-color: #efefef;height:120px;object-fit:cover;"
|
||||
src="{$lists_v['config_value']}" class="layui-upload-img" onmouseover="show_img(this)"
|
||||
onmouseleave="hide_img()">
|
||||
<input type="hidden" name="{$lists_v['config_name']}" value="{$lists_v['config_value']}" />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','upload'],function(){
|
||||
layui.use(['layer', 'upload'], function () {
|
||||
layer = layui.layer;
|
||||
upload = layui.upload;
|
||||
$ = layui.jquery;
|
||||
@ -139,12 +160,12 @@
|
||||
elem: "#{$lists_v['config_name']}",
|
||||
url: "{$config['admin_route']}index/upload_img",
|
||||
multiple: true,
|
||||
done: function(res,title){
|
||||
if(res.code > 0){
|
||||
return layer.msg("上传失败,"+res.msg, {icon: 2});
|
||||
}else{
|
||||
$("#yulan_{$lists_v['config_name']}").html('<div class="upload_pic_li" style="position:relative;width:120px;margin:0 10px 10px 0"><img style="width:120px;height:120px;object-fit:cover;" src="'+ res.url +'" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()"><input type="hidden" name="{$lists_v['config_name']}" value="'+res.data+'"/></div>');
|
||||
layer.msg("上传成功", {icon: 1});
|
||||
done: function (res, title) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg("上传失败," + res.msg, { icon: 2 });
|
||||
} else {
|
||||
$("#yulan_{$lists_v['config_name']}").html('<div class="upload_pic_li" style="position:relative;width:120px;margin:0 10px 10px 0"><img style="width:120px;height:120px;object-fit:cover;" src="' + res.url + '" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()"><input type="hidden" name="{$lists_v['config_name']}" value="' + res.data + '"/></div>');
|
||||
layer.msg("上传成功", { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -154,9 +175,21 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea class="layui-textarea" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}" placeholder="{$lists_v['config_desc']}">{$lists_v['config_value']}</textarea>
|
||||
<textarea class="layui-textarea" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}"
|
||||
placeholder="{$lists_v['config_desc']}">{$lists_v['config_value']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
{elseif($lists_v['config_type'] == 4)/}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="{$lists_v['config_name']}_checkbox" lay-skin="switch" lay-text="开启|关闭" {if
|
||||
$lists_v['config_value']=='1' }checked{/if}>
|
||||
<input type="hidden" name="{$lists_v['config_name']}"
|
||||
value="{if $lists_v['config_value'] == '1'}1{else}0{/if}">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</form>
|
||||
@ -169,21 +202,21 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function save(){
|
||||
function save() {
|
||||
var loadIndex = layer.load(1, {
|
||||
shade: [0.1,'#fff']
|
||||
shade: [0.1, '#fff']
|
||||
});
|
||||
$.post('{$config["admin_route"]}yunzer/configvalue',$('form').serialize(),function(res){
|
||||
$.post('{$config["admin_route"]}yunzer/configvalue', $('form').serialize(), function (res) {
|
||||
layer.close(loadIndex);
|
||||
if(res.code>0){
|
||||
layer.msg(res.msg,{'icon':2});
|
||||
}else{
|
||||
layer.msg(res.msg,{'icon':1});
|
||||
setTimeout(function(){
|
||||
if (res.code > 0) {
|
||||
layer.msg(res.msg, { 'icon': 2 });
|
||||
} else {
|
||||
layer.msg(res.msg, { 'icon': 1 });
|
||||
setTimeout(function () {
|
||||
history.go(0);
|
||||
}, 1000);
|
||||
}
|
||||
},'json');
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
||||
{include file="public/tail" /}
|
||||
@ -156,7 +156,7 @@
|
||||
<div class="layui-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" lay-id="account">账密登录</li>
|
||||
<li lay-id="phone">手机验证码</li>
|
||||
<!-- <li lay-id="phone">手机验证码</li> -->
|
||||
<li lay-id="wechat">微信登录</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
@ -189,7 +189,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="layui-tab-item" id="phone">
|
||||
<!-- <div class="layui-tab-item" id="phone">
|
||||
<form action="#" method="post" class="layui-form login-form">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block" style="margin-left: 0;">
|
||||
@ -217,7 +217,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="layui-tab-item" id="wechat">
|
||||
<div class="wechat-login">
|
||||
<img src="" alt="微信登录" class="layui-img">
|
||||
@ -233,6 +233,8 @@
|
||||
var element = layui.element;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 检查极验验证是否开启
|
||||
<?php if ($config['geetest_open'] == 1): ?>
|
||||
// 初始化极验验证
|
||||
var handler = function (captchaObj) {
|
||||
// 将验证码渲染到指定容器
|
||||
@ -350,6 +352,76 @@
|
||||
time: 2000
|
||||
});
|
||||
});
|
||||
<?php else: ?>
|
||||
// 极验验证关闭,移除验证码容器
|
||||
$('#gt-captcha').remove();
|
||||
|
||||
// 移除表单提交时的验证码验证逻辑
|
||||
form.on('submit(accountLogin)', function (data) {
|
||||
$.ajax({
|
||||
url: '{:url("index/user/login")}',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 存储登录数据,设置7天过期
|
||||
var expireTime = new Date().getTime() + 7 * 24 * 60 * 60 * 1000;
|
||||
localStorage.setItem('user_account', data.field.account);
|
||||
localStorage.setItem('user_password', btoa(data.field.password));
|
||||
localStorage.setItem('expire_time', expireTime);
|
||||
// 添加登录状态标记
|
||||
localStorage.setItem('is_auto_login', 'true');
|
||||
|
||||
layer.msg('登录成功', {
|
||||
icon: 1,
|
||||
time: 2000,
|
||||
shade: 0.3
|
||||
}, function () {
|
||||
window.location.href = '{:url("/")}';
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
icon: 2,
|
||||
time: 2000
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('submit(phoneLogin)', function (data) {
|
||||
$.ajax({
|
||||
url: '{:url("index/user/login")}',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg('登录成功', {
|
||||
icon: 1,
|
||||
time: 2000,
|
||||
shade: 0.3
|
||||
}, function () {
|
||||
window.location.href = '{:url("/")}';
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
icon: 2,
|
||||
time: 2000
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 移除获取验证码按钮的验证码验证逻辑
|
||||
document.getElementById('getCode').addEventListener('click', function () {
|
||||
console.log('获取验证码');
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
// 页面加载时检查是否有保存的登录数据
|
||||
$(function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user