hrjy 3 years ago
parent
commit
fa1d1eab67
1 changed files with 36 additions and 14 deletions
  1. 36 14
      app/models/user/User.php

+ 36 - 14
app/models/user/User.php

@@ -119,23 +119,45 @@ class User extends BaseModel
             $status = false;
         }
         if ($userInfo->spread_uid) {
-            return self::edit([
-                'nickname' => $wechatUser['nickname'] ?: '',
-                'avatar' => $wechatUser['headimgurl'] ?: '',
-                'is_promoter' => $status ? 1 : $userInfo->is_promoter,
-                'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
-            ], $uid, 'uid');
+            if (empty($wechatUser['nickname'])){
+                return self::edit([
+                    'phone' => $wechatUser['phone'],
+                    'is_promoter' => $status ? 1 : $userInfo->is_promoter,
+                    'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
+                ], $uid, 'uid');
+            }else{
+                return self::edit([
+                    'nickname' => $wechatUser['nickname'] ?: '',
+                    'avatar' => $wechatUser['headimgurl'] ?: '',
+                    'is_promoter' => $status ? 1 : $userInfo->is_promoter,
+                    'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
+                ], $uid, 'uid');
+            }
+
         } else {
-            $data = [
-                'nickname' => $wechatUser['nickname'] ?: '',
-                'avatar' => $wechatUser['headimgurl'] ?: '',
-                'is_promoter' => $status ? 1 : $userInfo->is_promoter,
-                'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
+            if (empty($wechatUser['nickname'])){
+                $data = [
+                    'phone' => $wechatUser['phone'],
+                    'is_promoter' => $status ? 1 : $userInfo->is_promoter,
+                    'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
+//                'spread_uid' => 0,
+//                'spread_time' => 0,
+                    'last_time' => time(),
+                    'last_ip' => request()->ip(),
+                ];
+            }else{
+                $data = [
+                    'nickname' => $wechatUser['nickname'] ?: '',
+                    'avatar' => $wechatUser['headimgurl'] ?: '',
+                    'is_promoter' => $status ? 1 : $userInfo->is_promoter,
+                    'login_type' => isset($wechatUser['login_type']) ? $wechatUser['login_type'] : $userInfo->login_type,
 //                'spread_uid' => 0,
 //                'spread_time' => 0,
-                'last_time' => time(),
-                'last_ip' => request()->ip(),
-            ];
+                    'last_time' => time(),
+                    'last_ip' => request()->ip(),
+                ];
+            }
+
             //TODO 获取后台分销类型
 //            $storeBrokerageStatus = sys_config('store_brokerage_statu');
 //            $storeBrokerageStatus = $storeBrokerageStatus ? $storeBrokerageStatus : 1;