From 3bc66da95a34f735850b2067210e0481edc9a4cc Mon Sep 17 00:00:00 2001 From: gcd Date: Tue, 22 Apr 2025 23:07:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=20"w7corp/easywechat":=20"^6.17"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/WorkerService.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/application/services/WorkerService.php b/application/services/WorkerService.php index 23cf5f2..b01c90c 100644 --- a/application/services/WorkerService.php +++ b/application/services/WorkerService.php @@ -86,16 +86,27 @@ class WorkerService extends BaseService } /** - * 解密微信手机号 + * 通过 code 获取用户手机号 + * @param string $code + * @return array + */ + private function code2PhoneNumberInfo(string $code): array + { + $app = $this->getMiniProgramApp(); + $phoneInfo = $app->getClient()->postJson('wxa/business/getuserphonenumber', ['code' => $code]); + + return $phoneInfo->toArray(); + } + + /** + * 获取用户手机号 * @param string $code * @return mixed */ public function getPhoneNumber(string $code) { - $app = $this->getMiniProgramApp(); - $app->phone_number->getUserPhoneNumber(string $code); - $phoneInfo = $app->getClient()->postJson('wxa/business/getuserphonenumber', ['code' => $code]); - dd($phoneInfo); + //通过 code 获取手机号信息 + $phoneInfo = $this->code2PhoneNumberInfo($code); if (empty($phoneInfo)) { $this->apiError('获取手机号失败', 0, $phoneInfo);