feat: 微信登录调整
This commit is contained in:
parent
5ca1cf83f2
commit
fb0c43e309
|
|
@ -3,9 +3,8 @@
|
||||||
namespace app\services;
|
namespace app\services;
|
||||||
|
|
||||||
use app\common\library\Token;
|
use app\common\library\Token;
|
||||||
use EasyWeChat\Factory;
|
|
||||||
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
||||||
use EasyWeChat\MiniProgram\Application;
|
use EasyWeChat\MiniApp\Application;
|
||||||
|
|
||||||
class WorkerService extends BaseService
|
class WorkerService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -47,8 +46,9 @@ class WorkerService extends BaseService
|
||||||
{
|
{
|
||||||
$app = $this->getMiniProgramApp();
|
$app = $this->getMiniProgramApp();
|
||||||
try {
|
try {
|
||||||
$info = $app->auth->session($code);
|
$utils = $app->getUtils();
|
||||||
} catch (InvalidConfigException $e) {
|
$info = $utils->codeToSession($code);
|
||||||
|
} catch (\Exception $e) {
|
||||||
$this->apiError('登录失败', $e);
|
$this->apiError('登录失败', $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ class WorkerService extends BaseService
|
||||||
'app_id' => config('mini_program.app_id'),
|
'app_id' => config('mini_program.app_id'),
|
||||||
'secret' => config('mini_program.secret'),
|
'secret' => config('mini_program.secret'),
|
||||||
];
|
];
|
||||||
return Factory::miniProgram($config);
|
return new Application($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,8 +92,10 @@ class WorkerService extends BaseService
|
||||||
*/
|
*/
|
||||||
public function getPhoneNumber(string $code)
|
public function getPhoneNumber(string $code)
|
||||||
{
|
{
|
||||||
//getPhoneNumber 方法通过魔术方法 __call 获取
|
$app = $this->getMiniProgramApp();
|
||||||
$phoneInfo = $this->getMiniProgramApp()->getPhoneNumber($code);
|
$app->phone_number->getUserPhoneNumber(string $code);
|
||||||
|
$phoneInfo = $app->getClient()->postJson('wxa/business/getuserphonenumber', ['code' => $code]);
|
||||||
|
dd($phoneInfo);
|
||||||
|
|
||||||
if (empty($phoneInfo)) {
|
if (empty($phoneInfo)) {
|
||||||
$this->apiError('获取手机号失败', 0, $phoneInfo);
|
$this->apiError('获取手机号失败', 0, $phoneInfo);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user