增加极验验证开关设置
This commit is contained in:
parent
ebffdf180e
commit
d4017014f5
@ -405,30 +405,49 @@ class YunzerController extends Base
|
|||||||
}
|
}
|
||||||
# 配置值
|
# 配置值
|
||||||
public function configvalue()
|
public function configvalue()
|
||||||
{
|
{
|
||||||
$req = request();
|
$req = request();
|
||||||
if ($req->isPost()) {
|
if ($req->isPost()) {
|
||||||
$post = input('post.');
|
$post = input('post.');
|
||||||
if (empty($post)) {
|
if (empty($post)) {
|
||||||
Log::record('更新配置值', 0, '数据不能为空', '系统配置');
|
Log::record('更新配置值', 0, '数据不能为空', '系统配置');
|
||||||
$this->returnCode(1, '数据不能为空');
|
$this->returnCode(1, '数据不能为空');
|
||||||
}
|
}
|
||||||
$oConfig = new YzAdminConfig();
|
|
||||||
$updateAll = $oConfig->updateAll($post);
|
// 获取所有配置项,检查 config_type 为 4 的项
|
||||||
if (empty($updateAll)) {
|
$allConfigs = AdminConfig::order('config_sort DESC,config_id')->select();
|
||||||
Log::record('更新配置值', 0, '更新配置值失败', '系统配置');
|
foreach ($allConfigs as $config) {
|
||||||
$this->returnCode(1, '更新配置值失败');
|
if ($config['config_type'] == 4) {
|
||||||
}
|
$checkboxName = $config['config_name'] . '_checkbox';
|
||||||
Log::record('更新配置值', 1, '', '系统配置');
|
$configName = $config['config_name'];
|
||||||
$this->returnCode(0);
|
if (!isset($post[$checkboxName])) {
|
||||||
} else {
|
// 复选框未选中,手动添加对应的值为 0
|
||||||
$lists = AdminConfig::order('config_sort DESC,config_id')->select();
|
$post[$configName] = 0;
|
||||||
View::assign([
|
} else {
|
||||||
'lists' => $lists
|
// 复选框选中,确保值为 1
|
||||||
]);
|
$post[$configName] = 1;
|
||||||
return View::fetch();
|
}
|
||||||
}
|
// 移除 checkbox 字段
|
||||||
}
|
unset($post[$checkboxName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$oConfig = new YzAdminConfig();
|
||||||
|
$updateAll = $oConfig->updateAll($post);
|
||||||
|
if (empty($updateAll)) {
|
||||||
|
Log::record('更新配置值', 0, '更新配置值失败', '系统配置');
|
||||||
|
$this->returnCode(1, '更新配置值失败');
|
||||||
|
}
|
||||||
|
Log::record('更新配置值', 1, '', '系统配置');
|
||||||
|
$this->returnCode(0);
|
||||||
|
} else {
|
||||||
|
$lists = AdminConfig::order('config_sort DESC,config_id')->select();
|
||||||
|
View::assign([
|
||||||
|
'lists' => $lists
|
||||||
|
]);
|
||||||
|
return View::fetch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 邮件配置
|
// 邮件配置
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); */
|
/* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); */
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-header {
|
.config-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -13,15 +14,18 @@
|
|||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-header span {
|
.config-header span {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #2c3e50;
|
color: #2c3e50;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-header a {
|
.config-header a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-header a span {
|
.config-header a span {
|
||||||
padding: 6px 15px;
|
padding: 6px 15px;
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
@ -30,56 +34,70 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-header a span:hover {
|
.config-header a span:hover {
|
||||||
background: #e9ecef;
|
background: #e9ecef;
|
||||||
color: #409EFF;
|
color: #409EFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-form-item {
|
.layui-form-item {
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-form-label {
|
.layui-form-label {
|
||||||
color: #606266;
|
color: #606266;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-input {
|
.layui-input {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-input:focus {
|
.layui-input:focus {
|
||||||
border-color: #409EFF;
|
border-color: #409EFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-textarea {
|
.layui-textarea {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-word-aux {
|
.layui-word-aux {
|
||||||
color: #909399;
|
color: #909399;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-btn {
|
.layui-btn {
|
||||||
border-radius: 4px;
|
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;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-btn:hover {
|
.layui-btn:hover {
|
||||||
transform: translateY(-1px);
|
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 {
|
.upload-preview {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-preview img {
|
.upload-preview img {
|
||||||
border-radius: 4px;
|
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;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-preview img:hover {
|
.upload-preview img:hover {
|
||||||
transform: scale(1.02);
|
transform: scale(1.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
.save-button-container {
|
.save-button-container {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
border-top: 1px solid #eee;
|
border-top: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.save-button-container .layui-btn {
|
.save-button-container .layui-btn {
|
||||||
padding: 0 50px;
|
padding: 0 50px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
@ -98,66 +116,81 @@
|
|||||||
|
|
||||||
<form class="layui-form">
|
<form class="layui-form">
|
||||||
{foreach($lists as $lists_v)}
|
{foreach($lists as $lists_v)}
|
||||||
{if($lists_v['config_type'] == 1)}
|
{if($lists_v['config_type'] == 1)}
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||||
<div class="layui-input-inline" style="width: 350px;">
|
<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>
|
||||||
|
{elseif($lists_v['config_type'] == 2)/}
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal" id="{$lists_v['config_name']}">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i> 上传图片
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">{$lists_v['config_info']}预览</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<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']}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{elseif($lists_v['config_type'] == 2)/}
|
</div>
|
||||||
<div class="layui-form-item">
|
</div>
|
||||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
<script type="text/javascript">
|
||||||
<div class="layui-input-inline">
|
layui.use(['layer', 'upload'], function () {
|
||||||
<button type="button" class="layui-btn layui-btn-normal" id="{$lists_v['config_name']}">
|
layer = layui.layer;
|
||||||
<i class="layui-icon layui-icon-upload"></i> 上传图片
|
upload = layui.upload;
|
||||||
</button>
|
$ = layui.jquery;
|
||||||
</div>
|
|
||||||
<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
|
|
||||||
</div>
|
|
||||||
<div class="layui-form-item">
|
|
||||||
<label class="layui-form-label">{$lists_v['config_info']}预览</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<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']}"/>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
layui.use(['layer','upload'],function(){
|
|
||||||
layer = layui.layer;
|
|
||||||
upload = layui.upload;
|
|
||||||
$ = layui.jquery;
|
|
||||||
|
|
||||||
upload.render({
|
upload.render({
|
||||||
elem: "#{$lists_v['config_name']}",
|
elem: "#{$lists_v['config_name']}",
|
||||||
url: "{$config['admin_route']}index/upload_img",
|
url: "{$config['admin_route']}index/upload_img",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
done: function(res,title){
|
done: function (res, title) {
|
||||||
if(res.code > 0){
|
if (res.code > 0) {
|
||||||
return layer.msg("上传失败,"+res.msg, {icon: 2});
|
return layer.msg("上传失败," + res.msg, { icon: 2 });
|
||||||
}else{
|
} 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>');
|
$("#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});
|
layer.msg("上传成功", { icon: 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{elseif($lists_v['config_type'] == 3)/}
|
{elseif($lists_v['config_type'] == 3)/}
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
<label class="layui-form-label">{$lists_v['config_info']}</label>
|
||||||
<div class="layui-input-block">
|
<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']}"
|
||||||
</div>
|
placeholder="{$lists_v['config_desc']}">{$lists_v['config_value']}</textarea>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
</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}
|
{/foreach}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -169,21 +202,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function save(){
|
function save() {
|
||||||
var loadIndex = layer.load(1, {
|
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);
|
layer.close(loadIndex);
|
||||||
if(res.code>0){
|
if (res.code > 0) {
|
||||||
layer.msg(res.msg,{'icon':2});
|
layer.msg(res.msg, { 'icon': 2 });
|
||||||
}else{
|
} else {
|
||||||
layer.msg(res.msg,{'icon':1});
|
layer.msg(res.msg, { 'icon': 1 });
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
history.go(0);
|
history.go(0);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
},'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{include file="public/tail" /}
|
{include file="public/tail" /}
|
||||||
@ -156,7 +156,7 @@
|
|||||||
<div class="layui-tab">
|
<div class="layui-tab">
|
||||||
<ul class="layui-tab-title">
|
<ul class="layui-tab-title">
|
||||||
<li class="layui-this" lay-id="account">账密登录</li>
|
<li class="layui-this" lay-id="account">账密登录</li>
|
||||||
<li lay-id="phone">手机验证码</li>
|
<!-- <li lay-id="phone">手机验证码</li> -->
|
||||||
<li lay-id="wechat">微信登录</li>
|
<li lay-id="wechat">微信登录</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="layui-tab-content">
|
<div class="layui-tab-content">
|
||||||
@ -189,7 +189,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-tab-item" id="phone">
|
<!-- <div class="layui-tab-item" id="phone">
|
||||||
<form action="#" method="post" class="layui-form login-form">
|
<form action="#" method="post" class="layui-form login-form">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<div class="layui-input-block" style="margin-left: 0;">
|
<div class="layui-input-block" style="margin-left: 0;">
|
||||||
@ -217,7 +217,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="layui-tab-item" id="wechat">
|
<div class="layui-tab-item" id="wechat">
|
||||||
<div class="wechat-login">
|
<div class="wechat-login">
|
||||||
<img src="" alt="微信登录" class="layui-img">
|
<img src="" alt="微信登录" class="layui-img">
|
||||||
@ -233,25 +233,131 @@
|
|||||||
var element = layui.element;
|
var element = layui.element;
|
||||||
var $ = layui.jquery;
|
var $ = layui.jquery;
|
||||||
|
|
||||||
// 初始化极验验证
|
// 检查极验验证是否开启
|
||||||
var handler = function (captchaObj) {
|
<?php if ($config['geetest_open'] == 1): ?>
|
||||||
// 将验证码渲染到指定容器
|
// 初始化极验验证
|
||||||
captchaObj.appendTo('#gt-captcha');
|
var handler = function (captchaObj) {
|
||||||
|
// 将验证码渲染到指定容器
|
||||||
|
captchaObj.appendTo('#gt-captcha');
|
||||||
|
|
||||||
// 账密登录表单提交
|
// 账密登录表单提交
|
||||||
form.on('submit(accountLogin)', function (data) {
|
form.on('submit(accountLogin)', function (data) {
|
||||||
var validate = captchaObj.getValidate();
|
var validate = captchaObj.getValidate();
|
||||||
if (!validate) {
|
if (!validate) {
|
||||||
layer.msg('请完成验证码验证', {
|
layer.msg('请完成验证码验证', {
|
||||||
icon: 2,
|
icon: 2,
|
||||||
time: 2000
|
time: 2000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
data.field.geetest_challenge = validate.geetest_challenge;
|
||||||
|
data.field.geetest_validate = validate.geetest_validate;
|
||||||
|
data.field.geetest_seccode = validate.geetest_seccode;
|
||||||
|
|
||||||
|
$.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;
|
return false;
|
||||||
}
|
});
|
||||||
data.field.geetest_challenge = validate.geetest_challenge;
|
|
||||||
data.field.geetest_validate = validate.geetest_validate;
|
|
||||||
data.field.geetest_seccode = validate.geetest_seccode;
|
|
||||||
|
|
||||||
|
// 手机验证码登录表单提交
|
||||||
|
form.on('submit(phoneLogin)', function (data) {
|
||||||
|
var validate = captchaObj.getValidate();
|
||||||
|
if (!validate) {
|
||||||
|
layer.msg('请完成验证码验证', {
|
||||||
|
icon: 2,
|
||||||
|
time: 2000
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
data.field.geetest_challenge = validate.geetest_challenge;
|
||||||
|
data.field.geetest_validate = validate.geetest_validate;
|
||||||
|
data.field.geetest_seccode = validate.geetest_seccode;
|
||||||
|
|
||||||
|
$.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 () {
|
||||||
|
var validate = captchaObj.getValidate();
|
||||||
|
if (!validate) {
|
||||||
|
layer.msg('请完成验证码验证', {
|
||||||
|
icon: 2,
|
||||||
|
time: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('获取验证码');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 直接使用配置初始化极验验证,并添加错误处理
|
||||||
|
initGeetest4({
|
||||||
|
captchaId: '{$config[\'geetest_id\']}',
|
||||||
|
offline: false,
|
||||||
|
new_captcha: true
|
||||||
|
}, handler, function (error) {
|
||||||
|
console.error('极验验证初始化失败:', error);
|
||||||
|
layer.msg('验证码初始化失败,请刷新页面重试', {
|
||||||
|
icon: 2,
|
||||||
|
time: 2000
|
||||||
|
});
|
||||||
|
});
|
||||||
|
<?php else: ?>
|
||||||
|
// 极验验证关闭,移除验证码容器
|
||||||
|
$('#gt-captcha').remove();
|
||||||
|
|
||||||
|
// 移除表单提交时的验证码验证逻辑
|
||||||
|
form.on('submit(accountLogin)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{:url("index/user/login")}',
|
url: '{:url("index/user/login")}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -285,20 +391,7 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 手机验证码登录表单提交
|
|
||||||
form.on('submit(phoneLogin)', function (data) {
|
form.on('submit(phoneLogin)', function (data) {
|
||||||
var validate = captchaObj.getValidate();
|
|
||||||
if (!validate) {
|
|
||||||
layer.msg('请完成验证码验证', {
|
|
||||||
icon: 2,
|
|
||||||
time: 2000
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
data.field.geetest_challenge = validate.geetest_challenge;
|
|
||||||
data.field.geetest_validate = validate.geetest_validate;
|
|
||||||
data.field.geetest_seccode = validate.geetest_seccode;
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{:url("index/user/login")}',
|
url: '{:url("index/user/login")}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -324,32 +417,11 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 点击获取验证码按钮时验证
|
// 移除获取验证码按钮的验证码验证逻辑
|
||||||
document.getElementById('getCode').addEventListener('click', function () {
|
document.getElementById('getCode').addEventListener('click', function () {
|
||||||
var validate = captchaObj.getValidate();
|
|
||||||
if (!validate) {
|
|
||||||
layer.msg('请完成验证码验证', {
|
|
||||||
icon: 2,
|
|
||||||
time: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log('获取验证码');
|
console.log('获取验证码');
|
||||||
});
|
});
|
||||||
};
|
<?php endif; ?>
|
||||||
|
|
||||||
// 直接使用配置初始化极验验证,并添加错误处理
|
|
||||||
initGeetest4({
|
|
||||||
captchaId: '{$config[\'geetest_id\']}',
|
|
||||||
offline: false,
|
|
||||||
new_captcha: true
|
|
||||||
}, handler, function (error) {
|
|
||||||
console.error('极验验证初始化失败:', error);
|
|
||||||
layer.msg('验证码初始化失败,请刷新页面重试', {
|
|
||||||
icon: 2,
|
|
||||||
time: 2000
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 页面加载时检查是否有保存的登录数据
|
// 页面加载时检查是否有保存的登录数据
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user