mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-11-30 02:49:03 +08:00
1.5
This commit is contained in:
parent
9e2ac699b8
commit
66aa691ef7
@ -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()
|
||||
{
|
||||
require_once ROOT.'extend'.DS.'qrcode'.DS.'phpqrcode.php';
|
||||
|
||||
$params = input();
|
||||
$level = isset($params['level']) && in_array($params['level'], array('L','M','Q','H')) ? $params['level'] : 'L';
|
||||
$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);
|
||||
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();
|
||||
if(empty($params['url']))
|
||||
{
|
||||
$this->assign('msg', 'url参数为空');
|
||||
return $this->fetch('public/tips_error');
|
||||
}
|
||||
|
||||
(new \base\Qrcode())->Download($params);
|
||||
}
|
||||
}
|
||||
?>
|
@ -111,7 +111,8 @@ class Service
|
||||
$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']);
|
||||
|
@ -162,7 +162,7 @@
|
||||
</td>
|
||||
<td class="row-qucode">
|
||||
<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>
|
||||
</a>
|
||||
</td>
|
||||
|
@ -19,7 +19,7 @@ return [
|
||||
// 应用地址
|
||||
'app_host' => '',
|
||||
// 应用调试模式
|
||||
'app_debug' => true,
|
||||
'app_debug' => false,
|
||||
// 应用Trace
|
||||
'app_trace' => false,
|
||||
// 是否支持多模块
|
||||
|
88
extend/base/Qrcode.php
Normal file
88
extend/base/Qrcode.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user