chore: 优化用户查询界面

This commit is contained in:
2025-12-18 14:05:16 +08:00
parent a845a91269
commit da924ee75f
2 changed files with 393 additions and 263 deletions

View File

@@ -20,7 +20,8 @@ class Ajax extends Base
/*
* 初始化操作
*/
public function _initialize() {
public function _initialize()
{
parent::_initialize();
}
@@ -144,8 +145,7 @@ class Ajax extends Base
$arcmulti_db = Db::name('arcmulti');
$arcmultiRow = $arcmulti_db->where(['tagid' => $tagidmd5])->find();
if(!empty($arcmultiRow) && !empty($arcmultiRow['querysql']))
{
if (!empty($arcmultiRow) && !empty($arcmultiRow['querysql'])) {
// arcpagelist标签属性pagesize优先级高于arclist标签属性pagesize
if (0 < intval($pagesize)) {
$arcmultiRow['pagesize'] = $pagesize;
@@ -236,7 +236,7 @@ class Ajax extends Base
if ('login' == $type) {
if (!empty($users_id)) {
$currentstyle = input('param.currentstyle/s');
$users = M('users')->field('username,nickname,head_pic')
$users = M('users')->field('keyword,nickname,head_pic')
->where([
'users_id' => $users_id,
'lang' => $this->home_lang,
@@ -244,7 +244,7 @@ class Ajax extends Base
if (!empty($users)) {
$nickname = $users['nickname'];
if (empty($nickname)) {
$nickname = $users['username'];
$nickname = $users['keyword'];
}
$head_pic = get_head_pic(htmlspecialchars_decode($users['head_pic']));
$users['head_pic'] = func_preg_replace(['http://thirdqq.qlogo.cn'], ['https://thirdqq.qlogo.cn'], $head_pic);
@@ -273,27 +273,21 @@ class Ajax extends Base
}
}
$this->success('请先登录', null, ['ey_is_login' => 0]);
}
else if ('reg' == $type)
{
} else if ('reg' == $type) {
if (!empty($users_id)) {
$users['ey_is_login'] = 1;
} else {
$users['ey_is_login'] = 0;
}
$this->success('请求成功', null, $users);
}
else if ('logout' == $type)
{
} else if ('logout' == $type) {
if (!empty($users_id)) {
$users['ey_is_login'] = 1;
} else {
$users['ey_is_login'] = 0;
}
$this->success('请求成功', null, $users);
}
else if ('cart' == $type)
{
} else if ('cart' == $type) {
if (!empty($users_id)) {
$users['ey_is_login'] = 1;
$users['ey_cart_num_20191212'] = Db::name('shop_cart')->where(['users_id' => $users_id])->sum('product_num');
@@ -474,14 +468,16 @@ class Ajax extends Base
$post = input('post.');
$source = !empty($post['source']) ? $post['source'] : 0;
if (isset($post['scene']) && in_array($post['scene'], [5, 6])) {
if (empty($post['mobile'])) return false;
if (empty($post['mobile']))
return false;
/*发送并返回结果*/
$data = $post['data'];
//兼容原先消息通知的发送短信的逻辑
//查询消息通知模板的内容
$sms_type = tpCache('sms.sms_type') ?: 1;
$tpl_content = Db::name('sms_template')->where(["send_scene" => $post['scene'], "sms_type" => $sms_type])->value('tpl_content');
if (!$tpl_content) return false;
if (!$tpl_content)
return false;
$preg_res = preg_match('/订单/', $tpl_content);
switch ($data['type']) {
case '1':
@@ -507,24 +503,30 @@ class Ajax extends Base
}
$mobile = !empty($post['mobile']) ? $post['mobile'] : session('mobile');
$is_mobile = !empty($post['is_mobile']) ? $post['is_mobile'] : false;
if (empty($mobile)) $this->error('请先绑定手机号码');
if (empty($mobile))
$this->error('请先绑定手机号码');
if ('true' === $is_mobile) {
/*是否存在手机号码*/
$where = [
'mobile' => $mobile
];
$users_id = session('users_id');
if (!empty($users_id)) $where['users_id'] = ['NEQ', $users_id];
if (!empty($users_id))
$where['users_id'] = ['NEQ', $users_id];
$Result = Db::name('users')->where($where)->count();
/* END */
if (0 == $post['source']) {
if (!empty($Result)) $this->error('手机号码已注册');
if (!empty($Result))
$this->error('手机号码已注册');
} else if (2 == $post['source']) {
if (empty($Result)) $this->error('手机号码未注册');
if (empty($Result))
$this->error('手机号码未注册');
} else if (4 == $post['source']) {
if (empty($Result)) $this->error('手机号码不存在');
if (empty($Result))
$this->error('手机号码不存在');
} else {
if (!empty($Result)) $this->error('手机号码已存在');
if (!empty($Result))
$this->error('手机号码已存在');
}
}
@@ -538,14 +540,17 @@ class Ajax extends Base
];
$Result = Db::name('sms_log')->where($where)->order('id desc')->count();
if (!empty($Result) && false == config('sms_debug')) $this->error('120秒内只能发送一次');
if (!empty($Result) && false == config('sms_debug'))
$this->error('120秒内只能发送一次');
/* END */
/*图形验证码判断*/
if (!empty($post['IsVertify']) || (isset($post['type']) && in_array($post['type'], ['users_mobile_reg', 'users_mobile_login']))) {
if (empty($post['vertify'])) $this->error('请输入图形验证码!');
if (empty($post['vertify']))
$this->error('请输入图形验证码!');
$verify = new \think\Verify();
if (!$verify->check($post['vertify'], $post['type'])) $this->error('图形验证码错误!', null, ['code'=>'vertify']);
if (!$verify->check($post['vertify'], $post['type']))
$this->error('图形验证码错误!', null, ['code' => 'vertify']);
}
/* END */
@@ -913,7 +918,8 @@ class Ajax extends Base
$count = Db::name('users_notice_read')
->where(['id' => $id])
->value("id");
if (empty($count)) $this->error('未知错误!');
if (empty($count))
$this->error('未知错误!');
//未读消息数-1
$unread_num = Db::name('users')->where(['users_id' => $users_id])->value("unread_notice_num");
@@ -1126,28 +1132,101 @@ class Ajax extends Base
abort(404);
}
}
//add lucky 查询项目
public function projectsearch(){
//add lucky 查询项目/应用/服务商
public function projectsearch()
{
$type = intval(input('type'));
if ($type == 1) {//服务商
$item = Db::name('service')->where(['name' => input('realname')])->find();
}else{
$item = Db::name('project')->where(['name'=>input('username')])->find();
if ($item) {
if(input('password') != "123123"){
echo json_encode(array('code'=>-1,'msg'=>'项目存在,密码错误'));exit;
}
echo json_encode(array('code' => 1, 'msg' => '操作成功', 'img' => $item['qrcode']));
} else {
echo json_encode(array('code'=>0,'msg'=>'项目不存在','name'=>input('username')));exit;
}
echo json_encode(array('code' => 0, 'msg' => '不存在'));
}
if($item){//用户存在
echo json_encode(array('code'=>1,'msg'=>'操作成功','img'=>$item['qrcode']));exit;
exit;
}
// ------------------------------------------
// ---------------- 项目/应用查询 ----------------
// ------------------------------------------
$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' => '密码无效或无权限'));
exit;
} else {
echo json_encode(array('code'=>0,'msg'=>'不存在'));exit;
// 检查关键字与应用名称是否存在匹配
// 应用名称与关键字有几种匹配情况
// 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;
}
}
}
}

View File

@@ -200,7 +200,9 @@
margin: 30px 15px;
}
.search-container, .result-container, .qrcode-container {
.search-container,
.result-container,
.qrcode-container {
padding: 25px 20px;
}
@@ -214,6 +216,7 @@
}
}
</style>
<body>
<!--头部--star-->
{eyou:include file="header.htm" /}
@@ -226,15 +229,24 @@
<div class="content">
<div class="container-wrapper">
<div class="search-container">
<h2 class="header_title">原生应用查询</h2>
<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="username" class="form-control" placeholder="请输入关键词">
<input type="text" name="keyword" class="form-control" placeholder="请输入您要查询的名称关键词">
</div>
<div class="form-group">
<label class="form-label">查询密码:</label>
<input type="password" name="password" class="form-control" placeholder="请输入查询密码">
<input type="password" name="password" class="form-control" placeholder="请输入您的查询密码">
</div>
<div class="form-group">
<label class="form-label">请选择应用名称的匹配方式:</label>
<select name="match_type" class="form-control">
<option value="1">名称完全等于关键词</option>
<option value="2">名称包含关键词</option>
<option value="3">名称前缀包含关键词</option>
<option value="4">名称后缀包含关键词</option>
</select>
</div>
<input type="button" name="submit" class="search-btn" value="搜索" />
</form>
@@ -243,12 +255,12 @@
<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 class="result-label">关键词</div>
<div class="result-value" id="keyword_search"></div>
</div>
<div class="result-item">
<div class="result-label">已使用:</div>
<div class="result-value" id="used"></div>
<div class="result-value" id="keyword_used"></div>
</div>
<div class="result-item">
<div class="result-label">申请状态:</div>
@@ -260,6 +272,18 @@
<div class="qrcode-container" id="showqrcode">
<h3 class="result-title">二维码</h3>
<img src="" id="imgs" class="qrcode-img">
<div class="result-item">
<div class="result-label">查询关键词:</div>
<div class="result-value" id="qr_keyword_search"></div>
</div>
<div class="result-item">
<div class="result-label">查询方式:</div>
<div class="result-value" id="qr_match_type"></div>
</div>
<div class="result-item">
<div class="result-label">已被使用:</div>
<div class="result-value" id="qr_keyword_used"></div>
</div>
<button type="button" class="close-btn" id="close">关闭</button>
</div>
</div>
@@ -274,13 +298,19 @@
})
$(function () {
// 页面加载时设置默认值
// 如果没有选中任何值,则设置为默认的完全匹配(1)
var selectedValue = $('select[name=match_type]').val();
if (!selectedValue) {
$('select[name=match_type]').val(1);
}
$('input[name=submit]').on('click', function () {
var username = $('input[name=username]');
var keyword = $('input[name=keyword]');
var password = $('input[name=password]');
if(username.val() == ''){
if (keyword.val() == '') {
layer.msg('关键词不能为空!', { time: 1500, icon: 5 });
username.focus();
keyword.focus();
return false;
}
@@ -291,14 +321,31 @@
}
var data = {
username:username.val(),
keyword: keyword.val(),
password: password.val(),
match_type: $('select[name=match_type]').val(),
type: 0
}
var url = "{eyou:url link='api/Ajax/projectsearch' /}";
$('#show').hide();
// 根据匹配类型获取匹配类型名称
function getMatchTypeName(type) {
switch (type) {
case '1':
return '名称完全等于关键词';
case '2':
return '名称包含关键词';
case '3':
return '名称的前缀包含关键词';
case '4':
return '名称的后缀包含关键词';
default:
return '未知匹配方式';
}
}
$.ajax({
url: url,
data: data,
@@ -311,11 +358,15 @@
layer.msg(res.msg, { time: 1500, icon: 5 });
} else {
$('#show').show();
$('#name').html(res.name);
$('#keyword_search').html(res.name);
$('#keyword_used').html(res.count);
}
} else {
$('.search-container').hide();
$('#imgs').attr('src', res.img);
$('#qr_keyword_search').html(res.name);
$('#qr_keyword_used').html(`${res.count}`);
$('#qr_match_type').html(getMatchTypeName(res.match_type));
$('#showqrcode').show();
}
},