Parcourir la source

APP/小程序-登录

sunxbiao il y a 1 an
Parent
commit
81948d2fae
1 fichiers modifiés avec 32 ajouts et 29 suppressions
  1. 32 29
      app/controller/api/Auth.php

+ 32 - 29
app/controller/api/Auth.php

@@ -2025,36 +2025,39 @@ class Auth extends BaseController
2025 2025
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2026 2026
             }
2027 2027
             $user = $repository->accountByUser($phone);
2028
-            if($this->source=='yhc' && $this->merId){
2029
-                $where=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2030
-                $count=Db::name('enterprise_user')->where($where)->count();
2031
-                if($count<1){
2032
-                    $insert=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2033
-                    $data = $this->request->params(['spread', 'share_id']);
2034
-
2035
-                    if(isset($data['spread']) && $data['spread']){
2036
-                        $insert['puid']= $data['spread'];
2037
-                        $insert['node_uid']= $data['spread'];
2038
-                    }else if(isset($data['share_id']) && $data['share_id']){
2039
-                        $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
2040
-                        $insert['puid']= $spread_uid;
2041
-                        $insert['node_uid']= $spread_uid;
2042
-                    }
2043
-                    if(!isset($insert['node_uid']) || !$insert['node_uid']){
2044
-                        return app('json')->fail('必须要有邀请人才能注册',['is'=>1]);
2045
-                    }
2046
-
2047
-                    if(isset($data['spread']) && isset($zhuce)){
2048
-                        $insert['puid']= $data['spread'];
2049
-                        $insert['node_uid']= $data['spread'];
2050
-                    }
2051
-                    Db::name('enterprise_user')->insert($insert);
2052
-                }
2028
+            // if($this->source=='yhc' && $this->merId){
2029
+            //     $where=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2030
+            //     $count=Db::name('enterprise_user')->where($where)->count();
2031
+            //     if($count<1){
2032
+            //         $insert=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2033
+            //         $data = $this->request->params(['spread', 'share_id']);
2034
+            //
2035
+            //         if(isset($data['spread']) && $data['spread']){
2036
+            //             $insert['puid']= $data['spread'];
2037
+            //             $insert['node_uid']= $data['spread'];
2038
+            //         }else if(isset($data['share_id']) && $data['share_id']){
2039
+            //             $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
2040
+            //             $insert['puid']= $spread_uid;
2041
+            //             $insert['node_uid']= $spread_uid;
2042
+            //         }
2043
+            //         if(!isset($insert['node_uid']) || !$insert['node_uid']){
2044
+            //             return app('json')->fail('必须要有邀请人才能注册',['is'=>1]);
2045
+            //         }
2046
+            //
2047
+            //         if(isset($data['spread']) && isset($zhuce)){
2048
+            //             $insert['puid']= $data['spread'];
2049
+            //             $insert['node_uid']= $data['spread'];
2050
+            //         }
2051
+            //         Db::name('enterprise_user')->insert($insert);
2052
+            //     }
2053
+            // }
2054
+            if (!empty($user) && $user instanceof User) {
2055
+                $user = $repository->mainUser($user);
2056
+                $tokenInfo = $repository->createToken($user);
2057
+                return app('json')->success($repository->returnToken($user, $tokenInfo));
2058
+            } else {
2059
+                return app('json')->fail('未查询到用户信息');
2053 2060
             }
2054
-            $user = $repository->mainUser($user);
2055
-
2056
-            $tokenInfo = $repository->createToken($user);
2057
-            return app('json')->success($repository->returnToken($user, $tokenInfo));
2058 2061
         }catch (Exception $exception){
2059 2062
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);
2060 2063
         }