mirror of
https://gitee.com/zhc02/timely_service.git
synced 2025-06-24 04:01:23 +08:00
core
This commit is contained in:
parent
9325d4002c
commit
d30b63abc2
@ -25,7 +25,6 @@ class Index extends Base
|
||||
$online_kefu_num=KefuLogic::kefuCount(['online_status'=>1]);
|
||||
//获取当前在线游客数量
|
||||
$online_visitor_num=Visitor::visitorCount(['online_status'=>1]);
|
||||
|
||||
//获取当天的会话次数
|
||||
$service_num=VisitorService::getServiceNum();
|
||||
$days= date('t');
|
||||
@ -34,7 +33,7 @@ class Index extends Base
|
||||
$start_time = strtotime(date('Y-m-01')); //获取本月第一天时间戳
|
||||
$date=date('Y-m-d', $start_time+$i*86400);
|
||||
$endDate=date('Y-m-d 23:59:59',strtotime($date));
|
||||
$where1[]=['create_time','between time',[$date, $endDate]];
|
||||
$where1[0]=['create_time','between time',[$date, $endDate]];
|
||||
|
||||
$service_num_list[]=[
|
||||
'date'=>$date,
|
||||
|
@ -98,7 +98,7 @@
|
||||
layer.msg('验证码不能为空');
|
||||
return false;
|
||||
}
|
||||
console.log(data);
|
||||
|
||||
$.post('/admin/Login/loginIn', data, function (res) {
|
||||
|
||||
if (res.code == 1000) {
|
||||
|
@ -14,11 +14,28 @@ use think\Controller;
|
||||
|
||||
class Base extends Controller
|
||||
{
|
||||
const SUCCESS_CODE = 1000; // 系统成功代码
|
||||
const ERROR_CODE = 1001; // 失败代码
|
||||
/**
|
||||
* @var \think\Request 请求体
|
||||
*/
|
||||
var $request;
|
||||
/**
|
||||
* @var \library\Response 响应体
|
||||
*/
|
||||
var $response;
|
||||
|
||||
/**
|
||||
* @var boolean 是否强制登录
|
||||
*/
|
||||
protected $_require_login = TRUE;
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
parent::__construct($app);
|
||||
if( !session('kefu_name')){
|
||||
return $this->redirect('login/login');
|
||||
$this->request = request();
|
||||
$this->response = new \library\Response();
|
||||
if( $this->_require_login== TRUE && !session('kefu_name')){
|
||||
return $this->redirect('login/Login');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,65 +12,51 @@ namespace app\index\controller;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
class Login extends Controller
|
||||
|
||||
class Login extends Base
|
||||
{
|
||||
protected $_require_login = false;
|
||||
|
||||
public function Login()
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function Logining()
|
||||
public function LoginIn()
|
||||
{
|
||||
|
||||
$name = input('post.name');
|
||||
$name = input('post.username');
|
||||
$password = input('post.password');
|
||||
$captcha = input('post.captcha');
|
||||
if (!captcha_check($captcha)) {
|
||||
return $this->response->api('', self::ERROR_CODE, '验证码错误');
|
||||
}
|
||||
if (empty($name)) {
|
||||
return $this->error('请输入用户名');
|
||||
return $this->response->api('', self::ERROR_CODE, '请填写客服名');
|
||||
}
|
||||
if (empty($password)) {
|
||||
return $this->error('请输入密码');
|
||||
return $this->response->api('', self::ERROR_CODE, '请填写密码');
|
||||
}
|
||||
$kefu_info = Db::name('kefu_info')->where('kefu_name', $name)->find();
|
||||
if ($kefu_info) {
|
||||
if (md5(trim($password)) != $kefu_info['kefu_password']) {
|
||||
return $this->error('密码错误');
|
||||
}
|
||||
session('kefu_name', $kefu_info['kefu_name']);
|
||||
session('kefu_code', $kefu_info['kefu_code']);
|
||||
session('kefu_avatar', $kefu_info['kefu_avatar']);
|
||||
} else {
|
||||
//同一个ip 限制注册3个账号
|
||||
$num = Cache::get(request()->ip());
|
||||
if ($num > 3) {
|
||||
return $this->error('同一ip限制注册三个账号');
|
||||
}
|
||||
|
||||
//添加客服
|
||||
$kefu_data = [
|
||||
'kefu_code' => uniqid('kefu'),
|
||||
'kefu_name' => trim($name),
|
||||
'kefu_avatar' => '/static/common/images/kefu.jpg',
|
||||
'kefu_password' => md5(trim($password)),
|
||||
'kefu_status' => 1,
|
||||
'online_status' => 0,
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
Db::name('kefu_info')->insertGetId($kefu_data);
|
||||
Db::commit();
|
||||
Cache::inc(request()->ip());
|
||||
session('kefu_name', $kefu_data['kefu_name']);
|
||||
session('kefu_code', $kefu_data['kefu_code']);
|
||||
session('kefu_avatar', $kefu_data['kefu_avatar']);
|
||||
|
||||
if (!$kefu_info) {
|
||||
return $this->response->api('', self::ERROR_CODE, '客服不存在');
|
||||
}
|
||||
if (strtoupper(md5($password)) != $kefu_info['kefu_password']) {
|
||||
return $this->response->api('', self::ERROR_CODE, '密码错误');
|
||||
}
|
||||
session('kefu_name', $kefu_info['kefu_name']);
|
||||
session('kefu_code', $kefu_info['kefu_code']);
|
||||
session( 'kefu_avatar', $kefu_info['kefu_avatar']);
|
||||
|
||||
return $this->redirect('kefu/index');
|
||||
|
||||
return $this->response->api(url('kefu/index'), self::SUCCESS_CODE, '登录成功');
|
||||
}
|
||||
public function logout(){
|
||||
session('kefu_name',null);
|
||||
|
||||
public function logout()
|
||||
{
|
||||
session('kefu_name', null);
|
||||
session('kefu_code', null);
|
||||
session('kefu_avatar', null);
|
||||
return $this->redirect('login/login');
|
||||
return $this->redirect('login/login');
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,126 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>
|
||||
<html class="loginHtml">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Timely客服登陆</title>
|
||||
<link rel="stylesheet" href="/static/common/dist/css/soho.min.css">
|
||||
<meta charset="utf-8">
|
||||
<title>Timely在线客服系统客服登录</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<link rel="stylesheet" href="/static/lib/layui-v2.5.4/css/layui.css" media="all" />
|
||||
<style>
|
||||
.loginHtml,.loginBody{ height:100%;}
|
||||
.loginBody form.layui-form{ padding:0 20px; width:300px; height:335px; position:absolute; left:50%; top:50%; margin:-150px 0 0 -150px; -webkit-box-sizing:border-box;-moz-box-sizing:border-box; -o-box-sizing:border-box; box-sizing:border-box; background:#fff;-webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; box-shadow:0 0 50px #009688;}
|
||||
.login_face{ margin:-60px auto 20px; width:100px; height:50px; -webkit-border-radius:40%; -moz-border-radius:0%; border-radius:0%; border:5px solid #fff; overflow:hidden;box-shadow:0 0 30px #009688;}
|
||||
.login_face img{ width:100%;}
|
||||
.loginBody .layui-form-item{ position:relative;}
|
||||
.loginBody .layui-form-item label{ position:absolute; color:#757575; left:10px; top:9px; line-height:20px; background:#fff; padding:0 5px; font-size:14px; cursor:text;}
|
||||
.loginBody .layui-form-item.layui-input-focus label{ top:-10px; font-size:12px; color:#ff6700;}
|
||||
.loginBody .layui-form-item.layui-input-active label{ top:-10px; font-size:12px;}
|
||||
.loginBody .layui-input::-webkit-input-placeholder{color:#fff;}
|
||||
.loginBody .layui-input::-moz-placeholder{color:#fff;}
|
||||
.loginBody .layui-input:-ms-input-placeholder{color:#fff;}
|
||||
.loginBody .layui-input::placeholder{color:#fff;}
|
||||
.loginBody .layui-form-item.layui-input-focus input{ border-color:#ff6700 !important;}
|
||||
.loginBody .layui-input-focus .layui-input::-webkit-input-placeholder{color:#757575;}
|
||||
.loginBody .layui-input-focus .layui-input::-moz-placeholder{color:#757575;}
|
||||
.loginBody .layui-input-focus .layui-input:-ms-input-placeholder{color:#757575;}
|
||||
.loginBody .layui-input-focus .layui-input::placeholder{color:#757575;}
|
||||
.loginBody .seraph{ font-size:30px; text-align:center;}
|
||||
.loginBody .seraph.icon-qq:hover{ color:#0288d1;}
|
||||
.loginBody .seraph.icon-wechat:hover{ color:#00d20d;}
|
||||
.loginBody .seraph.icon-sina:hover{ color:#d32f2f;}
|
||||
.imgCode{ position:relative;}
|
||||
#imgCode img{ position:absolute; top:1px; right:1px; cursor:pointer;}
|
||||
</style>
|
||||
</head>
|
||||
<body class="form-membership">
|
||||
<body class="loginBody">
|
||||
<form class="layui-form">
|
||||
<div class="login_face"><img src="/static/images/logo.png" class="userAvatar"></div>
|
||||
<h3 style=";font-weight: 600;">Timely在线客服系统客服登录</h3>
|
||||
<div class="layui-form-item input-item" style="margin-top: 10px;">
|
||||
<label for="userName">客服名</label>
|
||||
<input type="text" placeholder="请输入客服名" autocomplete="off" id="userName" name='username' class="layui-input" lay-verify="required">
|
||||
</div>
|
||||
<div class="layui-form-item input-item">
|
||||
<label for="password">密码</label>
|
||||
<input type="password" placeholder="请输入密码" autocomplete="off" id="password" name='password' class="layui-input" lay-verify="required">
|
||||
</div>
|
||||
<div class="layui-form-item input-item" id="imgCode">
|
||||
<label for="code">验证码</label>
|
||||
<input type="text" placeholder="请输入验证码" autocomplete="off" id="code" name="captcha" class="layui-input">
|
||||
<img id="captchaPic" src="{:captcha_src()}" onclick="changeCaptcha(this)" style="width: 100px;height: 100%" >
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
|
||||
</div>
|
||||
<div class="layui-form-item layui-row">
|
||||
<a href="javascript:;" class="seraph icon-qq layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4"></a>
|
||||
<a href="javascript:;" class="seraph icon-wechat layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4"></a>
|
||||
<a href="javascript:;" class="seraph icon-sina layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4"></a>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/static/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
|
||||
<script>
|
||||
layui.use(['form','layer','jquery'],function(){
|
||||
var form = layui.form,
|
||||
layer = parent.layer === undefined ? layui.layer : top.layer
|
||||
$ = layui.jquery;
|
||||
|
||||
<div class="form-wrapper">
|
||||
<h5>Timely客服登陆</h5>
|
||||
<form action="{:url('login/Logining')}" method="post">
|
||||
<div class="form-group input-group-lg">
|
||||
<input type="text" name="name" class="form-control" placeholder="输入一个名称,名称已有会要求密码" required autofocus>
|
||||
</div>
|
||||
<div class="form-group input-group-lg">
|
||||
<input type="password" name="password" class="form-control" placeholder="请自行保存密码,下次登陆" required>
|
||||
</div>
|
||||
<div class="form-group d-flex justify-content-between">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" checked="" id="customCheck1">
|
||||
<label class="custom-control-label" for="customCheck1">记住我</label>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-lg btn-block">进入</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="/static/demo/js/jquery.min.js"></script>
|
||||
|
||||
//登录按钮
|
||||
form.on("submit(login)",function(data){
|
||||
data = data.field;
|
||||
if (data.username == '') {
|
||||
layer.msg('用户名不能为空');
|
||||
return false;
|
||||
}
|
||||
if (data.password == '') {
|
||||
layer.msg('密码不能为空');
|
||||
return false;
|
||||
}
|
||||
if (data.captcha == '') {
|
||||
layer.msg('验证码不能为空');
|
||||
return false;
|
||||
}
|
||||
$.post('/index/Login/loginIn', data, function (res) {
|
||||
if (res.code == 1000) {
|
||||
|
||||
layer.msg('登录成功', {icon: 1, time: 1500}, function () {
|
||||
// location.replace(res.data)
|
||||
window.location.href = res.data;
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 2});
|
||||
$("#captchaPic").click();
|
||||
}
|
||||
}, 'json');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
//表单输入效果
|
||||
$(".loginBody .input-item").click(function(e){
|
||||
e.stopPropagation();
|
||||
$(this).addClass("layui-input-focus").find(".layui-input").focus();
|
||||
})
|
||||
$(".loginBody .layui-form-item .layui-input").focus(function(){
|
||||
$(this).parent().addClass("layui-input-focus");
|
||||
})
|
||||
$(".loginBody .layui-form-item .layui-input").blur(function(){
|
||||
$(this).parent().removeClass("layui-input-focus");
|
||||
if($(this).val() != ''){
|
||||
$(this).parent().addClass("layui-input-active");
|
||||
}else{
|
||||
$(this).parent().removeClass("layui-input-active");
|
||||
}
|
||||
})
|
||||
})
|
||||
function changeCaptcha(obj) {
|
||||
$(obj).attr('src', $(obj).attr('src') + '?t=' + Math.random(100000000,999999999));
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -136,7 +136,7 @@ class KefuLogic
|
||||
}
|
||||
$kf['kefu_password'] = strtoupper(md5($password));
|
||||
$kf['update_time'] = date('Y-m-d H:i:s');
|
||||
return Db::name('kefu_info')->where('kefu_id', $id)->update(['kefu_password' => strtoupper(md5(config('timely.acquiesce_password')))]);
|
||||
return Db::name('kefu_info')->where('kefu_id', $id)->update($kf);
|
||||
} catch (BaseException $be) {
|
||||
throw new ResponsableException($be->getMessage(), $be->getCode());
|
||||
} catch (Exception $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user