短信验证码提交

master
zhengyongxing 5 years ago
parent 3741b0d27f
commit 3fca3c89ad

@ -4,6 +4,7 @@ namespace Admin\Controller;
use User\Api\UserApi; use User\Api\UserApi;
use Com\Wechat; use Com\Wechat;
use Com\WechatAuth; use Com\WechatAuth;
use Base\Tool\TaskClient;
/** /**
* 后台首页控制器 * 后台首页控制器
@ -78,7 +79,9 @@ class PublicController extends \Think\Controller
if (IS_POST) { if (IS_POST) {
/* 检测验证码 TODO: */ /* 检测验证码 TODO: */
$this->checksafecode($mobile, $verify, false); if (!$this->checksafecode($mobile, $verify)) {
$this->error('验证码错误');
}
$promote = M('promote', 'tab_')->where([ $promote = M('promote', 'tab_')->where([
'mobile_phone' => $mobile, 'mobile_phone' => $mobile,
'level' => 1, 'level' => 1,
@ -341,41 +344,31 @@ class PublicController extends \Think\Controller
*/ */
public function telsafecode($phone = '', $delay = 10, $flag = true) public function telsafecode($phone = '', $delay = 10, $flag = true)
{ {
$result = R('Common/Sms/send_sms_code', array($phone, $delay, false)); $taskClient = new TaskClient();
$result = $taskClient->sendSms($phone);
if ($result['code'] == 200) { $data = [];
if ($result['code'] == TaskClient::SUCCESS) {
$data['status'] = 1; $data['status'] = 1;
$data['data'] = $result['data'];
} else { } else {
$data['status'] = 0; $data['status'] = 0;
} }
$data['msg'] = $result['message'];
$data['msg'] = $result['msg'];
echo json_encode($data); echo json_encode($data);
exit; exit;
} }
/** /**
* 手机安全码验证 * 手机安全码验证
* @param bool $flag true 用于直接异步请求 false 用于方法调用
* @param [type] $vcode [description]
*/ */
public function checksafecode($phone, $vcode, $flag = true) public function checksafecode($phone, $code)
{ {
$result = R('Common/Sms/verify_sms_code', array($phone, $vcode, false)); $taskClient = new TaskClient();
$result = $taskClient->checkSms($phone, $code);
if ($result['code'] == 200) { $data = [];
$data['status'] = 1; if ($result && $result['code'] == TaskClient::SUCCESS) {
if ($flag) { return true;
echo json_encode($data);
exit;
}
} else { } else {
$data['status'] = 0; return false;
$data['msg'] = $result['msg'];
echo json_encode($data);
exit;
} }
} }

Loading…
Cancel
Save