diff --git a/application/services/WorkerService.php b/application/services/WorkerService.php index a98feb5..23cf5f2 100644 --- a/application/services/WorkerService.php +++ b/application/services/WorkerService.php @@ -3,9 +3,8 @@ namespace app\services; use app\common\library\Token; -use EasyWeChat\Factory; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; -use EasyWeChat\MiniProgram\Application; +use EasyWeChat\MiniApp\Application; class WorkerService extends BaseService { @@ -47,8 +46,9 @@ class WorkerService extends BaseService { $app = $this->getMiniProgramApp(); try { - $info = $app->auth->session($code); - } catch (InvalidConfigException $e) { + $utils = $app->getUtils(); + $info = $utils->codeToSession($code); + } catch (\Exception $e) { $this->apiError('登录失败', $e); } @@ -82,7 +82,7 @@ class WorkerService extends BaseService 'app_id' => config('mini_program.app_id'), '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) { - //getPhoneNumber 方法通过魔术方法 __call 获取 - $phoneInfo = $this->getMiniProgramApp()->getPhoneNumber($code); + $app = $this->getMiniProgramApp(); + $app->phone_number->getUserPhoneNumber(string $code); + $phoneInfo = $app->getClient()->postJson('wxa/business/getuserphonenumber', ['code' => $code]); + dd($phoneInfo); if (empty($phoneInfo)) { $this->apiError('获取手机号失败', 0, $phoneInfo);