Commit df60a5ff679c5dc19f3504b357528da77e0cd8fa

Authored by u123231312
1 parent 4462b2ee

no message

@@ -176,7 +176,8 @@ class Template extends Common{ @@ -176,7 +176,8 @@ class Template extends Common{
176 }*/ 176 }*/
177 177
178 public function index(){ 178 public function index(){
179 - $path = $this->publicpath.'images/'.input('folder').'/'; 179 + $path = "/alidata/www/dc-api/public/tables/batchPicsyn";
  180 +
180 $uppath = explode('/',input('folder')); 181 $uppath = explode('/',input('folder'));
181 $leve = count($uppath)-1; 182 $leve = count($uppath)-1;
182 unset($uppath[$leve]); 183 unset($uppath[$leve]);
@@ -211,32 +212,21 @@ class Template extends Common{ @@ -211,32 +212,21 @@ class Template extends Common{
211 } 212 }
212 213
213 public function PackzipDownload(){ 214 public function PackzipDownload(){
214 - $path = $this->publicpath.'images/'.input('post.folder'); 215 + $path = "/alidata/www/dc-api/public/tables/batchPicsyn";
215 $file=$path.input('post.filename'); 216 $file=$path.input('post.filename');
216 //首先判断是图片还是路径 217 //首先判断是图片还是路径
217 if($this->isImage($file)!==false){ 218 if($this->isImage($file)!==false){
218 //是图片 219 //是图片
219 $zip = new \ZipArchive; 220 $zip = new \ZipArchive;
220 //压缩文件名 221 //压缩文件名
221 - $filename = $path.'download.zip'; 222 + $filename = 'uploads/package/download.zip';
  223 +
222 //新建zip压缩包 224 //新建zip压缩包
223 $obj = $zip->open($filename,\ZIPARCHIVE::OVERWRITE | \ZIPARCHIVE::CREATE); 225 $obj = $zip->open($filename,\ZIPARCHIVE::OVERWRITE | \ZIPARCHIVE::CREATE);
224 //把图片一张一张加进去压缩 226 //把图片一张一张加进去压缩
225 $zip->addFile($file); 227 $zip->addFile($file);
226 //打包zip 228 //打包zip
227 - $zip->close();  
228 -  
229 - //可以直接重定向下载  
230 - //header('Location:'.$filename);  
231 -  
232 - //或者输出下载  
233 - /*header("Cache-Control: public");  
234 - header("Content-Description: File Transfer");  
235 - header('Content-disposition: attachment; filename='.basename($filename)); //文件名  
236 - header("Content-Type: application/force-download");  
237 - header("Content-Transfer-Encoding: binary");  
238 - header('Content-Length: '. filesize($filename)); //告诉浏览器,文件大小  
239 - return @readfile($filename);*/ 229 + $rs = $zip->close();
240 }else{ 230 }else{
241 //目录 231 //目录
242 $zip = new \ZipArchive; 232 $zip = new \ZipArchive;
@@ -251,20 +241,9 @@ class Template extends Common{ @@ -251,20 +241,9 @@ class Template extends Common{
251 } 241 }
252 242
253 //打包zip 243 //打包zip
254 - $zip->close();  
255 -  
256 - //可以直接重定向下载  
257 - header('Location:'.$filename);exit;  
258 -  
259 - //或者输出下载  
260 - header("Cache-Control: public");  
261 - header("Content-Description: File Transfer");  
262 - header('Content-disposition: attachment; filename='.basename($filename)); //文件名  
263 - header("Content-Type: application/force-download");  
264 - header("Content-Transfer-Encoding: binary");  
265 - header('Content-Length: '. filesize($filename)); //告诉浏览器,文件大小  
266 - return @readfile($filename); 244 + $rs = $zip->close();
267 } 245 }
  246 + return $rs;
268 } 247 }
269 248
270 /** 249 /**
@@ -285,4 +264,43 @@ class Template extends Common{ @@ -285,4 +264,43 @@ class Template extends Common{
285 return false; 264 return false;
286 } 265 }
287 } 266 }
  267 +
  268 + /**
  269 + * 二维码包下载页面
  270 + */
  271 + public function package(){
  272 + $path = 'uploads/package/'.input('folder').'/';
  273 +
  274 + $uppath = explode('/',input('folder'));
  275 + $leve = count($uppath)-1;
  276 + unset($uppath[$leve]);
  277 + if($leve>1){
  278 + unset($uppath[$leve-1]);
  279 + $uppath = implode('/',$uppath).'/';
  280 + }else{
  281 + $uppath = '';
  282 + }
  283 + $this->assign ( 'leve',$leve);
  284 + $this->assign ( 'uppath',$uppath);
  285 + $files = glob($path.'*');
  286 + $folders=array();
  287 + foreach($files as $key => $file) {
  288 + $filename = basename($file);
  289 + if(is_dir($file)){
  290 + $folders[$key]['filename'] = $filename;
  291 + $folders[$key]['filepath'] = $file;
  292 + $folders[$key]['ext'] = 'folder';
  293 + }else{
  294 + $templates[$key]['filename'] = $filename;
  295 + $templates[$key]['filepath'] = $file;
  296 + $templates[$key]['ext'] = strtolower(substr($filename,strrpos($filename, '.')-strlen($filename)+1));
  297 + if(!in_array($templates[$key]['ext'],array('zip','gif','jpg','png','bmp'))) $templates[$key]['favicon.ico'] =1;
  298 + }
  299 + }
  300 + $this->assign ( 'title','二维码管理' );
  301 + $this->assign ( 'path',$path);
  302 + $this->assign ( 'folders',$folders );
  303 + $this->assign ( 'files',$templates );
  304 + return $this->fetch();
  305 + }
288 } 306 }
@@ -16,9 +16,12 @@ @@ -16,9 +16,12 @@
16 </fieldset> 16 </fieldset>
17 <div class="layui-field-box"> 17 <div class="layui-field-box">
18 <blockquote class="layui-elem-quote"> 18 <blockquote class="layui-elem-quote">
19 - <a href="{:url('images')}" class="layui-btn layui-btn-sm layui-btn-danger"> 19 + <a href="{:url('index')}" class="layui-btn layui-btn-sm layui-btn-danger">
20 <i class="fa fa-file-image-o"></i> 二维码管理 20 <i class="fa fa-file-image-o"></i> 二维码管理
21 </a> 21 </a>
  22 + <a href="{:url('package')}" class="layui-btn layui-btn-sm">
  23 + <i class="fa fa-file-image-o"></i> 二维码包下载
  24 + </a>
22 </blockquote> 25 </blockquote>
23 <div class="table-list"> 26 <div class="table-list">
24 <ul class="pic"> 27 <ul class="pic">
@@ -65,12 +68,11 @@ @@ -65,12 +68,11 @@
65 function confirm_delete(folder,filename,path) { 68 function confirm_delete(folder,filename,path) {
66 var loading = layer.load(1, {shade: [0.1, '#fff']}); 69 var loading = layer.load(1, {shade: [0.1, '#fff']});
67 $.post("{:url('PackzipDownload')}",{folder:folder,path:path,filename:filename},function(data){ 70 $.post("{:url('PackzipDownload')}",{folder:folder,path:path,filename:filename},function(data){
68 - alert(data);die;  
69 layer.close(loading); 71 layer.close(loading);
70 - if(data.code==1){ 72 + if(data==true){
71 layer.alert(data.msg, {icon: 6}, function(index){ 73 layer.alert(data.msg, {icon: 6}, function(index){
72 layer.close(index); 74 layer.close(index);
73 - location.replace(location.href); 75 + location.replace(location.href="{:url('package')}");
74 }); 76 });
75 }else{ 77 }else{
76 layer.alert(data.msg, {icon: 5}, function(index){ 78 layer.alert(data.msg, {icon: 5}, function(index){
  1 +{include file="common/head"/}
  2 +<style>
  3 + a{text-decoration: none;}
  4 + .table-list ul.pic { list-style: none;}
  5 + .table-list ul.pic li {float:left;position:relative;margin:5px 10px;_margin:5px 8px;text-align: center;}
  6 + .table-list ul.pic li span { width:82px;height:82px;display: block;border: 1px solid #dedede;}
  7 + .table-list ul.pic li span a {border:1px solid #eee;width:80px;height:80px;*font-size: 75px;display: table-cell; vertical-align: middle; overflow: hidden;}
  8 + .table-list ul.pic li img {max-height:80px;max-width:80px ;_width:80px;_height:80px;}
  9 + .table-list ul.pic li b {display:block;line-height:20px;height:20px;font-weight:normal;width:82px;overflow:hidden;}
  10 + .table-list ul.pic li em {position:absolute;right:25px;bottom:20px;font-style: normal;}
  11 + .table-list ul.pic li em a{color: #f00;}
  12 +</style>
  13 +<div class="admin-main fadeInUp animated">
  14 + <fieldset class="layui-elem-field layui-field-title">
  15 + <legend>{$title}</legend>
  16 + </fieldset>
  17 + <div class="layui-field-box">
  18 + <blockquote class="layui-elem-quote">
  19 + <a href="{:url('index')}" class="layui-btn layui-btn-sm">
  20 + <i class="fa fa-file-image-o"></i> 二维码管理
  21 + </a>
  22 + <a href="{:url('package')}" class="layui-btn layui-btn-sm layui-btn-danger">
  23 + <i class="fa fa-file-image-o"></i> 二维码包下载
  24 + </a>
  25 + </blockquote>
  26 + <div class="table-list">
  27 + <ul class="pic">
  28 + {volist name="files" id="vo"}
  29 + <li>
  30 + <span>
  31 + <a href="/static/home/images/{:input('folder')}{$vo.filename}" target="_blank">
  32 + {if condition="!empty($vo['ico'])"}
  33 + <img src="/static/home/images/ext/{$vo['ext']}.png">
  34 + {else /}
  35 + <img src="/static/home/images/{:input('folder')}{$vo.filename}" >
  36 + {/if}
  37 + </a>
  38 + </span>
  39 + <b>{$vo.filename}</b>
  40 + <!--<em><a href="javascript:confirm_delete('{:input("folder")}','{$vo.filename}','{$path}')">打包</a></em>-->
  41 + </li>
  42 + {/volist}
  43 + </ul>
  44 + </div>
  45 + </div>
  46 +</div>
  47 +{include file="common/foot"/}
  48 +<script src="/static/common/js/jquery.2.1.1.min.js"></script>