接口文档更新

This commit is contained in:
2018-08-12 17:42:34 +08:00
parent 7433530805
commit 1f251a9103
7 changed files with 289 additions and 40 deletions
+50
View File
@@ -37,4 +37,54 @@ class Login extends \app\common\controller\Api{
return $this->data;
}
}
public function register(){
$code = $this->request->post('code');
$username = $this->request->post('username');
$password = $this->request->post('password');
$other['nickname'] = $this->request->post('nickname', '');
$other['mini_openid'] = $this->request->post('openid', '');
$other['mobile'] = $this->request->post('mobile', '');
$other['invite'] = $this->request->post('invite', '');
$client = $this->request->post('client', 'wxapp');
if ($client == 'wxapp') {
$user = db('Member')->where('mini_openid', $other['mini_openid'])->find();
if ($user) {
$user['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE');
$user['uid'] = $user['uid'];
$user['username'] = $user['username'];
$user['password'] = $user['password'];
$user['avatar'] = (isset($user['avatar_url']) && $user['avatar_url']) ? $user['avatar_url'] : avatar($user['uid']);
$this->data['data'] = $user;
$this->data['code'] = 205;
$this->data['msg'] = "您已注册!";
return $this->data;
}
}
//验证手机验证码
$time = db('MobileCode')->where('code', $code)->where('mobile', $other['mobile'])->value('time');
if (!$time || (time() - $time) > 60*1000) {
//小于60秒则提示验证码过期
$this->data['code'] = 1;
$this->data['msg'] = "验证码已过期";
return $this->data;
}
$result = model('Member')->register($username, $password, $password, $username.'@test.com', false, $other);
if ($result) {
get_coupon('client_register', $result['uid']);
$result['access_token'] = authcode($result['uid'].'|'.$result['username'].'|'.$result['password'], 'ENCODE');
$result['uid'] = $result['uid'];
$result['username'] = $result['username'];
$result['password'] = $result['password'];
//$result['avatar'] = (isset($user['avatar_url']) && $user['avatar_url']) ? $user['avatar_url'] : avatar($user['uid']);
$this->data['data'] = $result;
}else{
$this->data['msg'] = model('Member')->getError();
$this->data['code'] = 1;
}
return $this->data;
}
}