提交 5ab7fd86 编写于 作者: D devil_gong

附件/细节优化

上级 7cac1f6a
......@@ -305,7 +305,7 @@
<!-- 相册 -->
<div id="goods-nav-photo" class="division-block">
<label class="block nav-detail-title">商品相册<span class="am-form-group-label-tips">可拖拽图片进行排序,建议图片尺寸一致</span></label>
<ul class="plug-file-upload-view goods-photo-view" data-form-name="photo[]" data-max-number="5" data-dialog-type="images">
<ul class="plug-file-upload-view goods-photo-view" data-form-name="photo[]" data-max-number="30" data-dialog-type="images">
{{if !empty($data['photo'])}}
{{foreach $data.photo as $v}}
<li>
......
......@@ -36,7 +36,7 @@ class Devtest extends Common
}
/**
* 附件
* 附件初始化 1.6升级运行
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
......@@ -49,10 +49,6 @@ class Devtest extends Common
die('非法访问');
}
$count = 0;
$success = 0;
$error = 0;
$path_all = [
'video' => __MY_ROOT_PUBLIC__.'static/upload/video/',
'file' => __MY_ROOT_PUBLIC__.'static/upload/file/',
......@@ -61,77 +57,19 @@ class Devtest extends Common
foreach($path_all as $type=>$path)
{
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
// 从磁盘获取文件
$files = $this->GetDirFilesList($path, $type, $path);
if(!empty($files))
$handle = opendir($path);
while(false !== ($file = readdir($handle)))
{
$count += count($files);
foreach($files as $v)
if($file != 'index.html' && $file != '.' && $file != '..' && substr($file, 0, 1) != '.')
{
$temp = Db::name('Attachment')->where(['title'=>$v['title'], 'hash'=>$v['hash']])->find();
if(empty($temp))
$ret = ResourcesService::AttachmentDiskFilesToDb($file);
if(isset($ret['msg']))
{
$ret = ResourcesService::AttachmentAdd($v);
if($ret['code'] == 0)
{
$success++;
} else {
$error++;
}
} else {
$success++;
echo $ret['msg'];
}
}
}
}
echo '总数['.$count.'], 成功['.$success.'], 失败['.$error.']';
}
/**
* 遍历获取目录下的指定类型的文件
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-01-17T23:24:59+0800
* @param [string] $path [路径地址]
* @param [string] $type [允许的文件]
* @param [array] &$files [数据]
* @return [array] [数据]
*/
private function GetDirFilesList($path, $type, $path_old, &$files = array())
{
if(!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
$handle = opendir($path);
$document_root = GetDocumentRoot();
while(false !== ($file = readdir($handle)))
{
if($file != 'index.html' && $file != '.' && $file != '..' && substr($file, 0, 1) != '.')
{
$path2 = $path . $file;
if(is_dir($path2))
{
$this->GetDirFilesList($path2, $type, $path_old, $files);
} else {
$url = ResourcesService::AttachmentPathHandle(substr($path2, strlen($document_root)));
$title = substr($url, strripos($url, '/')+1);
$root_path = ROOT.'public'.$url;
$path_type = str_replace($path_old, '', $root_path);
$files[] = array(
'url' => $url,
'original' => $title,
'title' => $title,
'type' => $type,
'path_type' => substr($path_type, 0, stripos($path_type, '/')),
'size' => file_exists($root_path) ? filesize($root_path) : 0,
'hash' => file_exists($root_path) ? hash_file('sha256', $root_path, false) : '',
'ext' => substr($title, strripos($title, '.')),
);
}
}
}
return $files;
}
}
?>
\ No newline at end of file
......@@ -230,28 +230,28 @@
{{if !empty($floor['goods'])}}
{{foreach $floor.goods as $goods_key=>$goods}}
<div class="goods-items">
<!-- 首页楼层商品内部顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_home_goods_inside_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_home_goods_inside_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'floor_id'=>$key+1, 'goods_id'=>$goods['id'], 'goods'=>$goods]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
<a href="{{$goods.goods_url}}" target="_blank" class="am-block">
<!-- 首页楼层商品内部顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_home_goods_inside_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_home_goods_inside_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'floor_id'=>$key+1, 'goods_id'=>$goods['id'], 'goods'=>$goods]);
if(!empty($hook_data) && is_array($hook_data))
{
if(is_string($hook) || is_int($hook))
foreach($hook_data as $hook)
{
echo htmlspecialchars_decode($hook);
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
}
{{/php}}
<a href="{{$goods.goods_url}}" target="_blank">
<img src="{{$goods.home_recommended_images}}" alt="{{$goods.title}}" />
{{/php}}
<img src="{{$goods.home_recommended_images}}" alt="{{$goods.title}}" class="goods-images" />
</a>
<div class="outer-con">
<div class="goods-title am-text-truncate">
......
......@@ -2,32 +2,30 @@
{{foreach $data as $v}}
<li class="am-animation-scale-up">
<div class="items">
<!-- 搜索页面商品信息顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_search_goods_inside_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_search_goods_inside_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'goods_id'=>$v['id'], 'goods'=>$v]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
<a href="{{$v.goods_url}}" target="_blank" class="am-block">
<!-- 搜索页面商品信息顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_search_goods_inside_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_search_goods_inside_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'goods_id'=>$v['id'], 'goods'=>$v]);
if(!empty($hook_data) && is_array($hook_data))
{
if(is_string($hook) || is_int($hook))
foreach($hook_data as $hook)
{
echo htmlspecialchars_decode($hook);
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
}
{{/php}}
{{/php}}
<a href="{{$v.goods_url}}" target="_blank" class="goods-images">
<img src="{{$v.images}}" alt="{{$v.title}}">
</a>
<a href="{{$v.goods_url}}" target="_blank" class="goods-title">
<p class="am-text-truncate am-padding-xs" title="{{$v.title}}">{{$v.title}}</p>
<img src="{{$v.images}}" alt="{{$v.title}}" class="goods-images" />
<p class="am-text-truncate am-padding-xs goods-title" title="{{$v.title}}">{{$v.title}}</p>
</a>
<p class="am-padding-horizontal-xs am-cf">
<span class="am-fl original-price">¥{{$v.original_price}}</span>
......
......@@ -27,7 +27,7 @@
{{/if}}
<!-- content -->
<div class="am-container search-content" data-category-id="{{$params.category_id}}">
<div class="am-container" data-category-id="{{$params.category_id}}">
<!-- 搜索页面顶部内部结构里面钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
......@@ -42,7 +42,7 @@
{{/foreach}}
{{/if}}
<div class="search-list am-u-sm-12 am-u-md-12 am-padding-left-0 am-padding-right-0">
<div class="search-container am-u-sm-12 am-u-md-12 am-padding-left-0 am-padding-right-0">
<div class="theme-popover">
<ul class="select">
<p class="title-tips">
......@@ -198,7 +198,7 @@
{{/if}}
<!-- 数据容器 -->
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 data-list"></ul>
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 search-list"></ul>
<!-- 搜索页面数据容器底部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
......
......@@ -114,7 +114,7 @@ class PluginsAdminService
// 添加数据
if(Db::name('Plugins')->insertGetId($data) > 0)
{
return DataReturn('安装成功');
return DataReturn('安装成功');
} else {
return DataReturn('安装失败', -100);
}
......@@ -1073,6 +1073,9 @@ php;
}
}
// 附件同步到数据库
ResourcesService::AttachmentDiskFilesToDb('plugins_'.$plugins_name);
// sql运行
$install_sql = APP_PATH.'plugins'.DS.$plugins_name.DS.'install.sql';
if(!empty($plugins_name) && file_exists($install_sql))
......
......@@ -359,5 +359,101 @@ class ResourcesService
}
return DataReturn('删除失败', -100);
}
/**
* 磁盘附加同步到数据库
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-08-02
* @desc description
* @param [string] $path_type [附件路径类型]
*/
public static function AttachmentDiskFilesToDb($path_type)
{
// 处理状态总数
$count = 0;
$success = 0;
$error = 0;
// 视频/文件/图片
$path_all = [
'video' => __MY_ROOT_PUBLIC__.'static/upload/video/'.$path_type.'/',
'file' => __MY_ROOT_PUBLIC__.'static/upload/file/'.$path_type.'/',
'image' => __MY_ROOT_PUBLIC__.'static/upload/images/'.$path_type.'/',
];
foreach($path_all as $type=>$path)
{
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
$files =self::AttachmentDiskFilesList($path, $type, $path_type);
if(!empty($files))
{
$count += count($files);
foreach($files as $v)
{
$temp = Db::name('Attachment')->where(['title'=>$v['title'], 'hash'=>$v['hash']])->find();
if(empty($temp))
{
$ret = self::AttachmentAdd($v);
if($ret['code'] == 0)
{
$success++;
} else {
$error++;
}
} else {
$success++;
}
}
}
}
return DataReturn('总数['.$count.'], 成功['.$success.'], 失败['.$error.']', 0);
}
/**
* 遍历获取目录下的指定类型的文件
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-01-17T23:24:59+0800
* @param [string] $path [路径地址]
* @param [string] $type [允许的文件]
* @param [string] $path_type [路径类型]
* @param [array] &$files [数据]
* @return [array] [数据]
*/
public static function AttachmentDiskFilesList($path, $type, $path_type, &$files = [])
{
if(!is_dir($path)) return null;
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
$handle = opendir($path);
$document_root = GetDocumentRoot();
while(false !== ($file = readdir($handle)))
{
if($file != 'index.html' && $file != '.' && $file != '..' && substr($file, 0, 1) != '.')
{
$temp_path = $path . $file;
if(is_dir($temp_path))
{
self::AttachmentDiskFilesList($temp_path, $type, $path_type, $files);
} else {
$url = self::AttachmentPathHandle(substr($temp_path, strlen($document_root)));
$title = substr($url, strripos($url, '/')+1);
$root_path = ROOT.'public'.$url;
$files[] = array(
'url' => $url,
'original' => $title,
'title' => $title,
'type' => $type,
'path_type' => $path_type,
'size' => file_exists($root_path) ? filesize($root_path) : 0,
'hash' => file_exists($root_path) ? hash_file('sha256', $root_path, false) : '',
'ext' => substr($title, strripos($title, '.')),
);
}
}
}
return $files;
}
}
?>
\ No newline at end of file
......@@ -36,6 +36,7 @@ return array (
array (
0 => 'app\\plugins\\limitedtimediscount\\Hook',
1 => 'app\\plugins\\membershiplevelvip\\Hook',
2 => 'app\\plugins\\goodsphototag\\Hook',
),
'plugins_js' =>
array (
......@@ -103,5 +104,17 @@ return array (
array (
0 => 'app\\plugins\\membershiplevelvip\\Hook',
),
'plugins_view_goods_detail_photo_within' =>
array (
0 => 'app\\plugins\\goodsphototag\\Hook',
),
'plugins_view_home_goods_inside_top' =>
array (
0 => 'app\\plugins\\goodsphototag\\Hook',
),
'plugins_view_search_goods_inside_top' =>
array (
0 => 'app\\plugins\\goodsphototag\\Hook',
),
);
?>
\ No newline at end of file
此差异已折叠。
......@@ -43,8 +43,7 @@ text-align: center;float:none}
.aggregation .outer-con{ padding: 10px; text-align: center; }
/*楼层商品*/
.goods-items { background-color: #fff; }
.goods-items a { font-size: 12px; }
.floor .goods-list .goods-items { background-color: #fff; position: relative; overflow: hidden; }
.floor li {width: 50%;float: left;text-align: center;}
@media only screen and (min-width: 480px) {
.small-nav img{max-width: 100%;max-height: 100%;}
......@@ -75,8 +74,8 @@ text-align: center;float:none}
.floor .goods-list { overflow: hidden; }
.outer-con .describe {font-size: 14px;font-weight: 600;}
.goods-title, .outer-con .price { font-size: 14px; }
.floor .goods-list .goods-items { float: left; width: 25%; padding: 10px 15px; border-right: 1px solid; border-bottom: 1px solid; border-color: #eee; position: relative; overflow: hidden; }
.floor .goods-list .goods-items img { max-width: 100%; padding: 10px; }
.floor .goods-list .goods-items { float: left; width: 25%; padding: 10px 15px; border-right: 1px solid; border-bottom: 1px solid; border-color: #eee; }
.floor .goods-list .goods-items .goods-images { max-width: 100%; padding: 10px; }
.floor .aggregation img {position: absolute;top:auto;left:0;bottom:0;max-width: 100%;}
/*楼层 hover*/
......@@ -178,7 +177,7 @@ text-align: center;float:none}
.aggregation .word { padding: 10px; }
.word .outer { width: calc(33% - 12px); }
.floor .goods-list .goods-items { width: 50%; float: left; padding: 10px; border-bottom: 1px solid #eee; }
.floor .goods-list .goods-items img { padding: 10px; }
.floor .goods-list .goods-items .goods-images { padding: 10px; }
.floor .goods-list .goods-items:nth-of-type(2n + 1) { border-right: 1px solid #eee; }
.floor .goods-list .goods-items:nth-of-type(2n) { border-left: 1px solid transparent; }
}
\ No newline at end of file
.search-list { float: none; }
.search-container { float: none; }
.items img{ width:100%;}
.items .price strong{ font-size: 14px; }
.theme-popover {z-index: 1011;overflow:hidden;background:#fff; width: 100%; }
......@@ -44,7 +44,7 @@ li.select-result dt {left:-26px; top:0;font-weight:bold;width:50px;}
dl#select2 .dd-conent{ left:-100%; right:-100%;}
dl#select3 .dd-conent{ left:-200%; right:0px;}
.search-content .am-badge{font-size:12px ;padding:0px 0px;background-color: #999999;color: #ffffff;font-weight: 600;}
.search-container .am-badge{font-size:12px ;padding:0px 0px;background-color: #999999;color: #ffffff;font-weight: 600;}
.theme-popover-mask{z-index:1001;width: 100%;height: auto;position:fixed ;background:#000 ;top:0;opacity: 0.6;bottom: 0;}
/*搜索结果*/
......@@ -71,7 +71,7 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
.select-result dl dt{width:100px;}
.screening-remove-submit{width:80px;float:right;margin-right:20px;}
.search-content .am-badge{font-size:14px ;padding:0px 0px;background: none; }
.search-container .am-badge{font-size:14px ;padding:0px 0px;background: none; }
/*排序*/
.sort-nav{padding:0px 0px;margin:10px 5px; font-size: 12px;width:auto;overflow: hidden;}
......@@ -101,10 +101,10 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
.theme-popover { padding: 0px; margin-top: 10px; }
.sort-nav { margin: 10px 0; }
.search-nav .am-sticky-placeholder { margin: 10px 0 !important; }
.data-list { width: calc(100% + 10px); margin-left: -5px; }
.search-list { width: calc(100% + 10px); margin-left: -5px; }
/*选中效果*/
.search-list ul li:hover .items,.search-side li:hover .items.check{ -webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4); box-shadow:0px 12px 12px -10px rgba(0,0,0,.4); border: 4px solid #d2364c; -webkit-transition: border-color .2s ease-in; -moz-transition: border-color .2s ease-in; -ms-transition: border-color .2s ease-in; -o-transition: border-color .2s ease-in; transition: border-color .2s ease-in; }
.search-container ul li:hover .items,.search-side li:hover .items.check{ -webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4); box-shadow:0px 12px 12px -10px rgba(0,0,0,.4); border: 4px solid #d2364c; -webkit-transition: border-color .2s ease-in; -moz-transition: border-color .2s ease-in; -ms-transition: border-color .2s ease-in; -o-transition: border-color .2s ease-in; transition: border-color .2s ease-in; }
}
@media only screen and (max-width: 640px) {
......
......@@ -151,7 +151,7 @@ $(function()
{
// 请求参数处理
var data = {
category_id: $('.search-content').data('category-id') || 0,
category_id: $('.search-container').data('category-id') || 0,
wd: $('#search-input').val() || '',
page: page || parseInt($('.search-pages-submit').attr('data-page')) || 1,
order_by_field: $('.sort-nav li.active').attr('data-field') || 'default',
......@@ -165,7 +165,7 @@ $(function()
// 清空数据
if(data.page == 1)
{
$('.data-list').html('');
$('.search-list').html('');
}
// 页面提示处理
......@@ -185,13 +185,13 @@ $(function()
$('.loding-view').hide();
if(result.code == 0)
{
$('.data-list').append(result.data.data);
$('.search-list').append(result.data.data);
$('.search-pages-submit').attr('data-page', data.page+1);
$('.search-pages-submit').attr('disabled', (result.data.page_total <= 1));
$('.search-pages-submit').show();
$('.table-no').hide();
} else if(result.code == -100) {
if($('.data-list li').length == 0)
if($('.search-list li').length == 0)
{
$('.table-no').show();
$('.search-pages-submit').hide();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册