moonsflyer 6 месяцев назад
Родитель
Сommit
92246d2ee7
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      app/common/service/GiftCardQrCodeService.php

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

@@ -30,6 +30,7 @@ class GiftCardQrCodeService
             $config = WeChatConfigService::getMnpConfig();
             $app = Factory::miniProgram($config);
 
+            // 修正:使用正确的API方法
             $response = $app->app_code->getUnlimited($scene, [
                 'page' => $page,
                 'width' => 280,
@@ -37,6 +38,17 @@ class GiftCardQrCodeService
                 'line_color' => ['r' => 0, 'g' => 0, 'b' => 0],
             ]);
 
+            // 如果上面的方法不工作,尝试以下替代方案:
+            // 方案1:使用get方法
+            // $response = $app->app_code->get($page . '?' . $scene, [
+            //     'width' => 280,
+            // ]);
+
+            // 方案2:使用getQrCode方法
+            // $response = $app->app_code->getQrCode($page . '?' . $scene, [
+            //     'width' => 280,
+            // ]);
+
             if (!($response instanceof \EasyWeChat\Kernel\Http\StreamResponse)) {
                 Log::error('生成小程序码失败', ['response' => $response]);
                 return false;