mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-02 03:48:47 +08:00
应用
This commit is contained in:
parent
b7ff24ee17
commit
2fc196b820
@ -13,6 +13,7 @@ namespace app\plugins\petscms;
|
||||
use think\Db;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\RegionService;
|
||||
use app\service\PluginsService;
|
||||
|
||||
/**
|
||||
* 宠物管理系统 - 服务层
|
||||
@ -111,8 +112,8 @@ class Service
|
||||
$v['lose_features'] = str_replace("\n", '<br />', $v['lose_features']);
|
||||
|
||||
// 二维码
|
||||
$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', ['url'=>urlencode(base64_encode($v['qrcode_url']))]);
|
||||
$v['qrcode_url'] = empty($v['qrcode_images']) ? MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(PluginsHomeUrl('petscms', 'pets', 'detail', ['id'=>$v['id']])))]) : ResourcesService::AttachmentPathViewHandle($v['qrcode_images']);
|
||||
$v['qrcode_download'] = MyUrl('index/qrcode/download', ['url'=>urlencode(base64_encode($v['qrcode_url'])), 'filename'=>$v['pest_no']]);
|
||||
|
||||
// 地址
|
||||
$v['province_name'] = RegionService::RegionName($v['lose_province']);
|
||||
@ -126,7 +127,6 @@ class Service
|
||||
$v['upd_time_date'] = empty($v['upd_time']) ? '' : date('Y-m-d', $v['upd_time']);
|
||||
}
|
||||
}
|
||||
//print_r($data);
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
|
||||
@ -406,8 +406,12 @@ class Service
|
||||
{
|
||||
$data['pest_no'] = date('YmdHis').GetNumberCode(6);
|
||||
$data['add_time'] = time();
|
||||
if(Db::name('PluginsPetscmsPets')->insertGetId($data) > 0)
|
||||
$pets_id = Db::name('PluginsPetscmsPets')->insertGetId($data);
|
||||
if($pets_id > 0)
|
||||
{
|
||||
// 生成二维码
|
||||
self::PetsQrcodeCreate($pets_id);
|
||||
|
||||
return DataReturn('添加成功', 0);
|
||||
}
|
||||
return DataReturn('添加失败', -100);
|
||||
@ -421,6 +425,37 @@ class Service
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 宠物二维码生成
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-04-19
|
||||
* @desc description
|
||||
* @param [type] $pets_id [description]
|
||||
*/
|
||||
private static function PetsQrcodeCreate($pets_id)
|
||||
{
|
||||
if(!empty($pets_id))
|
||||
{
|
||||
$base = PluginsService::PluginsData('petscms', ['logo']);
|
||||
$params = [
|
||||
'path' => DS.'static'.DS.'upload'.DS.'images'.DS.'plugins_petscms'.DS.'qrcode'.DS.date('Y').DS.date('m').DS.date('d').DS,
|
||||
'content' => PluginsHomeUrl('petscms', 'pets', 'detail', ['id'=>$pets_id]),
|
||||
'logo' => empty($base['data']['logo']) ? '' : $base['data']['logo'],
|
||||
];
|
||||
$ret = (new \base\Qrcode())->Create($params);
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
if(!Db::name('PluginsPetscmsPets')->where(['id'=>$pets_id])->update(['qrcode_images'=>$ret['data']['path'].$ret['data']['filename'], 'upd_time'=>time()]))
|
||||
{
|
||||
return DataReturn('二维码生成失败', -10);
|
||||
}
|
||||
}
|
||||
}
|
||||
return DataReturn('二维码生成成功', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宠物相册
|
||||
* @author Devil
|
||||
|
@ -4,6 +4,7 @@ CREATE TABLE `s_plugins_petscms_pets` (
|
||||
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
|
||||
`pest_no` char(60) NOT NULL DEFAULT '' COMMENT '宠物编号',
|
||||
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态(0正常, 1丢失, 2去世, 3关闭)',
|
||||
`qrcode_images` char(255) NOT NULL DEFAULT '' COMMENT '宠物二维码',
|
||||
`title` char(60) NOT NULL DEFAULT '' COMMENT '标题',
|
||||
`name` char(30) NOT NULL DEFAULT '' COMMENT '名字',
|
||||
`birthday` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '出生日期',
|
||||
@ -36,7 +37,6 @@ CREATE TABLE `s_plugins_petscms_pets` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='宠物管理系统宠物 - 应用'
|
||||
|
||||
|
||||
|
||||
# 宠物管理系统宠物丢失帮助数据
|
||||
CREATE TABLE `s_plugins_petscms_help` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
|
@ -215,34 +215,36 @@
|
||||
{{/if}}
|
||||
{{else /}}
|
||||
<div class="pets-not-bind">
|
||||
<p><i class="am-icon-github-alt am-animation-slide-top"></i></p>
|
||||
<p><i class="am-icon-github-alt"></i></p>
|
||||
{{if !empty($plugins_base_data['not_bind_desc'])}}
|
||||
<div class="am-alert am-alert-secondary am-animation-shake" data-am-alert>
|
||||
{{$plugins_base_data.not_bind_desc|raw}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo', ['pest_no'=>$data['pest_no']])}}" class="am-btn am-btn-primary am-radius am-icon-get-pocket am-animation-slide-bottom"> {{if empty($plugins_base_data['pets_take'])}}我要领取{{else /}}{{$plugins_base_data.pets_take}}{{/if}}</a>
|
||||
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo', ['pest_no'=>$data['pest_no']])}}" class="am-btn am-btn-primary am-radius am-icon-get-pocket"> {{if empty($plugins_base_data['pets_take'])}}我要领取{{else /}}{{$plugins_base_data.pets_take}}{{/if}}</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_images']) or !empty($plugins_base_data['weixin_qrcode_images'])}}
|
||||
<ul class="qrcode am-animation-slide-bottom">
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_images'])}}
|
||||
<li>
|
||||
<img src="{{$plugins_base_data.alipay_qrcode_images}}" alt="二维码" />
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_name'])}}
|
||||
<p>{{$plugins_base_data.alipay_qrcode_name}}</p>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_base_data['weixin_qrcode_images'])}}
|
||||
<li>
|
||||
<img src="{{$plugins_base_data.weixin_qrcode_images}}" alt="二维码" />
|
||||
{{if !empty($plugins_base_data['weixin_qrcode_name'])}}
|
||||
<p>{{$plugins_base_data.weixin_qrcode_name}}</p>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_images']) or !empty($plugins_base_data['weixin_qrcode_images'])}}
|
||||
<div class="pets-qrcode-related">
|
||||
<ul>
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_images'])}}
|
||||
<li>
|
||||
<img src="{{$plugins_base_data.alipay_qrcode_images}}" alt="二维码" />
|
||||
{{if !empty($plugins_base_data['alipay_qrcode_name'])}}
|
||||
<p>{{$plugins_base_data.alipay_qrcode_name}}</p>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_base_data['weixin_qrcode_images'])}}
|
||||
<li>
|
||||
<img src="{{$plugins_base_data.weixin_qrcode_images}}" alt="二维码" />
|
||||
{{if !empty($plugins_base_data['weixin_qrcode_name'])}}
|
||||
<p>{{$plugins_base_data.weixin_qrcode_name}}</p>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -34,8 +34,8 @@ class FileUpload
|
||||
*/
|
||||
public function __construct($params = [])
|
||||
{
|
||||
$this->config['root_path'] = isset($params['root_path']) ? $params['root_path'] : ROOT_PATH;
|
||||
$this->config['path'] = isset($params['path']) ? $params['path'] : DS.'Public'.DS.'Upload'.DS.'file'.DS.date('Y').DS.date('m').DS.date('d').DS;
|
||||
$this->config['root_path'] = isset($params['root_path']) ? $params['root_path'] : ROOT.'public';
|
||||
$this->config['path'] = isset($params['path']) ? $params['path'] : DS.'static'.DS.'upload'.DS.'file'.DS.date('Y').DS.date('m').DS.date('d').DS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,9 @@ namespace base;
|
||||
*/
|
||||
class Qrcode
|
||||
{
|
||||
// 配置
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
@ -29,6 +32,10 @@ class Qrcode
|
||||
public function __construct()
|
||||
{
|
||||
require_once ROOT.'extend'.DS.'qrcode'.DS.'phpqrcode.php';
|
||||
|
||||
// 默认配置
|
||||
$this->config['root_path'] = isset($params['root_path']) ? $params['root_path'] : ROOT.'public';
|
||||
$this->config['path'] = isset($params['path']) ? $params['path'] : DS.'static'.DS.'upload'.DS.'images'.DS.'qrcode'.DS.date('Y').DS.date('m').DS.date('d').DS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +52,7 @@ class Qrcode
|
||||
$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;
|
||||
$point_size = isset($params['size']) ? min(max(intval($params['size']), 1), 30) : 6;
|
||||
|
||||
// 外边距
|
||||
$mr = isset($params['mr']) ? intval($params['mr']) : 1;
|
||||
@ -57,6 +64,98 @@ class Qrcode
|
||||
\QRcode::png($content, false, $level, $point_size, $mr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 二维码创建
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-04-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function Create($params = [])
|
||||
{
|
||||
// 数据参数
|
||||
if(empty($params['content']))
|
||||
{
|
||||
return DataReturn('内容不能为空', -1);
|
||||
}
|
||||
|
||||
// 自定义路径
|
||||
if(!empty($params['root_path']))
|
||||
{
|
||||
$this->config['root_path'] = $params['root_path'];
|
||||
}
|
||||
if(!empty($params['path']))
|
||||
{
|
||||
$this->config['path'] = $params['path'];
|
||||
}
|
||||
|
||||
// 存储目录校验
|
||||
$dir = str_replace(['//', '\\\\'], ['/', '\\'], $this->config['root_path'].$this->config['path']);
|
||||
$ret = $this->IsMkdir($dir);
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 文件名称
|
||||
$filename = empty($params['filename']) ? $this->RandNewFilename().'.png' : $params['filename'];
|
||||
|
||||
// 容错率
|
||||
$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), 30) : 10;
|
||||
|
||||
// 外边距
|
||||
$mr = isset($params['mr']) ? intval($params['mr']) : 2;
|
||||
|
||||
// 生成二维码
|
||||
\QRcode::png($params['content'], $dir.$filename, $level, $point_size, $mr);
|
||||
if(!file_exists($dir.$filename))
|
||||
{
|
||||
return DataReturn('二维码创建失败', -100);
|
||||
}
|
||||
|
||||
//判断是否生成带logo的二维码
|
||||
if(!empty($params['logo']))
|
||||
{
|
||||
$logo = @file_get_contents($params['logo']);
|
||||
if($logo !== false)
|
||||
{
|
||||
$qr = imagecreatefromstring(file_get_contents($dir.$filename)); //目标图象连接资源
|
||||
$logo = imagecreatefromstring($logo); //源图象连接资源
|
||||
|
||||
$qr_width = imagesx($qr);
|
||||
$qr_height = imagesy($qr);
|
||||
$logo_width = imagesx($logo);
|
||||
$logo_height = imagesy($logo);
|
||||
$logo_qr_width = $qr_width / 5; //组合之后logo的宽度(占二维码的1/5)
|
||||
$scale = $logo_width/$logo_qr_width; //logo的宽度缩放比(本身宽度/组合后的宽度)
|
||||
$logo_qr_height = $logo_height/$scale; //组合之后logo的高度
|
||||
$from_width = ($qr_width - $logo_qr_width) / 2; //组合之后logo左上角所在坐标点
|
||||
|
||||
//重新组合图片并调整大小
|
||||
imagecopyresampled($qr, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,$logo_qr_height, $logo_width, $logo_height);
|
||||
|
||||
//输出图片
|
||||
imagepng($qr, $dir.$filename);
|
||||
imagedestroy($qr);
|
||||
imagedestroy($logo);
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'dir' => $dir.$filename,
|
||||
'root' => $this->config['root_path'],
|
||||
'path' => $this->config['path'],
|
||||
'filename' => $filename,
|
||||
];
|
||||
return DataReturn('创建成功', 0, $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 二维码下载
|
||||
* @author Devil
|
||||
@ -71,7 +170,7 @@ class Qrcode
|
||||
$url = base64_decode(urldecode($params['url']));
|
||||
|
||||
// 随机文件名
|
||||
$filename = time().GetNumberCode().'.png';
|
||||
$filename = empty($params['filename']) ? date('YmdHis').GetNumberCode().'.png' : $params['filename'].'.png';
|
||||
|
||||
// 设置头信息
|
||||
header('Pragma: public');
|
||||
@ -84,5 +183,76 @@ class Qrcode
|
||||
header('Connection: close');
|
||||
readfile($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成新的文件名称
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-06-29
|
||||
* @desc description
|
||||
* @return [string] [文件名称]
|
||||
*/
|
||||
private function RandNewFilename()
|
||||
{
|
||||
return date('YmdHis').rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径不存在则创建
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-06-29
|
||||
* @desc description
|
||||
* @param [string] $dir [文件路径]
|
||||
*/
|
||||
private function IsMkdir($dir)
|
||||
{
|
||||
if(!is_dir($dir))
|
||||
{
|
||||
// 目录是否有权限
|
||||
$ret = $this->IsWritable($dir);
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 创建目录
|
||||
if(mkdir($dir, 0777, true) === false)
|
||||
{
|
||||
return DataReturn('目录创建失败', -1);
|
||||
}
|
||||
}
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录是否有权限
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-04-19
|
||||
* @desc description
|
||||
* @param [string] $dir [文件路径]
|
||||
*/
|
||||
private function IsWritable($dir)
|
||||
{
|
||||
$dirs = str_replace($this->config['root_path'], '', $dir);
|
||||
$dll = explode(DS, $dirs);
|
||||
if(!empty($dll) && is_array($dll))
|
||||
{
|
||||
$dstr = '';
|
||||
foreach($dll as $d)
|
||||
{
|
||||
$dstr .= empty($d) ? '' : DS.$d;
|
||||
if(is_dir($this->config['root_path'].$dstr) && !is_writable($this->config['root_path'].$dstr))
|
||||
{
|
||||
return DataReturn('目录没有权限['.$dstr.']', -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return DataReturn('有权限', 0);
|
||||
}
|
||||
}
|
||||
?>
|
@ -35,8 +35,8 @@ form.am-form .am-form-group-label-tips-must { color: #f00; }
|
||||
.am-tagsinput input[type="text"]:hover { box-shadow: 0 0 0 #fff !important; border: 0 !important; }
|
||||
.chosen-choices li.search-field input[type="text"]:focus,
|
||||
.am-tagsinput input[type="text"]:focus { border-color: #fff; -webkit-box-shadow: inset 0 0 0 0 !important; box-shadow: inset 0 0 0 0 !important; }
|
||||
.chosen-choices { padding: 0px 3px !important; min-height: 32px; }
|
||||
.chosen-container-single .chosen-single { height: 32px; line-height: 32px; }
|
||||
.chosen-choices { padding: 0px 3px !important; min-height: 28px; }
|
||||
.chosen-container-single .chosen-single { height: 28px; line-height: 28px; }
|
||||
.chosen-container-multi .chosen-choices li.search-field { padding-left: 3px; }
|
||||
.chosen-container-single .chosen-single { color: #444 !important; }
|
||||
.chosen-container-single .chosen-default { color: #999 !important; }
|
||||
|
@ -74,29 +74,37 @@
|
||||
.pets-not-bind .am-btn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.pets-not-bind ul.qrcode {
|
||||
overflow: hidden;
|
||||
|
||||
/**
|
||||
* 相关二维码
|
||||
*/
|
||||
.pets-qrcode-related {
|
||||
margin-top: 30px;
|
||||
}
|
||||
.pets-qrcode-related ul {
|
||||
margin: 0 auto;
|
||||
max-width: 600px;
|
||||
overflow: hidden;
|
||||
border: 1px solid;
|
||||
border-top: 5px solid;
|
||||
border-color: #eee;
|
||||
border-color: #1aa9f3;
|
||||
}
|
||||
.pets-not-bind ul.qrcode li {
|
||||
.pets-qrcode-related li {
|
||||
width: 50%;
|
||||
float: left;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
.pets-not-bind ul.qrcode li:first-child {
|
||||
.pets-qrcode-related li:first-child {
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
.pets-not-bind ul.qrcode li:last-child {
|
||||
.pets-qrcode-related li:last-child {
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
.pets-not-bind ul.qrcode li img {
|
||||
.pets-qrcode-related li img {
|
||||
max-width: 150px;
|
||||
}
|
||||
.pets-not-bind ul.qrcode li p {
|
||||
.pets-qrcode-related li p {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
@ -237,7 +245,7 @@ form.form-validation #map {
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width: 641px) {
|
||||
.base, .lose, .content {
|
||||
.base, .lose, .content, .pets-qrcode-related {
|
||||
padding: 0 5px;
|
||||
}
|
||||
.base h1 {
|
||||
|
0
public/static/upload/images/plugins_petscms/2019/04/09/1554814711403578.jpg
Normal file → Executable file
0
public/static/upload/images/plugins_petscms/2019/04/09/1554814711403578.jpg
Normal file → Executable file
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in New Issue
Block a user