44 lines
1.0 KiB
PHP
Executable File
44 lines
1.0 KiB
PHP
Executable File
<?php
|
|
namespace App\Domains\Sms\Http\Controllers;
|
|
|
|
use App\Core\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Domains\Sms\Services\SmsService;
|
|
|
|
class SmsController extends Controller
|
|
{
|
|
const PRODUCT = '卡务平台';
|
|
|
|
protected $request;
|
|
protected $smsService;
|
|
|
|
/**
|
|
* 构造函数,自动注入.
|
|
*/
|
|
public function __construct(Request $request, SmsService $smsService)
|
|
{
|
|
$this->request = $request;
|
|
$this->smsService = $smsService;
|
|
}
|
|
|
|
/**
|
|
* 短信验证码接口
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$mobile = $this->request->get('mobile');
|
|
|
|
if ($this->request->isMethod('post')) {
|
|
$verifyCode = $this->request->get('verify_code');
|
|
$this->smsService->verifyCode($mobile, $verifyCode);
|
|
return res(true, '验证码正确');
|
|
}
|
|
|
|
$freqsecs = $this->smsService->sendVcode($mobile, self::PRODUCT);
|
|
|
|
return res(['freg' => $freqsecs], '发送成功');
|
|
}
|
|
}
|