|
|
|
@ -100,7 +100,7 @@ class WapBasic extends Controller |
|
|
|
|
return $this->failed('请设置redis密码!', 'http://help.crmeb.net/crmeb_zsff/1907223'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function oauth($spread_uid = 0, $is_h5 = false) |
|
|
|
|
{ /* exit($this->failed('微信用户信息获取失败!!')); */ |
|
|
|
|
$openid = Session::get('loginOpenid', 'wap'); |
|
|
|
@ -109,7 +109,7 @@ class WapBasic extends Controller |
|
|
|
|
if (!UtilService::isWechatBrowser()) exit($this->failed('请在微信客户端打开链接')); |
|
|
|
|
//if ($this->request->isAjax()) exit($this->failed('请登陆!')); |
|
|
|
|
$errorNum = (int)Cookie::get('_oen'); |
|
|
|
|
if ($errorNum && $errorNum > 3) exit($this->failed('微信用户信息获取失败!!')); |
|
|
|
|
if ($errorNum && $errorNum > 3) exit($this->failed('微信用户信息获取失败!!')); |
|
|
|
|
try { |
|
|
|
|
$original = WechatService::oauthService()->getAccessToken($this->request->get('code')); |
|
|
|
|
if (!WechatUser::be(['openid' => $original->openid]) && $original->scope === 'snsapi_base') { |
|
|
|
@ -157,7 +157,7 @@ class WapBasic extends Controller |
|
|
|
|
}else{ |
|
|
|
|
return UserBehavior::wechatOauthAfter($openid, $wechatInfo,true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* APP微信授权登录 |
|
|
|
@ -199,7 +199,7 @@ class WapBasic extends Controller |
|
|
|
|
} |
|
|
|
|
$tokenService = new JwtService(); |
|
|
|
|
$token['token'] = $tokenService->getToken((int)$user['uid']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($token) { |
|
|
|
|
/** @var UserVisitServices $visitServices */ |
|
|
|
|
/* $visitServices = app()->make(UserVisitServices::class); |
|
|
|
@ -211,7 +211,7 @@ class WapBasic extends Controller |
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
return $th->getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -300,12 +300,12 @@ class WapBasic extends Controller |
|
|
|
|
'nickname' => $username |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$wechatUserServices->wechatUpdata([$user['uid'], $createData[1]]); |
|
|
|
|
} |
|
|
|
|
$tokenService = new JwtService(); |
|
|
|
|
$token['token'] = $tokenService->getToken((int)$user['uid']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($token) { |
|
|
|
|
/** @var UserVisitServices $visitServices */ |
|
|
|
|
/* $visitServices = app()->make(UserVisitServices::class); |
|
|
|
@ -317,7 +317,7 @@ class WapBasic extends Controller |
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
return $th->getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -347,7 +347,7 @@ class WapBasic extends Controller |
|
|
|
|
if (!isset($userInfoCong['open_id'])) { |
|
|
|
|
throw new ValidateException('openid获取失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//解密获取用户信息 |
|
|
|
|
$userInfo = KuaiMiniProgramService::encryptor($session_key, $iv, $encryptedData); |
|
|
|
@ -355,7 +355,7 @@ class WapBasic extends Controller |
|
|
|
|
if ($e->getCode() == '-41003') { |
|
|
|
|
throw new ValidateException('获取会话密匙失败'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$userInfo['unionId'] = isset($userInfoCong['unionid']) ? $userInfoCong['unionid'] : ''; |
|
|
|
|
$userInfo['openId'] = $openid = $userInfoCong['open_id']; |
|
|
|
|
$userInfo['spid'] = $spid; |
|
|
|
@ -373,15 +373,15 @@ class WapBasic extends Controller |
|
|
|
|
// 新用户获取后台默认名称 |
|
|
|
|
$createData['nickname'] =$userInfo['nickName']; |
|
|
|
|
$createData[1]['nickname'] = $userInfo['nickName']; |
|
|
|
|
$user = $wechatUserServices->wechatOauthAfter($createData); |
|
|
|
|
$user = $wechatUserServices->wechatOauthAfter($createData); |
|
|
|
|
} else { |
|
|
|
|
//更新用户信息 |
|
|
|
|
$wechatUserServices->wechatUpdata([$user['uid'], $createData[1]]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tokenService = new JwtService(); |
|
|
|
|
$token['token'] = $tokenService->getToken((int)$user['uid']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($token) { |
|
|
|
|
$token['userInfo'] = User::where('uid', $user['uid'])->find(); |
|
|
|
|
return $token; |
|
|
|
@ -390,10 +390,10 @@ class WapBasic extends Controller |
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
return $th->getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 抖音头条小程序授权登录 |
|
|
|
|
* @param $code |
|
|
|
@ -420,7 +420,7 @@ class WapBasic extends Controller |
|
|
|
|
if (!isset($userInfoCong['openid'])) { |
|
|
|
|
throw new ValidateException('openid获取失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
//解密获取用户信息 |
|
|
|
|
$userInfo = TouMiniProgramService::encryptor($session_key, $iv, $encryptedData); |
|
|
|
@ -428,7 +428,7 @@ class WapBasic extends Controller |
|
|
|
|
if ($e->getCode() == '-41003') { |
|
|
|
|
throw new ValidateException('获取会话密匙失败'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$userInfo['unionId'] = isset($userInfoCong['unionid']) ? $userInfoCong['unionid'] : ''; |
|
|
|
|
$userInfo['openId'] = $openid = $userInfoCong['openid']; |
|
|
|
|
$userInfo['spid'] = $spid; |
|
|
|
@ -446,15 +446,15 @@ class WapBasic extends Controller |
|
|
|
|
// 新用户获取后台默认名称 |
|
|
|
|
$createData['nickname'] =$userInfo['nickName']; |
|
|
|
|
$createData[1]['nickname'] = $userInfo['nickName']; |
|
|
|
|
$user = $toutiaoUser->wechatOauthAfter($createData); |
|
|
|
|
$user = $toutiaoUser->wechatOauthAfter($createData); |
|
|
|
|
} else { |
|
|
|
|
//更新用户信息 |
|
|
|
|
$toutiaoUser->wechatUpdata([$user['uid'], $createData[1]]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tokenService = new JwtService(); |
|
|
|
|
$token['token'] = $tokenService->getToken((int)$user['uid']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($token) { |
|
|
|
|
$token['userInfo'] = User::where('uid', $user['uid'])->find(); |
|
|
|
|
return $token; |
|
|
|
@ -463,7 +463,7 @@ class WapBasic extends Controller |
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
return $th->getMessage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 小程序创建用户后返回uid |
|
|
|
|