From a29365fed8decf4315cc847f049195967ad1bee0 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Wed, 6 May 2020 15:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/IndexController.class.php | 63 +++++ .../Home/Controller/SafeController.class.php | 68 +++++ .../Home/View/default/Index/index.html | 1 + .../Home/View/default/Index/phoneLogin.html | 267 ++++++++++++++++++ .../Home/View/default/Safe/bindTel.html | 265 +++++++++++++++++ 5 files changed, 664 insertions(+) create mode 100644 Application/Home/View/default/Index/phoneLogin.html create mode 100644 Application/Home/View/default/Safe/bindTel.html diff --git a/Application/Home/Controller/IndexController.class.php b/Application/Home/Controller/IndexController.class.php index c91fac847..ad19c8d97 100644 --- a/Application/Home/Controller/IndexController.class.php +++ b/Application/Home/Controller/IndexController.class.php @@ -14,6 +14,7 @@ use OT\DataDictionary; use User\Api\PromoteApi; use Home\Controller\DownController; +use Base\Tool\TaskClient; /** * 前台首页控制器 @@ -74,6 +75,12 @@ class IndexController extends HomeController $map['account'] = $account; $data['last_login_time'] = time(); M("promote", "tab_")->where($map)->save($data); + $loginrecord['promote_id'] = get_pid(); + $loginrecord['account'] = $_POST['account']; + $loginrecord['client_ip'] = $_SERVER['REMOTE_ADDR']; + $loginrecord['login_type'] = 1; + $loginrecord['create_time'] = time(); + M("promote_login_record", "tab_")->add($loginrecord); $this->ajaxReturn(array("status" => 1, "msg" => "登录成功", 'url' => U('Promote/index'))); } else { $msg = ""; @@ -99,6 +106,25 @@ class IndexController extends HomeController } } + public function doPhoneLogin($mobile = null, $verify = null) { + if (!$this->checksafecode($mobile, $verify)) { + $this->error('验证码错误'); + } + $promote = M('promote', 'tab_')->where([ + 'login_phone' => $mobile, + ])->find(); + if($promote) { + $loginrecord['promote_id'] = get_pid(); + $loginrecord['account'] = $_POST['account']; + $loginrecord['client_ip'] = $_SERVER['REMOTE_ADDR']; + $loginrecord['login_type'] = 1; + $loginrecord['create_time'] = time(); + M("promote_login_record", "tab_")->add($loginrecord); + setcookie('login_phone', $mobile, time() + 3600 * 10000, $_SERVER["HTTP_HOST"]); + $this->success('登录成功!', U('Promote/index')); + } + } + /* public function register() { if (IS_POST) { @@ -291,4 +317,41 @@ class IndexController extends HomeController $Promote->logout(); redirect(U('Index/index')); } + + public function phoneLogin() { + $this->display(); + } + + /** + * 发动手机验证码 + */ + public function telsafecode($phone = '', $delay = 10, $flag = true) + { + $taskClient = new TaskClient(); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); + $data = []; + if ($result['code'] == TaskClient::SUCCESS) { + $data['status'] = 1; + } else { + $data['status'] = 0; + } + $data['msg'] = $result['message']; + echo json_encode($data); + exit; + } + + /** + * 手机安全码验证 + */ + public function checksafecode($phone, $code) + { + $taskClient = new TaskClient(); + $result = $taskClient->checkSms($phone, $code); + $data = []; + if ($result && $result['code'] == TaskClient::SUCCESS) { + return true; + } else { + return false; + } + } } diff --git a/Application/Home/Controller/SafeController.class.php b/Application/Home/Controller/SafeController.class.php index 5e9d5bede..ba6a98334 100644 --- a/Application/Home/Controller/SafeController.class.php +++ b/Application/Home/Controller/SafeController.class.php @@ -9,6 +9,7 @@ namespace Home\Controller; use Think\Controller; use Base\Repository\PromoteRepository; +use Base\Tool\TaskClient; /** * 扩展控制器 @@ -559,4 +560,71 @@ class SafeController extends BaseController{ $this->ajaxReturn(['code'=>0000,'mes'=>'删除成功']); } } + + public function bindTel() { + $id = get_pid(); + $promote = M('promote', 'tab_')->where(['id' => $id])->find(); + if(!empty($promote['login_phone'])) { + $this->assign('login_phone', $promote['login_phone']); + } + return $this->display(); + } + + /** + * 发动手机验证码 + */ + public function telsafecode($phone = '', $delay = 10, $flag = true) + { + $taskClient = new TaskClient(); + $result = $taskClient->sendSmsCode($phone, get_client_ip()); + $data = []; + if ($result['code'] == TaskClient::SUCCESS) { + $data['status'] = 1; + } else { + $data['status'] = 0; + } + $data['msg'] = $result['message']; + echo json_encode($data); + exit; + } + + /** + * 手机安全码验证 + */ + public function checksafecode($phone, $code) + { + $taskClient = new TaskClient(); + $result = $taskClient->checkSms($phone, $code); + $data = []; + if ($result && $result['code'] == TaskClient::SUCCESS) { + return true; + } else { + return false; + } + } + + public function addLoginMobile($mobile = null, $verify = null) { + if (IS_POST) { + /* 检测验证码 TODO: */ + + if (!$this->checksafecode($mobile, $verify)) { + $this->error('验证码错误'); + } + $id = get_pid(); + $promote = M('promote', 'tab_')->where([ + 'id' => $id + ])->find(); + if ($promote) { + $promote['login_phone'] = $mobile; + $updateRs = M('promote', 'tab_')->where(['id' => $id])->save($promote); + if($updateRs) { + $this->success("更新登陆手机号成功"); + }else { + $this->error("更新登陆手机号失败"); + } + }else { + $this->error("无此推广账号信息"); + } + } + } } \ No newline at end of file diff --git a/Application/Home/View/default/Index/index.html b/Application/Home/View/default/Index/index.html index 578362aeb..822ac37eb 100644 --- a/Application/Home/View/default/Index/index.html +++ b/Application/Home/View/default/Index/index.html @@ -38,6 +38,7 @@
+
diff --git a/Application/Home/View/default/Index/phoneLogin.html b/Application/Home/View/default/Index/phoneLogin.html new file mode 100644 index 000000000..dcaec1ca9 --- /dev/null +++ b/Application/Home/View/default/Index/phoneLogin.html @@ -0,0 +1,267 @@ + + + + + + + +
+
+ + + +
+
+
+
+ +
+ + + +
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/Safe/bindTel.html b/Application/Home/View/default/Safe/bindTel.html new file mode 100644 index 000000000..dbaa93c66 --- /dev/null +++ b/Application/Home/View/default/Safe/bindTel.html @@ -0,0 +1,265 @@ + + + + + + + + +
+
+ + 手机号绑定 +
+
+
+ +
+ + + + + + + + + + + + + + +
*手机号码 + + + + + + +
*短信验证码 + + +
+ + +
+
+ + + +
+
+
+ + + + + +
+ + + + + + + + \ No newline at end of file