Procházet zdrojové kódy

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

xupuyuan před 11 měsíci
rodič
revize
76bb0fc384
1 změnil soubory, kde provedl 9 přidání a 0 odebrání
  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 2093
             $user_res=Db::name('user')->where('account',$phone)->find();
2094 2094
 
2095
+            $isnew = false;
2096
+
2095 2097
             if(!$user_res){
2096 2098
                 $spread_uid=Db::name('product_share')->where('id',$share_id['share_id'])->value('uid');
2097 2099
                 if (!intval($spread_uid)) {
2098 2100
                     $spread_uid = 0;
2099 2101
                 }
2100 2102
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2103
+
2104
+                $isnew = true;
2101 2105
             }
2102 2106
             $user = $repository->accountByUser($phone);
2103 2107
             if($this->source=='yhc' && $this->merId){
@@ -2129,6 +2133,11 @@ class Auth extends BaseController
2129 2133
             $user = $repository->mainUser($user);
2130 2134
 
2131 2135
             $tokenInfo = $repository->createToken($user);
2136
+
2137
+            if($isnew){
2138
+                return app('json')->success('注册用户');
2139
+            }
2140
+
2132 2141
             return app('json')->success($repository->returnToken($user, $tokenInfo));
2133 2142
         }catch (Exception $exception){
2134 2143
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);