moonsflyer 6 månader sedan
förälder
incheckning
b5de3ee2f9
1 ändrade filer med 12 tillägg och 2 borttagningar
  1. 12 2
      app/common/service/GiftCardQrCodeService.php

+ 12 - 2
app/common/service/GiftCardQrCodeService.php

@@ -47,8 +47,18 @@ class GiftCardQrCodeService
 
 
 
 
             // 方案2:使用getQrCode方法
             // 方案2:使用getQrCode方法
-             $response = $app->app_code->getQrCode($page . '?' . $scene, 280
-             );
+//             $response = $app->app_code->getQrCode($page . '?' . $scene, 280
+//             );
+            // 备用方案:直接调用微信API
+            $accessToken = $app->access_token->getToken()['access_token'];
+            $url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token={$accessToken}";
+            return $accessToken;
+            $data = [
+                'path' => $page . '?' . $scene,
+                'width' => 280
+            ];
+
+            $response = $app->getClient()->postJson($url, $data);
             if (!($response instanceof \EasyWeChat\Kernel\Http\StreamResponse)) {
             if (!($response instanceof \EasyWeChat\Kernel\Http\StreamResponse)) {
                 Log::error('生成小程序码失败', [
                 Log::error('生成小程序码失败', [
                     'response' => $response,
                     'response' => $response,