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();
}
@@ -31,7 +32,7 @@ class Ajax extends Base
{
if (IS_AJAX) {
$pid = input('pid/d', 0);
$res = Db::name('region')->where('parent_id',$pid)->select();
$res = Db::name('region')->where('parent_id', $pid)->select();
$this->success('请求成功', null, $res);
}
}
@@ -48,11 +49,11 @@ class Ajax extends Base
if ($aid > 0) {
$archives_db = Db::name('archives');
if ('view' == $type) {
$archives_db->where(array('aid'=>$aid))->setInc('click');
$archives_db->where(array('aid' => $aid))->setInc('click');
}
$click = $archives_db->where(array('aid'=>$aid))->getField('click');
$click = $archives_db->where(array('aid' => $aid))->getField('click');
}
echo($click);
echo ($click);
exit;
} else {
abort(404);
@@ -69,9 +70,9 @@ class Ajax extends Base
$downcount = 0;
$aid = input('aid/d', 0);
if ($aid > 0) {
$downcount = Db::name('archives')->where(array('aid'=>$aid))->getField('downcount');
$downcount = Db::name('archives')->where(array('aid' => $aid))->getField('downcount');
}
echo($downcount);
echo ($downcount);
exit;
} else {
abort(404);
@@ -88,9 +89,9 @@ class Ajax extends Base
$collectnum = 0;
$aid = input('aid/d', 0);
if ($aid > 0) {
$collectnum = Db::name('users_collection')->where(array('aid'=>$aid))->count();
$collectnum = Db::name('users_collection')->where(array('aid' => $aid))->count();
}
echo($collectnum);
echo ($collectnum);
exit;
} else {
abort(404);
@@ -107,9 +108,9 @@ class Ajax extends Base
$unread_notice_num = 0;
$users_id = session('users_id');
if ($users_id > 0) {
$unread_notice_num = Db::name('users')->where(array('users_id'=>$users_id))->value('unread_notice_num');
$unread_notice_num = Db::name('users')->where(array('users_id' => $users_id))->value('unread_notice_num');
}
echo($unread_notice_num);
echo ($unread_notice_num);
exit;
} else {
abort(404);
@@ -129,8 +130,8 @@ class Ajax extends Base
$pagesize = input('pagesize/d', 0);
$tagid = input('tagid/s', '');
$tagidmd5 = input('tagidmd5/s', '');
!empty($tagid) && $tagid = preg_replace("/[^a-zA-Z0-9-_]/",'', $tagid);
!empty($tagidmd5) && $tagidmd5 = preg_replace("/[^a-zA-Z0-9_]/",'', $tagidmd5);
!empty($tagid) && $tagid = preg_replace("/[^a-zA-Z0-9-_]/", '', $tagid);
!empty($tagidmd5) && $tagidmd5 = preg_replace("/[^a-zA-Z0-9_]/", '', $tagidmd5);
if (empty($tagid) || empty($pnum) || empty($tagidmd5)) {
$this->error('参数有误');
@@ -143,9 +144,8 @@ class Ajax extends Base
];
$arcmulti_db = Db::name('arcmulti');
$arcmultiRow = $arcmulti_db->where(['tagid'=>$tagidmd5])->find();
if(!empty($arcmultiRow) && !empty($arcmultiRow['querysql']))
{
$arcmultiRow = $arcmulti_db->where(['tagid' => $tagidmd5])->find();
if (!empty($arcmultiRow) && !empty($arcmultiRow['querysql'])) {
// arcpagelist标签属性pagesize优先级高于arclist标签属性pagesize
if (0 < intval($pagesize)) {
$arcmultiRow['pagesize'] = $pagesize;
@@ -165,7 +165,7 @@ class Ajax extends Base
$queryRow = Db::query($querysql);
if (!empty($queryRow)) {
$tpl_content = '';
$filename = './template/'.THEME_STYLE_PATH.'/'.'system/arclist_'.$tagid.'.'.\think\Config::get('template.view_suffix');
$filename = './template/' . THEME_STYLE_PATH . '/' . 'system/arclist_' . $tagid . '.' . \think\Config::get('template.view_suffix');
if (!file_exists($filename)) {
$data['code'] = -1;
$data['msg'] = "模板追加文件 arclist_{$tagid}.htm 不存在!";
@@ -184,7 +184,7 @@ class Ajax extends Base
$row = intval($offset) + intval($arcmultiRow['pagesize']);
$innertext = "{eyou:arclist";
foreach ($attarray as $key => $val) {
if (in_array($key, ['tagid','offset','row'])) {
if (in_array($key, ['tagid', 'offset', 'row'])) {
continue;
}
$innertext .= " {$key}='{$val}'";
@@ -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);
@@ -272,31 +272,25 @@ class Ajax extends Base
$this->success('请求成功', null, $users);
}
}
$this->success('请先登录', null, ['ey_is_login'=>0]);
}
else if ('reg' == $type)
{
$this->success('请先登录', null, ['ey_is_login' => 0]);
} 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');
$users['ey_cart_num_20191212'] = Db::name('shop_cart')->where(['users_id' => $users_id])->sum('product_num');
} else {
$users['ey_is_login'] = 0;
$users['ey_cart_num_20191212'] = 0;
@@ -347,7 +341,7 @@ class Ajax extends Base
unset($users['paypwd']);
$dtypes = [];
foreach ($users as $key => $val) {
$html_key = md5($key.'-'.$t_uniqid);
$html_key = md5($key . '-' . $t_uniqid);
$users[$html_key] = $val;
$dtype = 'txt';
@@ -368,7 +362,7 @@ class Ajax extends Base
];
$this->success('请求成功', null, $data);
}
$this->success('请先登录', null, ['ey_is_login'=>0]);
$this->success('请先登录', null, ['ey_is_login' => 0]);
}
$this->error('访问错误');
}
@@ -383,7 +377,7 @@ class Ajax extends Base
$captchaArr = array_keys($configList);
if (in_array($type, $captchaArr)) {
/*验证码插件开关*/
$admin_login_captcha = config('captcha.'.$type);
$admin_login_captcha = config('captcha.' . $type);
$config = (!empty($admin_login_captcha['is_on']) && !empty($admin_login_captcha['config'])) ? $admin_login_captcha['config'] : config('captcha.default');
/*--end*/
} else {
@@ -421,12 +415,12 @@ class Ajax extends Base
$web_name = tpCache('web.web_name');
// 判断标题拼接
$arctype = M('arctype')->field('typename')->find($tid);
$web_name = $arctype['typename'].'-'.$web_name;
$web_name = $arctype['typename'] . '-' . $web_name;
// 拼装发送的字符串内容
$row = M('guestbook_attribute')->field('a.attr_name, b.attr_value')
->alias('a')
->join('__GUESTBOOK_ATTR__ b', 'a.attr_id = b.attr_id AND a.typeid = '.$tid, 'LEFT')
->join('__GUESTBOOK_ATTR__ b', 'a.attr_id = b.attr_id AND a.typeid = ' . $tid, 'LEFT')
->where([
'b.aid' => $aid,
])
@@ -436,13 +430,13 @@ class Ajax extends Base
foreach ($row as $key => $val) {
if (preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $val['attr_value'])) {
if (!stristr($val['attr_value'], '|')) {
$val['attr_value'] = $this->request->domain().handle_subdir_pic($val['attr_value']);
$val['attr_value'] = "<a href='".$val['attr_value']."' target='_blank'><img src='".$val['attr_value']."' width='150' height='150' /></a>";
$val['attr_value'] = $this->request->domain() . handle_subdir_pic($val['attr_value']);
$val['attr_value'] = "<a href='" . $val['attr_value'] . "' target='_blank'><img src='" . $val['attr_value'] . "' width='150' height='150' /></a>";
}
} else {
$val['attr_value'] = str_replace(PHP_EOL, ' | ', $val['attr_value']);
}
$content .= $val['attr_name'] . '' . $val['attr_value'].'<br/>';
$content .= $val['attr_name'] . '' . $val['attr_value'] . '<br/>';
}
$html = "<p style='text-align: left;'>{$web_name}</p><p style='text-align: left;'>{$content}</p>";
if (isMobile()) {
@@ -452,7 +446,7 @@ class Ajax extends Base
}
// 发送邮件
$res = send_email(null,null,$html, $scene);
$res = send_email(null, null, $html, $scene);
if (intval($res['code']) == 1) {
$this->success($res['msg']);
} else {
@@ -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;
$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;
$preg_res = preg_match('/订单/', $tpl_content);
switch ($data['type']) {
case '1':
@@ -494,7 +490,7 @@ class Ajax extends Base
$content = '';
break;
}
$Result = sendSms($post['scene'], $post['mobile'], array('content'=>$content));
$Result = sendSms($post['scene'], $post['mobile'], array('content' => $content));
if (intval($Result['status']) == 1) {
$this->success('发送成功!');
} else {
@@ -502,29 +498,35 @@ class Ajax extends Base
}
/* END */
} else {
if (isset($post['type']) && in_array($post['type'], ['users_mobile_reg','users_mobile_login'])) {
if (isset($post['type']) && in_array($post['type'], ['users_mobile_reg', 'users_mobile_login'])) {
$post['is_mobile'] = 'true';
}
$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['IsVertify']) || (isset($post['type']) && in_array($post['type'], ['users_mobile_reg', 'users_mobile_login']))) {
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 */
@@ -582,7 +587,7 @@ class Ajax extends Base
$UsersDataa = Db::name('users')->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id'=>$users_id])
->where(['a.users_id' => $users_id])
->find();
if (0 == $Arcrank['arcrank']) {
if (IS_AJAX) {
@@ -590,27 +595,27 @@ class Ajax extends Base
} else {
return true;
}
}else if (-1 == $Arcrank['arcrank']) {
} else if (-1 == $Arcrank['arcrank']) {
$is_admin = session('?admin_id') ? 1 : 0;
$param_admin_id = input('param.admin_id/d');
if ($users_id == $Arcrank['users_id']) {
if (IS_AJAX) {
$this->success('允许查阅!', null, ['is_admin'=>$is_admin, 'msg'=>'待审核稿件,仅限自己查看!']);
$this->success('允许查阅!', null, ['is_admin' => $is_admin, 'msg' => '待审核稿件,仅限自己查看!']);
} else {
return true;
}
}else if(!empty($is_admin) && !empty($param_admin_id)){
} else if (!empty($is_admin) && !empty($param_admin_id)) {
if (IS_AJAX) {
$this->success('允许查阅!', null, ['is_admin'=>$is_admin, 'msg'=>'待审核稿件,仅限管理员查看!']);
$this->success('允许查阅!', null, ['is_admin' => $is_admin, 'msg' => '待审核稿件,仅限管理员查看!']);
} else {
return true;
}
}else{
} else {
$msg = '待审核稿件,你没有权限阅读!';
}
}else if ($UsersDataa['level_value'] < $Arcrank['level_value']) {
$msg = '内容需要【'.$Arcrank['level_name'].'】才可以查看,您为【'.$UsersDataa['level_name'].'】,请先升级!';
}else{
} else if ($UsersDataa['level_value'] < $Arcrank['level_value']) {
$msg = '内容需要【' . $Arcrank['level_name'] . '】才可以查看,您为【' . $UsersDataa['level_name'] . '】,请先升级!';
} else {
if (IS_AJAX) {
$this->success('允许查阅!');
} else {
@@ -622,24 +627,24 @@ class Ajax extends Base
} else {
return $msg;
}
}else{
} else {
if (0 == $Arcrank['arcrank']) {
if (IS_AJAX) {
$this->success('允许查阅!');
} else {
return true;
}
}else if (-1 == $Arcrank['arcrank']) {
} else if (-1 == $Arcrank['arcrank']) {
$is_admin = session('?admin_id') ? 1 : 0;
$param_admin_id = input('param.admin_id/d');
if (!empty($is_admin) && !empty($param_admin_id)) {
$this->success('允许查阅!', null, ['is_admin'=>$is_admin, 'msg'=>'待审核稿件,仅限管理员查看!']);
$this->success('允许查阅!', null, ['is_admin' => $is_admin, 'msg' => '待审核稿件,仅限管理员查看!']);
} else {
$msg = '待审核稿件,你没有权限阅读!';
}
}else if (!empty($Arcrank['level_name'])) {
$msg = '文章需要【'.$Arcrank['level_name'].'】才可以查看,游客不可查看,请登录!';
}else{
} else if (!empty($Arcrank['level_name'])) {
$msg = '文章需要【' . $Arcrank['level_name'] . '】才可以查看,游客不可查看,请登录!';
} else {
$msg = '游客不可查看,请登录!';
}
if (IS_AJAX) {
@@ -709,20 +714,20 @@ class Ajax extends Base
// 获取token的值http://ziyuan.baidu.com/linksubmit/index?site=http://www.eyoucms.com/
$sitemap_zzbaidutoken = config('tpcache.sitemap_zzbaidutoken');
if (empty($sitemap_zzbaidutoken)) {
$this->error('尚未配置实时推送Url的token', null, ['code'=>0]);
$this->error('尚未配置实时推送Url的token', null, ['code' => 0]);
} else if (!function_exists('curl_init')) {
$this->error('请开启php扩展curl_init', null, ['code'=>1]);
$this->error('请开启php扩展curl_init', null, ['code' => 1]);
}
$urlsArr[] = $url;
$type = ('edit' == $type) ? 'update' : 'urls';
if (is_http_url($sitemap_zzbaidutoken)) {
$searchs = ["/urls?","/update?"];
$searchs = ["/urls?", "/update?"];
$replaces = ["/{$type}?", "/{$type}?"];
$api = str_replace($searchs, $replaces, $sitemap_zzbaidutoken);
} else {
$api = 'http://data.zz.baidu.com/'.$type.'?site='.$this->request->host(true).'&token='.trim($sitemap_zzbaidutoken);
$api = 'http://data.zz.baidu.com/' . $type . '?site=' . $this->request->host(true) . '&token=' . trim($sitemap_zzbaidutoken);
}
$ch = curl_init();
@@ -780,13 +785,13 @@ class Ajax extends Base
/*是否需要付费*/
if (0 < $archivesInfo['users_price'] && empty($archivesInfo['users_free'])) {
if (empty($archivesInfo['arc_level_id'])){
if (empty($archivesInfo['arc_level_id'])) {
//不限会员 付费
$result['status_value'] = 1;
}else{
} else {
//3-限制会员 付费
$result['status_value'] = 3;
if ($archivesInfo['level_value'] <= $UsersData['level_value']){
if ($archivesInfo['level_value'] <= $UsersData['level_value']) {
$result['vip_status'] = 1;//已升级会员未购买
}
}
@@ -802,20 +807,20 @@ class Ajax extends Base
//已购买
if (!empty($Paid)) {
if (3 == $result['status_value']) {
if (1 == $result['vip_status']){
if (1 == $result['vip_status']) {
$result['play_auth'] = 1;
$result['vip_status'] = 3;//已升级会员已经购买
}else{
} else {
$result['play_auth'] = 0;
$result['vip_status'] = 2;//未升级会员已经购买
}
}else{
} else {
$result['play_auth'] = 1;
$result['vip_status'] = 4;//不限会员已经购买
}
}
}
}else{
} else {
if (0 < intval($archivesInfo['arc_level_id'])) { // 会员免费
$result['status_value'] = 2;
if (!empty($UsersID) && $archivesInfo['level_value'] <= $UsersData['level_value']) {
@@ -841,16 +846,16 @@ class Ajax extends Base
/*END*/
$is_pay = 0;
if (in_array($result['status_value'], [1,3])){ // 所有人、会员付费
if (in_array($result['status_value'], [1, 3])) { // 所有人、会员付费
$is_pay = Db::name('media_order')->where($where)->count();
}
$result['is_pay'] = $is_pay;
if (in_array($result['status_value'], [2,3])){ // 已满足会员级别要求
if (in_array($result['status_value'], [2, 3])) { // 已满足会员级别要求
$result['status_name'] = Db::name('users_level')->where('level_id', intval($archivesInfo['arc_level_id']))->value('level_name');
}
/*
/*
if (in_array($result['status_value'], [2,3])){ // 会员免费与会员付费
$result['status_name'] = Db::name('users_level')->where('level_id', $archivesInfo['arc_level_id'])->value('level_name');
$vip_status = 0;
@@ -859,30 +864,30 @@ class Ajax extends Base
}
}*/
if ($result['status_value'] == 0){
if ($result['status_value'] == 0) {
$result['button'] = '免费';
$result['status_name'] = '免费';
}else if ($result['status_value'] == 1){ // 所有人付费
} else if ($result['status_value'] == 1) { // 所有人付费
$result['button'] = '付费';
if (!empty($is_pay)){
if (!empty($is_pay)) {
$result['button'] = '观看';
}
}else if ($result['status_value'] == 2){
} else if ($result['status_value'] == 2) {
$result['button'] = 'VIP';
if (!empty($result['play_auth'])){
if (!empty($result['play_auth'])) {
$result['button'] = '观看';
}
}else if ($result['status_value'] == 3){
} else if ($result['status_value'] == 3) {
// if(1 == $result['vip_status']){
// $result['button'] = '立即购买';
// $result['button_url'] = 'MediaOrderBuy_1592878548();';
// }else
if (2 == $result['vip_status']){
if (2 == $result['vip_status']) {
$result['button'] = 'VIP';
$result['button_url'] = "window.location.href = '" . url('user/Level/level_centre') . "'";
} else if (3 == $result['vip_status']) {
$result['button'] = '观看';
}else{
} else {
$result['button'] = 'VIP付费';
$result['button_url'] = "window.location.href = '" . url('user/Level/level_centre') . "'";
}
@@ -890,7 +895,7 @@ class Ajax extends Base
// $result['button'] = '观看';
// }
}
if ('观看' == $result['button']){
if ('观看' == $result['button']) {
$result['button_url'] = arcurl('home/Media/view', $archivesInfo);
}
@@ -913,16 +918,17 @@ 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");
if ($unread_num>0){
$unread_num = $unread_num-1;
Db::name('users')->where(['users_id' => $users_id])->update(['unread_notice_num'=>$unread_num]);
if ($unread_num > 0) {
$unread_num = $unread_num - 1;
Db::name('users')->where(['users_id' => $users_id])->update(['unread_notice_num' => $unread_num]);
}
Db::name('users_notice_read')->where(['id'=>$id])->update(['is_read'=>1]);
$this->success('保存成功',null,['unread_num'=>$unread_num]);
Db::name('users_notice_read')->where(['id' => $id])->update(['is_read' => 1]);
$this->success('保存成功', null, ['unread_num' => $unread_num]);
}
}
@@ -959,7 +965,7 @@ class Ajax extends Base
'update_time' => getTime(),
]);
if (!empty($r)) {
$this->success('收藏成功', null, ['opt'=>'add']);
$this->success('收藏成功', null, ['opt' => 'add']);
}
}
} else {
@@ -967,7 +973,7 @@ class Ajax extends Base
'users_id' => $users_id,
'aid' => $aid,
])->delete();
$this->success('取消成功', null, ['opt'=>'cancel']);
$this->success('取消成功', null, ['opt' => 'cancel']);
}
$this->error('收藏失败', null);
}
@@ -993,10 +999,10 @@ class Ajax extends Base
'users_id' => $users_id,
])->count();
if (!empty($count)) {
$this->success('已收藏', null, ['total'=>$total]);
$this->success('已收藏', null, ['total' => $total]);
}
}
$this->error('未收藏', null, ['total'=>$total]);
$this->error('未收藏', null, ['total' => $total]);
}
abort(404);
}
@@ -1025,16 +1031,16 @@ class Ajax extends Base
$user_footprint_limit = config('global.user_footprint_limit');
if (!$user_footprint_limit) {
$user_footprint_limit = 20;
config('global.user_footprint_limit',$user_footprint_limit);
config('global.user_footprint_limit', $user_footprint_limit);
}
$user_footprint_record = Db::name('users_footprint')->where(['users_id'=>$users_id])->count("id");
$user_footprint_record = Db::name('users_footprint')->where(['users_id' => $users_id])->count("id");
if ($user_footprint_record == $user_footprint_limit) {
Db::name('users_footprint')->where(['users_id' => $users_id])->order("update_time ASC")->limit(1)->delete();
}elseif ($user_footprint_record > $user_footprint_limit) {
$del_count = $user_footprint_record-$user_footprint_limit+1;
} elseif ($user_footprint_record > $user_footprint_limit) {
$del_count = $user_footprint_record - $user_footprint_limit + 1;
$del_ids = Db::name('users_footprint')->field("id")->where(['users_id' => $this->users_id])->order("update_time ASC")->limit($del_count)->select();
$del_ids = get_arr_column($del_ids,'id');
Db::name('users_footprint')->where(['id' => ['IN',$del_ids]])->delete();
$del_ids = get_arr_column($del_ids, 'id');
Db::name('users_footprint')->where(['id' => ['IN', $del_ids]])->delete();
}
$arc['users_id'] = $users_id;
@@ -1076,9 +1082,9 @@ class Ajax extends Base
//今日签到信息
$now_time = time();
$today_start = mktime(0,0,0,date("m",$now_time),date("d",$now_time),date("Y",$now_time));
$today_end = mktime(23,59,59,date("m",$now_time),date("d",$now_time),date("Y",$now_time));
$row = Db::name('users_signin')->where(['users_id'=>$users_id,'add_time'=>['BETWEEN',[$today_start,$today_end]]])->value("id");
$today_start = mktime(0, 0, 0, date("m", $now_time), date("d", $now_time), date("Y", $now_time));
$today_end = mktime(23, 59, 59, date("m", $now_time), date("d", $now_time), date("Y", $now_time));
$row = Db::name('users_signin')->where(['users_id' => $users_id, 'add_time' => ['BETWEEN', [$today_start, $today_end]]])->value("id");
if (!$row) {
$r = Db::name('users_signin')->add([
@@ -1087,9 +1093,9 @@ class Ajax extends Base
'add_time' => getTime(),
]);
if (!empty($r)) {
$scores_step = $signin_conf['score_signin_score'] ?:0;
Db::name('users')->where(['users_id'=>$users_id])->setInc('scores',$scores_step);
$users_scores = Db::name('users')->where(['users_id'=>$users_id])->value("scores");
$scores_step = $signin_conf['score_signin_score'] ?: 0;
Db::name('users')->where(['users_id' => $users_id])->setInc('scores', $scores_step);
$users_scores = Db::name('users')->where(['users_id' => $users_id])->value("scores");
Db::name('users_score')->add([
'type' => 5,//每日签到
@@ -1104,7 +1110,7 @@ class Ajax extends Base
'add_time' => getTime(),
'update_time' => getTime(),
]);
$this->success('签到成功', null,['scores'=>$users_scores]);
$this->success('签到成功', null, ['scores' => $users_scores]);
}
$this->error('未知错误', null);
}
@@ -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;
}
}else{
echo json_encode(array('code'=>0,'msg'=>'项目不存在','name'=>input('username')));exit;
}
if ($type == 1) {//服务商
$item = Db::name('service')->where(['name' => input('realname')])->find();
if ($item) {
echo json_encode(array('code' => 1, 'msg' => '操作成功', 'img' => $item['qrcode']));
} else {
echo json_encode(array('code' => 0, 'msg' => '不存在'));
}
if($item){//用户存在
echo json_encode(array('code'=>1,'msg'=>'操作成功','img'=>$item['qrcode']));exit;
}else{
echo json_encode(array('code'=>0,'msg'=>'不存在'));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 {
// 检查关键字与应用名称是否存在匹配
// 应用名称与关键字有几种匹配情况
// 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

@@ -191,7 +191,7 @@
}
.content-inner {
background:url(../template/pc/skin/images/map.png) no-repeat center 20px;
background: url(../template/pc/skin/images/map.png) no-repeat center 20px;
min-height: 960px;
}
@@ -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,29 +229,38 @@
<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>
<input type="button" name="submit" class="search-btn" value="搜索"/>
<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>
</div>
<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>
@@ -267,59 +291,86 @@
</div>
<script>
$('#close').click(function(){
$('#close').click(function () {
$('#showqrcode').hide();
$('#theForm').show();
$('.search-container').show();
})
$(function(){
$('input[name=submit]').on('click',function(){
var username = $('input[name=username]');
$(function () {
// 页面加载时设置默认值
// 如果没有选中任何值,则设置为默认的完全匹配(1)
var selectedValue = $('select[name=match_type]').val();
if (!selectedValue) {
$('select[name=match_type]').val(1);
}
$('input[name=submit]').on('click', function () {
var keyword = $('input[name=keyword]');
var password = $('input[name=password]');
if(username.val() == ''){
layer.msg('关键词不能为空!', {time: 1500, icon: 5});
username.focus();
if (keyword.val() == '') {
layer.msg('关键词不能为空!', { time: 1500, icon: 5 });
keyword.focus();
return false;
}
if(password.val() == ''){
layer.msg('密码不能为空!', {time: 1500, icon: 5});
if (password.val() == '') {
layer.msg('密码不能为空!', { time: 1500, icon: 5 });
password.focus();
return false;
}
var data = {
username:username.val(),
password:password.val(),
type:0
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();
$.ajax({
url : url,
data:data,
type:'post',
dataType:'json',
success:function(res){
console.log(res);
if( res.code<=0){
if(res.code == -1){
layer.msg(res.msg, {time: 1500, icon: 5});
}else{
$('#show').show();
$('#name').html(res.name);
// 根据匹配类型获取匹配类型名称
function getMatchTypeName(type) {
switch (type) {
case '1':
return '名称完全等于关键词';
case '2':
return '名称包含关键词';
case '3':
return '名称的前缀包含关键词';
case '4':
return '名称的后缀包含关键词';
default:
return '未知匹配方式';
}
}else{
}
$.ajax({
url: url,
data: data,
type: 'post',
dataType: 'json',
success: function (res) {
console.log(res);
if (res.code <= 0) {
if (res.code == -1) {
layer.msg(res.msg, { time: 1500, icon: 5 });
} else {
$('#show').show();
$('#keyword_search').html(res.name);
$('#keyword_used').html(res.count);
}
} else {
$('.search-container').hide();
$('#imgs').attr('src',res.img);
$('#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();
}
},
error:function(e) {
error: function (e) {
layer.closeAll();
showErrorAlert(e.responseText);
}