Просмотр исходного кода

APP小程序-注册登录功能改进-一键登录若是新用户告知前端

xupuyuan месяцев назад: 11
Родитель
Сommit
76bb0fc384
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      app/controller/api/Auth.php

+ 9 - 0
app/controller/api/Auth.php

@@ -2092,12 +2092,16 @@ class Auth extends BaseController
2092
             }
2092
             }
2093
             $user_res=Db::name('user')->where('account',$phone)->find();
2093
             $user_res=Db::name('user')->where('account',$phone)->find();
2094
 
2094
 
2095
+            $isnew = false;
2096
+
2095
             if(!$user_res){
2097
             if(!$user_res){
2096
                 $spread_uid=Db::name('product_share')->where('id',$share_id['share_id'])->value('uid');
2098
                 $spread_uid=Db::name('product_share')->where('id',$share_id['share_id'])->value('uid');
2097
                 if (!intval($spread_uid)) {
2099
                 if (!intval($spread_uid)) {
2098
                     $spread_uid = 0;
2100
                     $spread_uid = 0;
2099
                 }
2101
                 }
2100
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2102
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2103
+
2104
+                $isnew = true;
2101
             }
2105
             }
2102
             $user = $repository->accountByUser($phone);
2106
             $user = $repository->accountByUser($phone);
2103
             if($this->source=='yhc' && $this->merId){
2107
             if($this->source=='yhc' && $this->merId){
@@ -2129,6 +2133,11 @@ class Auth extends BaseController
2129
             $user = $repository->mainUser($user);
2133
             $user = $repository->mainUser($user);
2130
 
2134
 
2131
             $tokenInfo = $repository->createToken($user);
2135
             $tokenInfo = $repository->createToken($user);
2136
+
2137
+            if($isnew){
2138
+                return app('json')->success('注册用户');
2139
+            }
2140
+
2132
             return app('json')->success($repository->returnToken($user, $tokenInfo));
2141
             return app('json')->success($repository->returnToken($user, $tokenInfo));
2133
         }catch (Exception $exception){
2142
         }catch (Exception $exception){
2134
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);
2143
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);