|
@@ -235,155 +235,7 @@ class User extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 注册会员
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $username 用户名
|
|
|
- * @param string $password 密码
|
|
|
- * @param string $email 邮箱
|
|
|
- * @param string $mobile 手机号
|
|
|
- * @param string $code 验证码
|
|
|
- */
|
|
|
- /*public function register()
|
|
|
- {
|
|
|
- $username = $this->request->post('username');
|
|
|
- $password = $this->request->post('password');
|
|
|
- $email = $this->request->post('email');
|
|
|
- $mobile = $this->request->post('mobile');
|
|
|
- $code = $this->request->post('code');
|
|
|
- if (!$username || !$password) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
- if ($email && !Validate::is($email, "email")) {
|
|
|
- $this->error(__('Email is incorrect'));
|
|
|
- }
|
|
|
- if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
- $this->error(__('Mobile is incorrect'));
|
|
|
- }
|
|
|
- $ret = Sms::check($mobile, $code, 'register');
|
|
|
- if (!$ret) {
|
|
|
- $this->error(__('Captcha is incorrect'));
|
|
|
- }
|
|
|
- $ret = $this->auth->register($username, $password, $email, $mobile, []);
|
|
|
- if ($ret) {
|
|
|
- $data = $this->userInfo('return');
|
|
|
- $this->success(__('Sign up successful'), $data);
|
|
|
- } else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- //微信登录
|
|
|
- public function wechatlogin(){
|
|
|
-// $nickname = input('nickname','');
|
|
|
-// $avatar = input('avatar','');
|
|
|
-// $gender = input('gender',1);
|
|
|
- $wechat_openid = input('wechat_openid','');
|
|
|
-
|
|
|
- if (!$wechat_openid) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-// if($gender != 1){
|
|
|
-// $gender = 0;
|
|
|
-// }
|
|
|
-
|
|
|
- $user = \app\common\model\User::getByOpenid($wechat_openid);
|
|
|
- if ($user) {
|
|
|
- if (!in_array($user->status,[1,2])) {
|
|
|
- $this->error(__('Account is locked'));
|
|
|
- }
|
|
|
- if ($user->frozentime > time()) {
|
|
|
- $this->error('您的账号已被封禁至' . date('Y-m-d H:i'));
|
|
|
- }
|
|
|
- //如果已经有账号则直接登录
|
|
|
- $ret = $this->auth->direct($user->id);
|
|
|
-
|
|
|
- //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
|
|
|
- /*if($user->gender == 1 && $user->gh_id == 0){
|
|
|
- $this->firstopen_send($user->id);
|
|
|
- }*/
|
|
|
- } else {
|
|
|
-// $this->success('选择性别', ['code' => 5]);
|
|
|
-
|
|
|
-// if (!$nickname || !$avatar) {
|
|
|
-// $this->error(__('Invalid parameters'));
|
|
|
-// }
|
|
|
-
|
|
|
- $reg_data = [
|
|
|
-// 'nickname'=>$nickname,
|
|
|
-// 'avatar'=>$avatar,
|
|
|
-// 'gender'=>$gender,
|
|
|
- 'register_from' => input('register_from',''),
|
|
|
- 'gender' => -1
|
|
|
- ];
|
|
|
- $ret = $this->auth->openid_register($wechat_openid,$reg_data);
|
|
|
- //亿米
|
|
|
- /*if(input('register_from','') == 'xiaomi'){
|
|
|
- $this->yimi_advert();
|
|
|
- }*/
|
|
|
- }
|
|
|
- if ($ret) {
|
|
|
- $data = $this->userInfo('return');
|
|
|
- $this->success(__('Logged in successful'), $data);
|
|
|
- } else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //微信注册
|
|
|
- public function wechatregiter(){
|
|
|
-// $nickname = input('nickname','');
|
|
|
-// $avatar = input('avatar','');
|
|
|
-// $gender = input('gender',1);
|
|
|
- $wechat_openid = input('wechat_openid','');
|
|
|
- $gender = input('gender', -1, 'intval'); //性别:1=男,0=女
|
|
|
-
|
|
|
- if (!$wechat_openid) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
- if (!in_array($gender, [1, 0])) {
|
|
|
- $this->error('性别错误');
|
|
|
- }
|
|
|
-
|
|
|
- $user = \app\common\model\User::getByOpenid($wechat_openid);
|
|
|
- if ($user) {
|
|
|
- $this->error('账号已经存在,请直接登录');
|
|
|
-
|
|
|
- if (!in_array($user->status,[1,2])) {
|
|
|
- $this->error(__('Account is locked'));
|
|
|
- }
|
|
|
- //如果已经有账号则直接登录
|
|
|
- $ret = $this->auth->direct($user->id);
|
|
|
-
|
|
|
- //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
|
|
|
- /*if($user->gender == 1 && $user->gh_id == 0){
|
|
|
- $this->firstopen_send($user->id);
|
|
|
- }*/
|
|
|
- } else {
|
|
|
-// if (!$nickname || !$avatar) {
|
|
|
-// $this->error(__('Invalid parameters'));
|
|
|
-// }
|
|
|
-
|
|
|
- $reg_data = [
|
|
|
-// 'nickname'=>$nickname,
|
|
|
-// 'avatar'=>$avatar,
|
|
|
- 'gender'=>$gender,
|
|
|
- 'register_from' => input('register_from',''),
|
|
|
- ];
|
|
|
- $ret = $this->auth->openid_register($wechat_openid,$reg_data);
|
|
|
- //亿米
|
|
|
- /*if(input('register_from','') == 'xiaomi'){
|
|
|
- $this->yimi_advert();
|
|
|
- }*/
|
|
|
- }
|
|
|
- if ($ret) {
|
|
|
- $data = $this->userInfo('return');
|
|
|
- $this->success(__('Logged in successful'), $data);
|
|
|
- } else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 运营商一键登录
|