| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace addons\pickup\controller;
- use app\common\controller\Api;
- use think\Config;
- use think\Validate;
- use think\Db;
- use app\common\library\Sms as Smslib;
- use Endroid\QrCode\QrCode;
- //use think\addons\Controller;
- use think\Response;
- /**
- * 微信接口
- */
- //class Index extends Api{
- class Index extends \think\addons\Controller {
- public function _initialize() {
- parent::_initialize();
- }
- /**
- *插件首页
- */
- public function index() {
- return $this->view->fetch();
- }
- //生成二维码
- public function qrcode() {
- $config = get_addon_config('qrcode');
- $text = $this->request->get('text', request()->domain().'/addons/pickup#/pages/index/index');
- $size = intval($this->request->get('size', 250));
- $padding = $this->request->get('padding', 5);
- $errorcorrection = $this->request->get('errorcorrection', 'medium');
- $foreground = $this->request->get('foreground', "#000000");
- $background = $this->request->get('background', "#ffffff");
- $params = [
- 'text' => $text,
- 'size' => $size,
- 'padding' => $padding,
- 'errorlevel' => $errorcorrection,
- 'foreground' => $foreground,
- 'background' => $background,
- 'format' => 'png',
- ];
- $qrCode = \addons\pickup\library\Service::qrcode($params);
- //也可以直接使用render方法输出结果
- $mimetype='image/png';
- $response = Response::create()->header("Content-Type", $mimetype);
- // 直接显示二维码
- header('Content-Type: ' . $qrCode->getContentType());
- $response->content($qrCode->writeString());
- return $response;
- }
- }
|