Browse Source

fix:抛出异常

景好勇 4 months ago
parent
commit
9815d24301
1 changed files with 17 additions and 24 deletions
  1. 17 24
      app/Services/Client/WechatService.php

+ 17 - 24
app/Services/Client/WechatService.php

@@ -2,12 +2,13 @@
 
 namespace App\Services\Client;
 
+use Illuminate\Support\Facades\Log;
 use App\Exceptions\BusinessException;
-use EasyWeChat\OfficialAccount\Application;
 use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\Log;
-use Overtrue\Socialite\Contracts\ProviderInterface;
+use App\Services\Client\AccountService;
+use EasyWeChat\OfficialAccount\Application;
 use Overtrue\Socialite\Contracts\UserInterface;
+use Overtrue\Socialite\Contracts\ProviderInterface;
 
 class WechatService
 {
@@ -210,7 +211,7 @@ class WechatService
 
     protected function getAuthStateKey(string $state): string
     {
-        return config('wechat.auth.cache_prefix').$state;
+        return config('wechat.auth.cache_prefix') . $state;
     }
 
     /**
@@ -223,26 +224,18 @@ class WechatService
      */
     public function getJsConfig(string $url): array
     {
-        try {
-            $apis = [
-                'updateAppMessageShareData',
-                'updateTimelineShareData',
-                'chooseImage',
-                'previewImage',
-                'uploadImage',
-                'downloadImage',
-                'getLocation',
-                'openLocation',
-                'scanQRCode',
-            ];
+        $apis = [
+            'updateAppMessageShareData',
+            'updateTimelineShareData',
+            'chooseImage',
+            'previewImage',
+            'uploadImage',
+            'downloadImage',
+            'getLocation',
+            'openLocation',
+            'scanQRCode',
+        ];
 
-            return $this->app->getUtils()->buildJsSdkConfig($url, $apis);
-        } catch (\Throwable $e) {
-            \Log::error('获取JSAPI配置失败', [
-                'url' => $url,
-                'error' => $e->getMessage(),
-            ]);
-            throw new BusinessException('获取JSAPI配置失败,请稍后重试');
-        }
+        return $this->app->getUtils()->buildJsSdkConfig($url, $apis);
     }
 }