NewsQrcodeController.class.php 796 Bytes
<?php
/**
 * 新闻预览二维码
 * User: wangjiayu
 * Date: 2017-12-22
 */
namespace Frontend\Controller\Index;

use Com\QRcode;

class NewsQrcodeController extends AbstractController
{

    // 免登录
    protected $_require_login = false;

    /**
     * @author wangjiayu
     * @desc 新闻预览二维码扫码跳转
     * @param Int article_id 新闻ID
     */
    public function Index()
    {

        $article_id = I('get.article_id', '', 'trim');

        if (empty($article_id)) {

            E('_ERR_ARTICLE_ID_IS_EMPTY');
        }

        $url = oaUrl('Frontend/Index/NewsScan/Index', ['article_id' => $article_id]);
        $qrCode = QRcode::png($url, false, QR_ECLEVEL_L, 12, 1);
        header('Content-Type: image/png');
        imagepng($qrCode);
        exit;
    }
}