chore: 实现服务商的查询与查询密码的关联

This commit is contained in:
2025-12-18 15:35:13 +08:00
parent da924ee75f
commit ec0700a6b6
5 changed files with 509 additions and 301 deletions

View File

@@ -31,7 +31,7 @@ class Project extends Base {
/*会员中心数据表*/
$this->project_db = Db::name('project'); //
$this->service_db = Db::name('service'); //
$this->projectQueryPasswordDb = Db::name('project_query_password'); // 查询密码表
$this->projectQueryPasswordDb = Db::name('query_password'); // 查询密码表
// 是否开启支付功能设置
$this->userConfig = getUsersConfigData('all');
@@ -548,6 +548,8 @@ class Project extends Base {
'password' => trim($post['password']),
'allow_keywords' => trim($post['allow_keywords']),
'deny_keywords' => trim($post['deny_keywords']),
'allow_servicer_keywords' => trim($post['allow_servicer_keywords']),
'deny_servicer_keywords' => trim($post['deny_servicer_keywords']),
'status' => !empty($post['status']) ? 1 : 0,
'updatetime' => time()
];

View File

@@ -17,7 +17,7 @@
</dl>
<dl class="row">
<dt class="tit"> <label for="allow_keywords">允许的关键字</label> </dt>
<dt class="tit"> <label for="allow_keywords">允许的应用关键字</label> </dt>
<dd class="opt">
<textarea name="allow_keywords" id="allow_keywords" class="input-txt" rows="4" cols="60">{$info['allow_keywords']|default=''}</textarea>
<span class="err"></span>
@@ -26,7 +26,7 @@
</dl>
<dl class="row">
<dt class="tit"> <label for="deny_keywords">禁止的关键字</label> </dt>
<dt class="tit"> <label for="deny_keywords">禁止的应用关键字</label> </dt>
<dd class="opt">
<textarea name="deny_keywords" id="deny_keywords" class="input-txt" rows="4" cols="60">{$info['deny_keywords']|default=''}</textarea>
<span class="err"></span>
@@ -34,21 +34,42 @@
</dd>
</dl>
<dl class="row">
<dt class="tit"> <label for="allow_servicer_keywords">允许的服务商关键字</label> </dt>
<dd class="opt">
<textarea name="allow_servicer_keywords" id="allow_servicer_keywords" class="input-txt" rows="4" cols="60">{$info['allow_servicer_keywords']|default=''}</textarea>
<span class="err"></span>
<p class="notic2 red" id="allow_servicer_keywords_tips">在此输入允许查询的服务商名称包含的关键字,多个关键字用逗号分隔。留空表示允许查询所有服务商。</p>
</dd>
</dl>
<dl class="row">
<dt class="tit"> <label for="deny_servicer_keywords">禁止的服务商关键字</label> </dt>
<dd class="opt">
<textarea name="deny_servicer_keywords" id="deny_servicer_keywords" class="input-txt" rows="4" cols="60">{$info['deny_servicer_keywords']|default=''}</textarea>
<span class="err"></span>
<p class="notic2 red" id="deny_servicer_keywords_tips">在此输入禁止查询的服务商名称包含的关键字,多个关键字用逗号分隔。留空表示不禁止任何服务商查询。</p>
</dd>
</dl>
<div class="row" style="margin: 15px 0; padding: 10px; background-color: #f8f9fa; border-radius: 4px;">
<div class="tit" style="font-weight: bold; margin-bottom: 10px;">规则说明:</div>
<div class="opt">
<p>1. 当"允许查询"为空时:可以查询所有应用</p>
<p>2. 当"允许查询"有内容时:只能查询应用名称包含这些关键字的应用</p>
<p>3. 当"禁止查询"有内容时:不能查询应用名称包含这些关键字的应用</p>
<p>1. 当"允许查询"为空时:可以查询所有应用或服务商</p>
<p>2. 当"允许查询"有内容时:只能查询应用或服务商名称包含这些关键字的记录</p>
<p>3. 当"禁止查询"有内容时:不能查询应用或服务商名称包含这些关键字的记录</p>
<p>4. 优先级:禁止查询 > 允许查询</p>
<p>5. 应用关键字和对应的服务商关键字分别独立生效</p>
</div>
</div>
<div class="row" style="margin: 15px 0; padding: 10px; background-color: #f8f9fa; border-radius: 4px;">
<div class="tit" style="font-weight: bold; margin-bottom: 10px;">示例说明:</div>
<div class="opt">
<p>- 设置"允许查询"为"电商,金融,教育":只能查询应用名称包含这些关键字的应用</p>
<p>- 设置"禁止查询"为"测试,临时":不能查询应用名称包含这些关键字的应用</p>
<p>- 设置应用"允许查询"为"电商,金融,教育":只能查询应用名称包含这些关键字的应用</p>
<p>- 设置应用"禁止查询"为"测试,临时":不能查询应用名称包含这些关键字的应用</p>
<p>- 设置服务商"允许查询"为"华东,华南":只能查询服务商名称包含这些关键字的服务商</p>
<p>- 设置服务商"禁止查询"为"测试中心,临时":不能查询服务商名称包含这些关键字的服务商</p>
<p>- 同时设置:允许"正式,生产",禁止"测试":可以查询包含"正式"或"生产"关键字的应用,但排除包含"测试"关键字的应用</p>
</div>
</div>

View File

@@ -59,21 +59,21 @@
<th abbr="password" axis="col3" style="width: 15%">
<div class="tc">查询密码</div>
</th>
<th abbr="allow_keywords" axis="col4" style="width: 20%">
<div class="tc">允许查询的关键字</div>
<th abbr="allow_keywords" axis="col4" style="width: 15%">
<div class="tc">允许查询的应用关键字</div>
</th>
<th abbr="deny_keywords" axis="col4" style="width: 20%">
<div class="tc">禁止查询的关键字</div>
<th abbr="deny_keywords" axis="col4" style="width: 15%">
<div class="tc">禁止查询的应用关键字</div>
</th>
<th abbr="status" axis="col4" class="" style="width: 10%">
<th abbr="allow_servicer_keywords" axis="col4" style="width: 15%">
<div class="tc">允许查询的服务商关键字</div>
</th>
<th abbr="deny_servicer_keywords" axis="col4" style="width: 15%">
<div class="tc">禁止查询的服务商关键字</div>
</th>
<th abbr="status" axis="col4" class="" style="width: 15%">
<div class="tc">状态</div>
</th>
<th abbr="createtime" axis="col4" style="width: 15%">
<div class="tc">创建时间</div>
</th>
<th abbr="updatetime" axis="col4" style="width: 15%">
<div class="tc">更新时间</div>
</th>
<th axis="col1" style="width: 15%">
<div class="tc">操作</div>
</th>
@@ -97,13 +97,19 @@
<td abbr="password" axis="col3" style="width: 15%">
<div class="tc">{$vo.password}</div>
</td>
<td abbr="allow_keywords" axis="col4" style="width: 20%">
<td abbr="allow_keywords" axis="col4" style="width: 15%">
<div class="tc">{$vo.allow_keywords|default='所有'}</div>
</td>
<td abbr="deny_keywords" axis="col4" style="width: 20%">
<td abbr="deny_keywords" axis="col4" style="width: 15%">
<div class="tc">{$vo.deny_keywords|default='无'}</div>
</td>
<td abbr="status" axis="col4" class="" style="width: 10%">
<td abbr="allow_servicer_keywords" axis="col4" style="width: 15%">
<div class="tc">{$vo.allow_servicer_keywords|default='所有'}</div>
</td>
<td abbr="deny_servicer_keywords" axis="col4" style="width: 15%">
<div class="tc">{$vo.deny_servicer_keywords|default='无'}</div>
</td>
<td abbr="status" axis="col4" class="" style="width: 15%">
<div class="tc">
{if condition="$vo.status eq 1"}
<span class="yes" onclick="changeStatus(this, {$vo.id}, 0);">启用</span>
@@ -112,12 +118,6 @@
{/if}
</div>
</td>
<td abbr="createtime" axis="col4" style="width: 15%">
<div class="tc">{$vo.createtime|date='Y-m-d H:i:s',###}</div>
</td>
<td abbr="updatetime" axis="col4" style="width: 15%">
<div class="tc">{$vo.updatetime|date='Y-m-d H:i:s',###|default='无'}</div>
</td>
<td axis="col1" style="width: 15%">
<div style="text-align: center">
<a data-href="{:url('Project/password_add',array('id'=>$vo['id']))}" data-closereload="1" onclick="openFullframe(this, '编辑', '100%', '100%');" class="btn blue">编辑</a>

View File

@@ -1138,14 +1138,46 @@ class Ajax extends Base
public function projectsearch()
{
$type = intval(input('type'));
if ($type == 1) {//服务商
$item = Db::name('service')->where(['name' => input('realname')])->find();
$password = input('password'); // 获取密码
if ($item) {
echo json_encode(array('code' => 1, 'msg' => '操作成功', 'img' => $item['qrcode']));
// 检查密码是否在数据库中且状态为启用
$password_check = Db::name('query_password')->where(['password' => $password, 'status' => 1])->find();
if (!$password_check) {
echo json_encode(array('code' => -1, 'msg' => '密码无效或无权限'));
exit;
}
// ------------------------------------------
// ---------------- 服务商查询 ----------------
// ------------------------------------------
if ($type == 1) {//服务商
$keyword = input('realname'); // 关键字
// 从查询密码中获得允许的服务商关键字和禁止的服务商关键字, 都转换成数组
// 处理空字符串情况,将其转换为空数组
$allow_keywords = trim($password_check['allow_servicer_keywords']) === '' ? [] : explode(',', $password_check['allow_servicer_keywords']);
$deny_keywords = trim($password_check['deny_servicer_keywords']) === '' ? [] : explode(',', $password_check['deny_servicer_keywords']);
if (!empty($allow_keywords) && !in_array($keyword, $allow_keywords)) {
echo json_encode(array('code' => -1, 'msg' => '您没有该关键词的查询权限,请联系数据安全管理员'));
exit;
} elseif (!empty($deny_keywords) && in_array($keyword, $deny_keywords)) {
echo json_encode(array('code' => -1, 'msg' => '您没有该关键词的查询权限,请联系数据安全管理员'));
exit;
}
// SQL 查询
$where = [];
$where['name'] = ['like', '%' . $keyword . '%'];
$item_list = Db::name('service')->where($where)->select();
if (!empty($item_list)) {
// 获得其他服务商的名称
$service_names = array_column($item_list, 'name');
$item_counts = count($item_list);
echo json_encode(array('code' => 1, 'msg' => '操作成功', 'img' => $item_list[0]['qrcode'], 'service_names' => $service_names, 'counts' => $item_counts, 'keyword' => $keyword));
} else {
echo json_encode(array('code' => 0, 'msg' => '不存在'));
}
}
exit;
}
@@ -1154,79 +1186,72 @@ class Ajax extends Base
// ---------------- 项目/应用查询 ----------------
// ------------------------------------------
$keyword = input('keyword'); // 关键字
$password = input('password'); // 获取密码
$matchType = input('match_type', 1); // 匹配类型,默认为完全匹配
// 检查密码是否在数据库中
$password_check = Db::name('project_query_password')->where(['password' => $password])->find();
if (!$password_check) {
echo json_encode(array('code' => -1, 'msg' => '密码无效或无权限'));
// 检查关键字与应用名称是否存在匹配
// 应用名称与关键字有几种匹配情况
// 1. 完全匹配
// 2. 包含匹配
// 3. 前缀匹配
// 4. 后缀匹配
// 根据匹配类型构建查询条件
$where = [];
switch ($matchType) {
case 1: // 完全匹配
$where['name'] = $keyword;
break;
case 2: // 包含匹配
$where['name'] = ['like', '%' . $keyword . '%'];
break;
case 3: // 前缀匹配
$where['name'] = ['like', $keyword . '%'];
break;
case 4: // 后缀匹配
$where['name'] = ['like', '%' . $keyword];
break;
default: // 默认完全匹配
$where['name'] = $keyword;
}
// 查询匹配的应用列表
// $item_list = Db::name('project')->where($where)->select();
$item_list = Db::name('project')->where($where)->select();
$count = count($item_list);
$infoArray = array('name' => $keyword, 'match_type' => $matchType, 'count' => $count);
// 如果匹配的应用列表为空
if (empty($item_list)) {
echo json_encode(array_merge(array('code' => -2, 'msg' => '项目/应用不存在,可以申请'), $infoArray));
exit;
}
// 从查询密码中获得允许的关键字和禁止的关键字, 都转换成数组
// 处理空字符串情况,将其转换为空数组
$allow_keywords = trim($password_check['allow_keywords']) === '' ? [] : explode(',', $password_check['allow_keywords']);
$deny_keywords = trim($password_check['deny_keywords']) === '' ? [] : explode(',', $password_check['deny_keywords']);
// 检查关键字是否在允许列表中,或者是否在禁止列表中
$find = true;
if (!empty($allow_keywords) && !in_array($keyword, $allow_keywords)) {
echo json_encode(array('code' => -1, 'msg' => '您没有该关键词的查询权限,请联系数据安全管理员'));
exit;
$find = false;
} elseif (!empty($deny_keywords) && in_array($keyword, $deny_keywords)) {
echo json_encode(array('code' => -1, 'msg' => '您没有该关键词的查询权限,请联系数据安全管理员'));
exit;
$find = false;
}
// 如果找到匹配的应用
if ($find) {
$item = $item_list[0];
echo json_encode(array_merge(array('code' => 1, 'msg' => '项目/应用存在', 'img' => $item['qrcode']), $infoArray));
exit;
} else {
// 检查关键字与应用名称是否存在匹配
// 应用名称与关键字有几种匹配情况
// 1. 完全匹配
// 2. 包含匹配
// 3. 前缀匹配
// 4. 后缀匹配
// 根据匹配类型构建查询条件
$where = [];
switch ($matchType) {
case 1: // 完全匹配
$where['name'] = $keyword;
break;
case 2: // 包含匹配
$where['name'] = ['like', '%' . $keyword . '%'];
break;
case 3: // 前缀匹配
$where['name'] = ['like', $keyword . '%'];
break;
case 4: // 后缀匹配
$where['name'] = ['like', '%' . $keyword];
break;
default: // 默认完全匹配
$where['name'] = $keyword;
}
// 查询匹配的应用列表
// $item_list = Db::name('project')->where($where)->select();
$item_list = Db::name('project')->where($where)->select();
$count = count($item_list);
$infoArray = array('name' => $keyword, 'match_type' => $matchType, 'count' => $count);
// 如果匹配的应用列表为空
if (empty($item_list)) {
echo json_encode(array_merge(array('code' => -2, 'msg' => '项目/应用不存在,可以申请'), $infoArray));
exit;
}
// 从查询密码中获得允许的关键字和禁止的关键字, 都转换成数组
// 处理空字符串情况,将其转换为空数组
$allow_keywords = trim($password_check['allow_keywords']) === '' ? [] : explode(',', $password_check['allow_keywords']);
$deny_keywords = trim($password_check['deny_keywords']) === '' ? [] : explode(',', $password_check['deny_keywords']);
// 检查关键字是否在允许列表中,或者是否在禁止列表中
$find = true;
if (!empty($allow_keywords) && !in_array($keyword, $allow_keywords)) {
// echo json_encode(array('code'=>-1,'msg'=>'关键字不在允许列表中'));exit;
$find = false;
} elseif (!empty($deny_keywords) && in_array($keyword, $deny_keywords)) {
// echo json_encode(array('code'=>-1,'msg'=>'关键字在禁止列表中'));exit;
$find = false;
}
// 如果找到匹配的应用
if ($find) {
$item = $item_list[0];
echo json_encode(array_merge(array('code' => 1, 'msg' => '项目/应用存在', 'img' => $item['qrcode']), $infoArray));
exit;
} else {
echo json_encode(array_merge(array('code' => -2, 'msg' => '项目/应用不存在,可以申请'), $infoArray));
exit;
}
echo json_encode(array_merge(array('code' => -2, 'msg' => '项目/应用不存在,可以申请'), $infoArray));
exit;
}
}
}

View File

@@ -19,84 +19,276 @@
{eyou:static file="users/skin/js/global.js" /}
</head>
<style>
.header_title{
margin-bottom: 50px;
font-size: 24px;
font-weight: 600;
color: #bd2a15;
/* 美化后的样式 */
.container-wrapper {
max-width: 600px;
margin: 60px auto 0;
}
.sys_header{
margin-top: 60px;
.search-container {
padding: 40px;
background: #fff;
border-radius: 10px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
text-align: center;
}
.header_search{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-bottom: 30px;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.header_search span{
display: block;
margin-right: 20px;
width: 100px;
height: 50px;
line-height: 50px;
text-align: right;
font-size: 17px;
.header_title {
margin-bottom: 30px;
font-size: 28px;
font-weight: 600;
color: #333;
position: relative;
padding-bottom: 15px;
}
.header_search input{
width: 600px;
height: 50px;
padding-left: 15px;
font-size: 17px;
.header_title:after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 3px;
background: #bd2a15;
border-radius: 3px;
}
.form-group {
margin-bottom: 25px;
text-align: left;
}
.form-label {
display: block;
margin-bottom: 8px;
font-size: 16px;
font-weight: 500;
color: #555;
}
.form-control {
width: 100%;
padding: 14px 15px;
font-size: 16px;
color: #333;
border: 1px solid #ddd;
border-radius: 6px;
transition: all 0.3s;
box-sizing: border-box;
}
.form-control:focus {
border-color: #bd2a15;
box-shadow: 0 0 0 3px rgba(189, 42, 21, 0.1);
outline: none;
}
.search-btn {
width: 100%;
padding: 14px;
font-size: 18px;
font-weight: 600;
color: #fff;
background: #bd2a15;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s;
margin-top: 10px;
}
.search-btn:hover {
background: #a52513;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(189, 42, 21, 0.3);
}
.result-container {
padding: 30px;
background: #fff;
border-radius: 10px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
display: none;
margin-bottom: 30px;
}
.result-title {
font-size: 22px;
font-weight: 600;
color: #333;
margin-bottom: 25px;
text-align: center;
padding-bottom: 15px;
border-bottom: 1px solid #eee;
}
.result-item {
display: flex;
margin-bottom: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #f5f5f5;
}
.result-item:last-child {
margin-bottom: 0;
padding-bottom: 0;
border-bottom: none;
}
.result-label {
width: 120px;
font-weight: 600;
color: #555;
}
.result-value {
flex: 1;
color: #333;
}
.qrcode-container {
max-width: 800px;
margin: 0 auto 40px;
padding: 30px;
background: #fff;
border-radius: 10px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
text-align: center;
display: none;
}
.other-services {
margin-top: 30px;
text-align: left;
background: #f9f9f9;
border-radius: 8px;
padding: 20px;
}
.other-services h4 {
font-size: 18px;
font-weight: 600;
color: #333;
margin-bottom: 15px;
text-align: center;
}
.services-list {
list-style-type: none;
padding: 0;
margin: 0;
max-height: 960px;
overflow-y: auto;
}
/* 自定义滚动条样式 */
.services-list::-webkit-scrollbar {
width: 8px;
}
.services-list::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.services-list::-webkit-scrollbar-thumb {
background: #bd2a15;
border-radius: 4px;
}
.services-list::-webkit-scrollbar-thumb:hover {
background: #a52513;
}
.service-item {
padding: 12px 15px;
border-bottom: 1px solid #eee;
display: flex;
justify-content: space-between;
align-items: center;
}
.service-item:last-child {
border-bottom: none;
}
.service-name {
font-size: 16px;
color: #333;
}
.service-tag {
font-size: 14px;
padding: 4px 10px;
border-radius: 12px;
background: #bd2a15;
color: white;
}
.service-tag.match {
background: #28a745;
}
.qrcode-img {
max-width: 100%;
height: auto;
margin-bottom: 20px;
border: 1px solid #eee;
border-radius: 8px;
}
.close-btn {
display: inline-block;
padding: 10px 25px;
font-size: 16px;
font-weight: 600;
color: #bd2a15;
background: #fff;
border: 2px solid #bd2a15;
border-radius: 30px;
cursor: pointer;
transition: all 0.3s;
}
.searchContainer{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-top: 40px;
margin-left: 120px;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.searchContainer .searchBtn{
width: 400px;
height: 50px;
line-height: 50px;
font-size: 17px;
.close-btn:hover {
background: #bd2a15;
color: #fff;
cursor: pointer;
}
.header_search botton{
display: block;
width: 100px;
height: 50px;
line-height: 50px;
text-align: center;
background: #bd2a15;
margin-left: 10px;
color: #fff;
font-size: 17px;
cursor: pointer;
.content-wrap {
background: none;
padding: 20px 0;
}
.content{
width: 100%;
.content-inner {
background: url(../template/pc/skin/images/map.png) no-repeat center 20px;
min-height: 960px;
}
.content-inner{
background:url(../template/pc/skin/images/map.png) no-repeat center 20px;
@media (max-width: 768px) {
.container-wrapper {
margin: 30px 15px;
}
.search-container,
.result-container,
.qrcode-container {
padding: 25px 20px;
}
.form-control {
padding: 12px 12px;
}
.search-btn {
padding: 12px;
font-size: 16px;
}
}
</style>
<body>
<!--头部--star-->
{eyou:include file="header.htm" /}
@@ -105,161 +297,129 @@
{eyou:include file="layui.htm" /}
<!---layui--->
<div class="content-wrap">
<div class="content-inner" style="height: 970px;">
<!-- w1200 -->
<div class="content ">
<form class="layui-form sys_header" action="" name='theForm' id="theForm" method="post" style="text-align: center;padding-top: 80px;" >
<div class="header_title" style="margin-left: -100px">服务商查询</div>
<div class="header_search"><input name="realname" placeholder="">
<botton>搜索</botton>
<div class="content-inner">
<div class="content">
<div class="container-wrapper">
<div class="search-container">
<h2 class="header_title">服务商查询</h2>
<form class="layui-form" name='theForm' id="theForm" method="post">
<div class="form-group">
<label class="form-label">关键词:</label>
<input type="text" name="realname" class="form-control" placeholder="请输入服务商名称关键词">
</div>
<div class="form-group">
<label class="form-label">查询密码:</label>
<input type="password" name="password" class="form-control" placeholder="请输入查询密码">
</div>
<input type="button" name="submit" class="search-btn" value="搜索" />
</form>
</div>
</form>
<div style="width:100%;height:100%;display: none;" id="showqrcode">
<div style="text-align: center;width: 100%;">
<img src="" id="imgs" style="width: 600px">
<div style="font-size: 50px;width: 100%;text-align: center;margin-top: 30px;">
<span style="border-radius: 50px;border: solid 2px #fff;width: 60px;padding: 4px 20px;color:#fff" id="close">x</span>
<div class="result-container" id="show">
<h3 class="result-title">查询结果</h3>
<div class="result-item">
<div class="result-label">关键词:</div>
<div class="result-value" id="name"></div>
</div>
<div class="result-item">
<div class="result-label">申请状态:</div>
<div class="result-value">可申请</div>
</div>
</div>
</div>
<div class="qrcode-container" id="showqrcode">
<h3 class="result-title">二维码</h3>
<img src="" id="imgs" class="qrcode-img">
<div class="other-services" id="otherServices">
<h4>相关服务商列表</h4>
<ul class="services-list" id="servicesList"></ul>
</div>
<button type="button" class="close-btn" id="close" style="margin-top: 20px;">关闭</button>
</div>
</div>
</div>
</div>
<script>
$('#close').click(function(){
$('#close').click(function () {
$('#showqrcode').hide();
$('#theForm').show();
})
$('.search-container').show();
})
$(function(){
$('botton').on('click',function(){
var realname = $('input[name=realname]');
var password = $('input[name=password]');
$(function () {
$('input[name=submit]').on('click', function () {
var realname = $('input[name=realname]');
var password = $('input[name=password]');
if(realname.val() == ''){
layer.msg('请输入关键词!', {time: 1500, icon: 5});
realname.focus();
return false;
}
if(password.val() == ''){
layer.msg('密码不能为空!', {time: 1500, icon: 5});
password.focus();
return false;
}
var url = "{eyou:url link='api/Ajax/projectsearch' /}";
// layer_loading('正在处理');
var data = {
realname:realname.val(),
type:1
}
console.log(data)
$.ajax({
// async:false,
url : url,
data:data,
type:'post',
dataType:'json',
success:function(res){
console.log(res)
if(0 == res.code){
layer.msg('服务商不存在', {time: 1500, icon: 5});
}else{
$('#imgs').attr('src',res.img)
$('#showqrcode').show();
$('#theForm').hide();
}
/* layer.alert(res.msg, {icon: 1, title: false, closeBtn: false},function(){
//window.location.href = res.url;
// $('#showqrcode').show();
// layer.closeAll();
});*/
/* if (1 == res.code) {
if (5 == res.data.status) {
layer.alert(res.msg, {icon: 5, title: false, closeBtn: false},function(){
window.location.href = res.url;
});
}else{
window.location.href = res.url;
}
} else {
layer.closeAll();
if ('vertify' == res.data.status) {
fleshVerify();
}
if (2 == res.data.status) {
showErrorAlert(res.msg, 4);
} else {
layer.msg(res.msg, {icon: 5,time: 1500});
}
}*/
},
error:function(e) {
layer.closeAll();
showErrorAlert(e.responseText);
if (realname.val() == '') {
layer.msg('请输入关键词!', { time: 1500, icon: 5 });
realname.focus();
return false;
}
if (password.val() == '') {
layer.msg('密码不能为空!', { time: 1500, icon: 5 });
password.focus();
return false;
}
var url = "{eyou:url link='api/Ajax/projectsearch' /}";
// layer_loading('正在处理');
var data = {
realname: realname.val(),
password: password.val(),
type: 1
}
// 发送Ajax请求
$.ajax({
// async:false,
url: url,
data: data,
type: 'post',
dataType: 'json',
success: function (res) {
if (res.code < 0) {
layer.msg(res.msg, { time: 1500, icon: 5 });
} else if (0 == res.code) {
layer.msg('服务商不存在', { time: 1500, icon: 5 });
} else {
$('#imgs').attr('src', res.img)
// 显示其他服务商列表
if (res.service_names && res.service_names.length > 0) {
var servicesHtml = '';
for (var i = 0; i < res.service_names.length; i++) {
servicesHtml += '<li class="service-item">';
servicesHtml += '<span class="service-name">' + res.service_names[i] + '</span>';
servicesHtml += '<span class="service-tag ' + (i === 0 ? 'match' : '') + '">' + (i === 0 ? '匹配项' : '相关项') + '</span>';
servicesHtml += '</li>';
}
$('#servicesList').html(servicesHtml);
$('#otherServices').show();
} else {
$('#servicesList').html('<li class="service-item" style="justify-content: center; color: #999;">暂无其他相关服务商</li>');
$('#otherServices').show();
}
$('#showqrcode').show();
$('#theForm').hide();
$('.search-container').hide();
}
},
error: function (e) {
layer.closeAll();
showErrorAlert(e.responseText);
}
});
});
});
});
/* layui.use(['table','form','upload','util','laydate','laypage',], function() {
var table = layui.table,form = layui.form,laydate = layui.laydate, $ = layui.jquery,upload = layui.upload,util = layui.util;
var laypage = layui.laypage
//监听搜索
form.on('submit(demo1)', function(data){
var field = data.field;
layer.alert(JSON.stringify(data.field), {
title: '最终的提交信息'
})
//return false;
var url = "{eyou:url link='api/Ajax/projectsearch' /}";
console.log(url)
// return false;
$.ajax({
// async:false,
url : url,
data: {},
type:'post',
dataType:'json',
success:function(res){
if (1 == res.code) {
if (5 == res.data.status) {
layer.alert(res.msg, {icon: 5, title: false, closeBtn: false},function(){
window.location.href = res.url;
});
}else{
window.location.href = res.url;
}
} else {
layer.closeAll();
if ('vertify' == res.data.status) {
fleshVerify();
}
if (2 == res.data.status) {
showErrorAlert(res.msg, 4);
} else {
layer.msg(res.msg, {icon: 5,time: 1500});
}
}
},
error:function(e) {
layer.closeAll();
showErrorAlert(e.responseText);
}
});
});
});*/
</script>
<!--底部-star-->
{eyou:include file="footer.htm" /}
<!--底部--end-->