login add logsms
This commit is contained in:
@@ -18,7 +18,11 @@ class Login extends CI_Controller
|
||||
header('Location:/welcome');
|
||||
}
|
||||
|
||||
$this->load->view('login');
|
||||
$arr = array();
|
||||
if ($this->input->get('need_code') == 'logsms'){
|
||||
$arr['need_code'] = 'logsms';
|
||||
}
|
||||
$this->load->view('login', $arr);
|
||||
}
|
||||
|
||||
public function post()
|
||||
@@ -33,9 +37,10 @@ class Login extends CI_Controller
|
||||
return false;
|
||||
}
|
||||
$log = 0;//加日志
|
||||
if ($this->input->post('need_code') == 'login') {
|
||||
if ($this->input->post('need_code') == 'login' || $this->input->post('need_code') == 'logsms') {
|
||||
$code = $this->input->post('code');
|
||||
$mobile = $this->input->post('mobile');
|
||||
$this->input->post('need_code') == 'logsms' && $mobile = $this->input->post('number');
|
||||
$cookie = $this->input->cookie(LOGIN_CODE_COOKIE);
|
||||
$code_cookie = $this->encryption->decrypt($cookie);
|
||||
if (!$code_cookie) {
|
||||
@@ -46,6 +51,9 @@ class Login extends CI_Controller
|
||||
}
|
||||
$this->load->model('sys/sys_admin_model');
|
||||
$admin_user = $this->sys_admin_model->get(array("mobile = '{$mobile}'" => null, 'status' => 1));
|
||||
if (!$admin_user['id']) {
|
||||
return $this->show_json(0, '用户不存在');
|
||||
}
|
||||
$log = 1;
|
||||
} else {
|
||||
if (!$username) {
|
||||
@@ -116,6 +124,14 @@ class Login extends CI_Controller
|
||||
{
|
||||
if ($this->input->method() == 'post') {
|
||||
$mobile = $this->input->post('mobile', true);
|
||||
if (!$mobile){
|
||||
return false;
|
||||
}
|
||||
$this->load->model('sys/sys_admin_model');
|
||||
$admin_user = $this->sys_admin_model->get(array("mobile = '{$mobile}'" => null, 'status' => 1));
|
||||
if (!$admin_user['id']) {
|
||||
return false;
|
||||
}
|
||||
$code = rand(100000, 999999);
|
||||
|
||||
$domain = explode('.', $_SERVER['HTTP_HOST']);
|
||||
|
||||
+17
-4
@@ -63,7 +63,7 @@
|
||||
<li class="username">
|
||||
<i></i>
|
||||
<input style="width: 65%" name="number" type="text" autofocus="autofocus"
|
||||
value="<?= $mobile ? mobile_asterisk($mobile) : '' ?>" disabled
|
||||
value="<?= $mobile ? mobile_asterisk($mobile) : '' ?>" <?= $need_code=='login' ? disabled : ''?>
|
||||
autocomplete="off" title="请输入手机号码" placeholder="请输入手机号码" maxlength="11">
|
||||
<button class="am-btn am-btn-sm" style="float: right; margin-top: 5px; margin-bottom: 5px;"
|
||||
type="button" onclick="getCode(this)"/>
|
||||
@@ -76,11 +76,16 @@
|
||||
autocomplete="off" title="请输入验证码" placeholder="请输入验证码" maxlength="6">
|
||||
</li>
|
||||
<input type="hidden" name="mobile" value="<?= $mobile ?>">
|
||||
<input type="hidden" name="need_code" value="">
|
||||
<input type="hidden" name="need_code" value="<?= $need_code ?>">
|
||||
<?php endif; ?>
|
||||
<li class="text-center">
|
||||
<button type="submit" class="am-btn am-btn-success" data-form-loaded="立 即 登 录">正 在 载 入</button>
|
||||
<!-- <a class="forget" href="/admin/login/forget.html">忘记密码?</a> -->
|
||||
<?php if (!$need_code) : ?>
|
||||
<a style="display:inline-block;position: relative;vertical-align: middle;margin-left: 5px;" href="/login/?need_code=logsms">验证码登录</a>
|
||||
<?php elseif ($need_code==='logsms') : ?>
|
||||
<a style="display:inline-block;position: relative;vertical-align: middle;margin-left: 5px;" href="/login">密码登录</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
@@ -117,15 +122,23 @@
|
||||
|
||||
function getCode(obj) {
|
||||
settime($(obj));
|
||||
|
||||
let mobile = "<?=$mobile?>";
|
||||
let need_code = $('[name="need_code"]').val();
|
||||
if (need_code == 'logsms'){
|
||||
mobile = $('[name="number"]').val();
|
||||
}
|
||||
$('[name="need_code"]').val('get');
|
||||
$.ajax({
|
||||
'url': 'get_code',
|
||||
'method': 'post',
|
||||
'type': 'json',
|
||||
'data': {mobile: "<?=$mobile?>"},
|
||||
//'data': {mobile: "<?//=$mobile?>//"},
|
||||
'data': {mobile: mobile},
|
||||
success: function (data) {
|
||||
$('[name="need_code"]').val('login');
|
||||
if (need_code == 'logsms'){
|
||||
$('[name="need_code"]').val(need_code);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user