Register.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Created by PhpStorm.
* User: 86132
* Date: 2020/7/4
* Time: 9:50
*/
namespace app\api\controller;
use think\Db;
use app\common\controller\Api;
/**
* 注册接口
*/
class Register extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
}
/**
* @ApiTitle (注册接口-注册)
* @ApiSummary (注册)
* @ApiMethod (POST)
* @ApiRoute (/api/register/RegisterSign)
* @ApiParams (name="mobile", type="integer", required=true, description="手机号")
* @ApiParams (name="password", type="string", required=true, description="密码")
* @ApiParams (name="code", type="string", required=true, description="验证码")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
"data": "1"
})
*/
public function RegisterSign()
{
$param = $this->request->param();
if (empty($param['password']||$param['password'] =="")) {
$is_user = Db::name('user')->where(['mobile' => $param['mobile']])->find();
if ($is_user) {
$this->error('您已注册过,请直接登陆', 0);
} else {
$this->CheckCode($param['mobile'], $param['code']);
}
} else {
$model=new \app\common\model\User();
$res = $model->save(['mobile' => $param['mobile'], 'username'=>$param['mobile'],'password' => $param['password']]);
if ($res) {
$this->success('成功', 1);
} else {
$this->error('失败', 0);
}
}
}
}