From 2a017bfb4530ce7c196bee4fdd75efa62b3acfea Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Sat, 9 May 2020 16:58:31 +0800 Subject: [PATCH] loginmodel --- Application/Admin/Model/PromoteModel.class.php | 4 ++++ .../Home/Controller/IndexController.class.php | 4 ++-- Application/User/Api/PromoteApi.class.php | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index b5d1d781f..3e42063d4 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -80,6 +80,10 @@ class PromoteModel extends Model{ } } + public function login_phone($user) { + $this->autoLogin($user); + } + diff --git a/Application/Home/Controller/IndexController.class.php b/Application/Home/Controller/IndexController.class.php index 6ec56b569..c64cf4998 100644 --- a/Application/Home/Controller/IndexController.class.php +++ b/Application/Home/Controller/IndexController.class.php @@ -124,9 +124,9 @@ class IndexController extends HomeController M("promote_login_record", "tab_")->add($loginrecord); setcookie('login_phone', $mobile, time() + 3600 * 10000, $_SERVER["HTTP_HOST"]); $promote1 = new PromoteApi(); - $result = $promote1->login($promote['account'], $promote['password']); + $result = $promote1->login_phone($promote['account']); if ($result) { - $this->success('登录成功!', U('Promote/index')); + $this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index'))); } }else { diff --git a/Application/User/Api/PromoteApi.class.php b/Application/User/Api/PromoteApi.class.php index 1fdff9a27..1c1776251 100644 --- a/Application/User/Api/PromoteApi.class.php +++ b/Application/User/Api/PromoteApi.class.php @@ -77,6 +77,20 @@ class PromoteApi extends Api{ return $this->model->login($username, $password); } + public function login_phone($account) + { + $map['account'] = $account; + /* 获取用户数据 */ + $user = M('promote', 'tab_')->where($map)->find(); + if($user) { + $this->model->login_phone($user); + return $user['id']; + }else { + return -1; + } + } + + /** * 退出登录 */