| xqd
@@ -142,6 +142,7 @@ class AlbumController extends Controller
|
|
|
|
|
|
$app = Factory::miniProgram($config);
|
|
|
$res = $app->auth->session($datas['code']);
|
|
|
+ print_r($config);
|
|
|
dd($res);
|
|
|
if (!$res || empty($res['openid'])) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '获取用户OpenId失败!', $validator->messages());
|
| xqd
@@ -149,11 +150,11 @@ class AlbumController extends Controller
|
|
|
|
|
|
$session = $res['session_key'];
|
|
|
$decryptedData = $app->encryptor->decryptData($session, $datas['iv'], $datas['encryptData']);
|
|
|
- $check = AlbumUserModel::where('wechat_union_id',$decryptedData['unionId'])->first();
|
|
|
+ $check = AlbumUserModel::where('wechat_union_id',$decryptedData['unionId'])->orWhere('open_id', $res['openid'])->first();
|
|
|
if(!$check){
|
|
|
$add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
$add['open_id'] = $res['openid'];
|
|
|
- $add['wechat_union_id'] = $decryptedData['unionId'];
|
|
|
+ $add['wechat_union_id'] = isset($decryptedData['unionId'])?$decryptedData['unionId']:'';
|
|
|
$add['avatar'] = $datas['avatar'];
|
|
|
$add['is_agent'] = 0;
|
|
|
$add['model'] = 1;
|