提交 66aa691e 编写于 作者: G gongfuxiang

1.5

上级 9e2ac699
...@@ -28,18 +28,41 @@ class QrCode extends Common ...@@ -28,18 +28,41 @@ class QrCode extends Common
} }
/** /**
* [Index 首页方法] * 二维码显示
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-16T21:52:09+0800
*/ */
public function Index() public function Index()
{ {
require_once ROOT.'extend'.DS.'qrcode'.DS.'phpqrcode.php'; $params = input();
if(empty($params['content']))
{
$this->assign('msg', '内容参数为空');
return $this->fetch('public/tips_error');
}
(new \base\Qrcode())->View($params);
}
/**
* 二维码下载
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-16T21:52:18+0800
*/
public function Download()
{
$params = input(); $params = input();
$level = isset($params['level']) && in_array($params['level'], array('L','M','Q','H')) ? $params['level'] : 'L'; if(empty($params['url']))
$point_size = isset($params['size']) ? min(max(intval($params['size']), 1), 10) : 6; {
$mr = isset($params['mr']) ? intval($params['mr']) : 1; $this->assign('msg', 'url参数为空');
$content = isset($params['content']) ? base64_decode(urldecode(trim($params['content']))) : __MY_URL__; return $this->fetch('public/tips_error');
\QRcode::png($content, false, $level, $point_size, $mr); }
(new \base\Qrcode())->Download($params);
} }
} }
?> ?>
\ No newline at end of file
...@@ -111,7 +111,8 @@ class Service ...@@ -111,7 +111,8 @@ class Service
$v['lose_features'] = str_replace("\n", '<br />', $v['lose_features']); $v['lose_features'] = str_replace("\n", '<br />', $v['lose_features']);
// 二维码 // 二维码
$v['qrcode_url'] = MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$v['id']], true, true)))]); $v['qrcode_url'] = MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(PluginsHomeUrl('petscms', 'pets', 'detail', ['id'=>$v['id']])))]);
$v['qrcode_download'] = MyUrl('index/qrcode/download', ['ssurl'=>urlencode(base64_encode($v['qrcode_url']))]);
// 地址 // 地址
$v['province_name'] = RegionService::RegionName($v['lose_province']); $v['province_name'] = RegionService::RegionName($v['lose_province']);
......
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
</td> </td>
<td class="row-qucode"> <td class="row-qucode">
<img src="{{$v.qrcode_url}}" alt="{{$v.title}}" /> <img src="{{$v.qrcode_url}}" alt="{{$v.title}}" />
<a href="#"> <a href="{{$v.qrcode_download}}" target="_blank" title="下载二维码">
<p><i class="am-icon-cloud-download"></i> 下载二维码</p> <p><i class="am-icon-cloud-download"></i> 下载二维码</p>
</a> </a>
</td> </td>
......
...@@ -19,7 +19,7 @@ return [ ...@@ -19,7 +19,7 @@ return [
// 应用地址 // 应用地址
'app_host' => '', 'app_host' => '',
// 应用调试模式 // 应用调试模式
'app_debug' => true, 'app_debug' => false,
// 应用Trace // 应用Trace
'app_trace' => false, 'app_trace' => false,
// 是否支持多模块 // 是否支持多模块
......
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace base;
/**
* 二维码驱动
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Qrcode
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-16T21:13:10+0800
*/
public function __construct()
{
require_once ROOT.'extend'.DS.'qrcode'.DS.'phpqrcode.php';
}
/**
* 二维码展示
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-16T21:13:16+0800
* @param [array] $params [输入参数]
*/
public function View($params = [])
{
// 容错率
$level = isset($params['level']) && in_array($params['level'], array('L','M','Q','H')) ? $params['level'] : 'L';
// 大小,最小1,最大10
$point_size = isset($params['size']) ? min(max(intval($params['size']), 1), 10) : 6;
// 外边距
$mr = isset($params['mr']) ? intval($params['mr']) : 1;
// 内容
$content = isset($params['content']) ? base64_decode(urldecode(trim($params['content']))) : __MY_URL__;
// 生成二维码并输出页面显示
\QRcode::png($content, false, $level, $point_size, $mr);
}
/**
* 二维码下载
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-04-16T21:23:01+0800
* @param [array] $params [输入参数]
*/
public function Download($params = [])
{
// 图片地址
$url = base64_decode(urldecode($params['url']));
// 随机文件名
$filename = time().GetNumberCode().'.png';
// 设置头信息
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile($url);
}
}
?>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册