|
|
@@ -5,6 +5,7 @@ use app\common\logic\BaseLogic;
|
|
|
use app\common\service\wechat\WeChatConfigService;
|
|
|
use app\common\service\wechat\WeChatMnpService;
|
|
|
use EasyWeChat\MiniApp\Application;
|
|
|
+use think\facade\Db;
|
|
|
|
|
|
/**
|
|
|
* 服务商品逻辑处理
|
|
|
@@ -14,22 +15,28 @@ use EasyWeChat\MiniApp\Application;
|
|
|
class GoodsCategoryLogic extends BaseLogic
|
|
|
{
|
|
|
/**
|
|
|
- * @return \EasyWeChat\Kernel\HttpClient\Response|false|\Symfony\Contracts\HttpClient\ResponseInterface
|
|
|
+ * @return string|void
|
|
|
*/
|
|
|
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();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|