1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\api\controller;
- use think\captcha\facade\Captcha;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 图片验证码控制器
- */
- class Seccode extends MobileMall
- {
- /**
- * 产生验证码
- * type 验证码传入可标识的信息
- */
- public function makecode()
- {
- $config = [
- // 验证码字体大小
- 'fontSize' => 40,
- // 验证码位数
- 'length' => 4,
- // 关闭验证码杂点
- 'useNoise' => false,
- ];
- config($config, 'captcha');
- $captcha = Captcha::create();
- return $captcha;
- }
- /**
- * @api {POST} api/Seccode/check 检查验证码
- * @apiVersion 1.0.0
- * @apiGroup Seccode
- *
- * @apiParam {String} captcha 验证码
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function check()
- {
- $captch = input('param.captcha');
- if (captcha_check($captch)) {
- ds_json_encode(10000, '');
- } else {
- ds_json_encode(10001, '验证码错误', ['code' => '']);
- }
- }
- }
|