Browse Source

师傅端-产品小程序码

whitefang 1 year ago
parent
commit
f25a490459

+ 1 - 1
app/workerapi/controller/GoodsCategoryController.php

@@ -22,6 +22,6 @@ class GoodsCategoryController extends BaseApiController
         if (false === $result) {
         if (false === $result) {
             return $this->fail(GoodsCategoryLogic::getError());
             return $this->fail(GoodsCategoryLogic::getError());
         }
         }
-        return $this->success('生成二维码', [], 1, 1);
+        return $this->success('生成二维码', ['qrcode'=>$this->request->domain().'/'.$result], 1, 1);
     }
     }
 }
 }

+ 20 - 13
app/workerapi/logic/GoodsCategoryLogic.php

@@ -5,6 +5,7 @@ use app\common\logic\BaseLogic;
 use app\common\service\wechat\WeChatConfigService;
 use app\common\service\wechat\WeChatConfigService;
 use app\common\service\wechat\WeChatMnpService;
 use app\common\service\wechat\WeChatMnpService;
 use EasyWeChat\MiniApp\Application;
 use EasyWeChat\MiniApp\Application;
+use think\facade\Db;
 
 
 /**
 /**
  * 服务商品逻辑处理
  * 服务商品逻辑处理
@@ -14,22 +15,28 @@ use EasyWeChat\MiniApp\Application;
 class GoodsCategoryLogic extends BaseLogic
 class GoodsCategoryLogic extends BaseLogic
 {
 {
     /**
     /**
-     * @return \EasyWeChat\Kernel\HttpClient\Response|false|\Symfony\Contracts\HttpClient\ResponseInterface
+     * @return string|void
      */
      */
     public static function getQRCode()
     public static function getQRCode()
     {
     {
-        $config = WeChatConfigService::getMnpConfig();
-
-        $app = new Application($config);
-        $response = $app->getClient()->postJson('/wxa/getwxacodeunlimit', [
-            'scene' => '123',
-            'page' => 'pages/good/good',
-            'width' => 430,
-            'check_path' => false,
-            'env_vesion' => 'trial'
-        ]);
-        dd($response);
-
+        try {
+            $response = (new WeChatMnpService())->getUnlimitedQRCode(
+                'type=2&id=19',
+                "pages/good/good",
+                'trial',
+                false
+            );
+            $qrcode = $response->getContent();
+            if(!is_dir('./uploads/wx_qrcode/'.date('Ymd'))){
+                mkdir('./uploads/wx_qrcode/'.date('Ymd'));
+            }
+            $file_name = 'uploads/wx_qrcode/'.date('Ymd').'/'.time().rand(1000,9999).'.png';
+            file_put_contents($file_name, $qrcode);
+            return $file_name;
+        } catch (\Throwable $e) {
+            // 失败
+            echo $e->getMessage();
+        }
     }
     }
 
 
 }
 }