From 472e1de077a8f4cc9815a3472ce2b8c4dddaabdd Mon Sep 17 00:00:00 2001 From: devil_gong Date: Tue, 11 Sep 2018 15:19:04 +0800 Subject: [PATCH] brand logo search --- .../Controller/BrandController.class.php | 25 +- .../Controller/CommonController.class.php | 312 +++--------------- .../Controller/ExpressController.class.php | 25 +- .../GoodsCategoryController.class.php | 50 +-- .../Controller/GoodsController.class.php | 230 +++++++++++++ .../Admin/Controller/SiteController.class.php | 27 +- service/Application/Admin/Lang/zh-cn/site.php | 2 +- .../Admin/View/Default/Site/Index.html | 15 +- .../Home/View/Default/Public/NavSearch.html | 2 +- .../Temp/38432eb7369925b9a826f2b9f64e2262.php | 2 +- service/Public/Admin/Default/Css/Site.css | 3 +- service/Public/Admin/Default/Js/Site.js | 4 +- service/Public/Home/Default/Css/Common.css | 4 +- .../brand/images/20180911144300_logo.jpeg | Bin 0 -> 5315 bytes .../brand/images/20180911144327_logo.jpeg | Bin 0 -> 6851 bytes .../brand/images/20180911144350_logo.jpeg | Bin 0 -> 6046 bytes .../brand/images/20180911144407_logo.jpeg | Bin 0 -> 7991 bytes .../brand/images/20180911144430_logo.jpeg | Bin 0 -> 6045 bytes .../brand/images/20180911145756_logo.jpeg | Bin 0 -> 5346 bytes .../brand/images/20180911150230_logo.jpeg | Bin 0 -> 3794 bytes .../brand/images/20180911150253_logo.jpeg | Bin 0 -> 8912 bytes .../brand/images/20180911150312_logo.jpeg | Bin 0 -> 8586 bytes .../brand/images/20180911150330_logo.jpeg | Bin 0 -> 3997 bytes .../brand/images/20180911150348_logo.jpeg | Bin 0 -> 7119 bytes .../brand/images/20180911150412_logo.jpeg | Bin 0 -> 5027 bytes .../brand/images/20180911150435_logo.jpeg | Bin 0 -> 9189 bytes .../brand/images/20180911150454_logo.jpeg | Bin 0 -> 7142 bytes .../brand/images/20180911150512_logo.jpeg | Bin 0 -> 6768 bytes .../brand/images/20180911150528_logo.jpeg | Bin 0 -> 4629 bytes .../brand/images/20180911150547_logo.jpeg | Bin 0 -> 8421 bytes .../brand/images/20180911150610_logo.gif | Bin 0 -> 8117 bytes .../brand/images/20180911150626_logo.jpeg | Bin 0 -> 8545 bytes .../brand/images/20180911150644_logo.jpeg | Bin 0 -> 3649 bytes .../brand/images/20180911150701_logo.jpeg | Bin 0 -> 5914 bytes .../brand/images/20180911150804_logo.png | Bin 0 -> 2953 bytes .../brand/images/20180911150855_logo.jpeg | Bin 0 -> 6380 bytes .../brand/images/20180911150921_logo.jpeg | Bin 0 -> 4128 bytes .../brand/images/20180911150946_logo.jpeg | Bin 0 -> 10114 bytes .../brand/images/20180911151005_logo.jpeg | Bin 0 -> 7152 bytes .../brand/images/20180911151034_logo.jpeg | Bin 0 -> 4272 bytes .../brand/images/20180911151051_logo.jpeg | Bin 0 -> 4935 bytes .../brand/images/20180911151118_logo.jpeg | Bin 0 -> 5531 bytes .../brand/images/20180911151143_logo.jpeg | Bin 0 -> 6017 bytes .../common/images/20180911134641_logo.png | Bin 0 -> 8725 bytes ...74046_logo.png => 20180911144001_logo.png} | Bin shopxo.sql | 36 +- 46 files changed, 314 insertions(+), 423 deletions(-) create mode 100644 service/Public/Upload/brand/images/20180911144300_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911144327_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911144350_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911144407_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911144430_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911145756_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150230_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150253_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150312_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150330_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150348_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150412_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150435_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150454_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150512_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150528_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150547_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150610_logo.gif create mode 100644 service/Public/Upload/brand/images/20180911150626_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150644_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150701_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150804_logo.png create mode 100644 service/Public/Upload/brand/images/20180911150855_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150921_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911150946_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911151005_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911151034_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911151051_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911151118_logo.jpeg create mode 100644 service/Public/Upload/brand/images/20180911151143_logo.jpeg create mode 100644 service/Public/Upload/common/images/20180911134641_logo.png rename service/Public/Upload/common/images/{20180807174046_logo.png => 20180911144001_logo.png} (100%) mode change 100755 => 100644 diff --git a/service/Application/Admin/Controller/BrandController.class.php b/service/Application/Admin/Controller/BrandController.class.php index 7c65a0782..d9850d639 100755 --- a/service/Application/Admin/Controller/BrandController.class.php +++ b/service/Application/Admin/Controller/BrandController.class.php @@ -198,30 +198,7 @@ class BrandController extends CommonController } // 图片 - if(!empty($_FILES['file_logo'])) - { - // 文件上传校验 - $error = FileUploadError('file_logo'); - if($error !== true) - { - $this->ajaxReturn($error, -1); - } - - // 文件类型 - list($type, $suffix) = explode('/', $_FILES['file_logo']['type']); - $path = 'Public'.DS.'Upload'.DS.'brand'.DS.date('Y').DS.date('m').DS; - if(!is_dir($path)) - { - mkdir(ROOT_PATH.$path, 0777, true); - } - $filename = date('YmdHis').GetNumberCode(6).'.'.$suffix; - $file_logo = $path.$filename; - - if(move_uploaded_file($_FILES['file_logo']['tmp_name'], ROOT_PATH.$file_logo)) - { - $_POST['logo'] = DS.$file_logo; - } - } + $this->ImagesSave('logo', 'file_logo', 'brand'); // id为空则表示是新增 $m = D('Brand'); diff --git a/service/Application/Admin/Controller/CommonController.class.php b/service/Application/Admin/Controller/CommonController.class.php index feb1054ed..416b439cd 100755 --- a/service/Application/Admin/Controller/CommonController.class.php +++ b/service/Application/Admin/Controller/CommonController.class.php @@ -240,50 +240,6 @@ class CommonController extends Controller } } - /** - * [GetClassList 获取班级列表,二级] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-30T13:26:00+0800 - * @return [array] [班级列表] - */ - protected function GetClassList() - { - $m = M('Class'); - $data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select(); - if(!empty($data)) - { - foreach($data as $k=>$v) - { - $data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select(); - } - } - return $data; - } - - /** - * [GetRoomList 获取教室列表,二级] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-30T13:26:00+0800 - * @return [array] [班级列表] - */ - protected function GetRoomList() - { - $m = M('Room'); - $data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select(); - if(!empty($data)) - { - foreach($data as $k=>$v) - { - $data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select(); - } - } - return $data; - } - /** * [MyConfigSave 配置数据保存] * @author Devil @@ -341,236 +297,6 @@ class CommonController extends Controller } } - /** - * 获取属性参数 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2018-07-09 - * @desc description - */ - protected function GetFormGoodsAttributeParams() - { - $result = []; - foreach($_POST as $k=>$v) - { - if(substr($k, 0, 9) == 'attribute') - { - // key分解 - $key = explode('_', $k); - - // 当前key是否是具体属性数据 - if(in_array('find', $key)) - { - $result[$key[1]][$key[2]][$key[3]][$key[4]] = $v; - } else { - // 属性类型数据 - $result[$key[1]][$key[2]][$key[3]] = $v; - } - } - } - return ['status'=>true, 'data'=>$result]; - } - - /** - * 获取app内容 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2018-07-09 - * @desc description - */ - protected function GetFormGoodsContentAppParams() - { - // 图像类库 - $images_obj = \Library\Images::Instance(['is_new_name'=>false]); - - // 定义图片目录 - $root_path = ROOT_PATH; - $img_path = 'Public'.DS.'Upload'.DS.'goods_app'.DS; - $date = DS.date('Y').DS.date('m').DS.date('d').DS; - - // 开始处理 - $result = []; - $name = 'content_app_'; - foreach($_POST AS $k=>$v) - { - if(substr($k, 0, 12) == $name) - { - $key = explode('_', str_replace($name, '', $k)); - if(count($key) == 2) - { - $result[$key[1]][$key[0]] = $v; - - if($key[0] == 'images') - { - $images_key = $name.$key[0].'_file_'.$key[1]; - if(isset($_FILES[$images_key])) - { - // 文件上传校验 - $error = FileUploadError($images_key); - if($error !== true) - { - return ['status'=>false, 'msg'=>$error]; - } - - // 存储图片 - $temp_all = [ - 'tmp_name' => $_FILES[$images_key]['tmp_name'], - 'type' => $_FILES[$images_key]['type'] - ]; - $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); - if(!empty($original)) - { - // 根据原图再次生成小图 - $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); - $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); - - if(!empty($compr)) - { - $result[$key[1]][$key[0]] = DS.$img_path.'compr'.$date.$small; - } else { - // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($img_path.'original'.$date.$original); - } - } - } - } - } - } - } - return ['status'=>true, 'data'=>$result]; - } - - /** - * 获取商品相册 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2018-07-10 - * @desc description - * @return [array] [一维数组但图片地址] - */ - protected function GetFormGoodsPhotoParams() - { - // 原始图片 - if(!empty($_POST['photo']) && is_array($_POST['photo'])) - { - $result = $_POST['photo']; - } else { - $result = []; - } - - // 开始处理图片存储 - $images_name = 'photo_file'; - if(!empty($_FILES[$images_name])) - { - // 定义图片目录 - $root_path = ROOT_PATH; - $img_path = 'Public'.DS.'Upload'.DS.'goods_photo'.DS; - $date = DS.date('Y').DS.date('m').DS.date('d').DS; - - // 图像类库 - $images_obj = \Library\Images::Instance(['is_new_name'=>false]); - - // 图片存储处理 - for($i=0; $ifalse, 'msg'=>$error]; - } - - // 存储图片 - $temp_all = [ - 'tmp_name' => $_FILES[$images_name]['tmp_name'][$i], - 'type' => $_FILES[$images_name]['type'][$i], - ]; - $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); - if(!empty($original)) - { - // 根据原图再次生成小图 - $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); - $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); - - if(!empty($compr)) - { - $result[] = DS.$img_path.'compr'.$date.$small; - } else { - // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($img_path.'original'.$date.$original); - } - } - } - } - - return ['status'=>true, 'data'=>$result]; - } - - /** - * 商品图片集合处理 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2018-08-07 - * @desc description - * @param [array] $data [字段列表] - */ - protected function GetGoodsImagesParams($data) - { - $result = []; - if(!empty($data)) - { - // 定义图片目录 - $root_path = ROOT_PATH; - $img_path = 'Public'.DS.'Upload'.DS.'goods_images'.DS; - $date = DS.date('Y').DS.date('m').DS.date('d').DS; - - // 图像类库 - $images_obj = \Library\Images::Instance(['is_new_name'=>false]); - - foreach($data as $field) - { - if(!empty($_FILES[$field])) - { - $file = $_FILES[$field]; - - // 文件上传校验 - $error = FileUploadError($field); - if($error !== true) - { - return ['status'=>false, 'msg'=>$error]; - } - - // 存储图片 - $temp_all = [ - 'tmp_name' => $file['tmp_name'], - 'type' => $file['type'], - ]; - $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); - if(!empty($original)) - { - // 根据原图再次生成小图 - $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); - $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); - - if(!empty($compr)) - { - $result[$field] = DS.$img_path.'compr'.$date.$small; - } else { - // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($img_path.'original'.$date.$original); - } - } - } - } - } - - return ['status'=>true, 'data'=>$result]; - } - /** * 图片删除 * @author Devil @@ -613,5 +339,43 @@ class CommonController extends Controller } } } + + /** + * 图片存储 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-11 + * @desc description + * @param [string] $field [name名称] + * @param [string] $post_name [file form name名称] + * @param [string] $dir [存储路径标记] + */ + protected function ImagesSave($field, $post_name, $dir = 'common') + { + if(isset($_FILES[$post_name]['error'])) + { + // 文件上传校验 + $error = FileUploadError($post_name); + if($error !== true) + { + $this->ajaxReturn($error, -1); + } + + // 文件类型 + list($type, $suffix) = explode('/', $_FILES[$post_name]['type']); + $path = 'Public'.DS.'Upload'.DS.$dir.DS.'images'.DS; + if(!is_dir($path)) + { + mkdir(ROOT_PATH.$path, 0777, true); + } + $filename = date('YmdHis').'_logo.'.$suffix; + $file = $path.$filename; + if(move_uploaded_file($_FILES[$post_name]['tmp_name'], ROOT_PATH.$file)) + { + $_POST[$field] = DS.$file; + } + } + } } ?> \ No newline at end of file diff --git a/service/Application/Admin/Controller/ExpressController.class.php b/service/Application/Admin/Controller/ExpressController.class.php index 73446bc9b..1dbff4f25 100755 --- a/service/Application/Admin/Controller/ExpressController.class.php +++ b/service/Application/Admin/Controller/ExpressController.class.php @@ -94,30 +94,7 @@ class ExpressController extends CommonController } // 图片 - if(!empty($_FILES['file_icon'])) - { - // 文件上传校验 - $error = FileUploadError('file_icon'); - if($error !== true) - { - $this->ajaxReturn($error, -1); - } - - // 文件类型 - list($type, $suffix) = explode('/', $_FILES['file_icon']['type']); - $path = 'Public'.DS.'Upload'.DS.'express'.DS.date('Y').DS.date('m').DS; - if(!is_dir($path)) - { - mkdir(ROOT_PATH.$path, 0777, true); - } - $filename = date('YmdHis').GetNumberCode(6).'.'.$suffix; - $file_icon = $path.$filename; - - if(move_uploaded_file($_FILES['file_icon']['tmp_name'], ROOT_PATH.$file_icon)) - { - $_POST['icon'] = DS.$file_icon; - } - } + $this->ImagesSave('icon', 'file_icon', 'express'); // id为空则表示是新增 $m = D('Express'); diff --git a/service/Application/Admin/Controller/GoodsCategoryController.class.php b/service/Application/Admin/Controller/GoodsCategoryController.class.php index 876be1474..6e6887ee5 100755 --- a/service/Application/Admin/Controller/GoodsCategoryController.class.php +++ b/service/Application/Admin/Controller/GoodsCategoryController.class.php @@ -116,56 +116,10 @@ class GoodsCategoryController extends CommonController } // icon - if(!empty($_FILES['file_icon'])) - { - // 文件上传校验 - $error = FileUploadError('file_icon'); - if($error !== true) - { - $this->ajaxReturn($error, -1); - } - - // 文件类型 - list($type, $suffix) = explode('/', $_FILES['file_icon']['type']); - $path = 'Public'.DS.'Upload'.DS.'goods_category'.DS.date('Y').DS.date('m').DS; - if(!is_dir($path)) - { - mkdir(ROOT_PATH.$path, 0777, true); - } - $filename = date('YmdHis').GetNumberCode(6).'.'.$suffix; - $file_icon = $path.$filename; - - if(move_uploaded_file($_FILES['file_icon']['tmp_name'], ROOT_PATH.$file_icon)) - { - $_POST['icon'] = DS.$file_icon; - } - } + $this->ImagesSave('icon', 'file_icon', 'goods_category'); // 大图片 - if(!empty($_FILES['file_big_images'])) - { - // 文件上传校验 - $error = FileUploadError('file_big_images'); - if($error !== true) - { - $this->ajaxReturn($error, -1); - } - - // 文件类型 - list($type, $suffix) = explode('/', $_FILES['file_big_images']['type']); - $path = 'Public'.DS.'Upload'.DS.'goods_category'.DS.date('Y').DS.date('m').DS; - if(!is_dir($path)) - { - mkdir(ROOT_PATH.$path, 0777, true); - } - $filename = date('YmdHis').GetNumberCode(6).'.'.$suffix; - $file_big_images = $path.$filename; - - if(move_uploaded_file($_FILES['file_big_images']['tmp_name'], ROOT_PATH.$file_big_images)) - { - $_POST['big_images'] = DS.$file_big_images; - } - } + $this->ImagesSave('big_images', 'file_big_images', 'goods_category'); // id为空则表示是新增 $m = D('GoodsCategory'); diff --git a/service/Application/Admin/Controller/GoodsController.class.php b/service/Application/Admin/Controller/GoodsController.class.php index 129519a4d..ce89ab168 100755 --- a/service/Application/Admin/Controller/GoodsController.class.php +++ b/service/Application/Admin/Controller/GoodsController.class.php @@ -413,6 +413,236 @@ class GoodsController extends CommonController } } + /** + * 获取属性参数 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-07-09 + * @desc description + */ + private function GetFormGoodsAttributeParams() + { + $result = []; + foreach($_POST as $k=>$v) + { + if(substr($k, 0, 9) == 'attribute') + { + // key分解 + $key = explode('_', $k); + + // 当前key是否是具体属性数据 + if(in_array('find', $key)) + { + $result[$key[1]][$key[2]][$key[3]][$key[4]] = $v; + } else { + // 属性类型数据 + $result[$key[1]][$key[2]][$key[3]] = $v; + } + } + } + return ['status'=>true, 'data'=>$result]; + } + + /** + * 获取app内容 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-07-09 + * @desc description + */ + private function GetFormGoodsContentAppParams() + { + // 图像类库 + $images_obj = \Library\Images::Instance(['is_new_name'=>false]); + + // 定义图片目录 + $root_path = ROOT_PATH; + $img_path = 'Public'.DS.'Upload'.DS.'goods_app'.DS; + $date = DS.date('Y').DS.date('m').DS.date('d').DS; + + // 开始处理 + $result = []; + $name = 'content_app_'; + foreach($_POST AS $k=>$v) + { + if(substr($k, 0, 12) == $name) + { + $key = explode('_', str_replace($name, '', $k)); + if(count($key) == 2) + { + $result[$key[1]][$key[0]] = $v; + + if($key[0] == 'images') + { + $images_key = $name.$key[0].'_file_'.$key[1]; + if(isset($_FILES[$images_key])) + { + // 文件上传校验 + $error = FileUploadError($images_key); + if($error !== true) + { + return ['status'=>false, 'msg'=>$error]; + } + + // 存储图片 + $temp_all = [ + 'tmp_name' => $_FILES[$images_key]['tmp_name'], + 'type' => $_FILES[$images_key]['type'] + ]; + $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); + if(!empty($original)) + { + // 根据原图再次生成小图 + $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); + $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); + + if(!empty($compr)) + { + $result[$key[1]][$key[0]] = DS.$img_path.'compr'.$date.$small; + } else { + // 如果图片格式有误,则删除原图片 + $this->ImagesDelete($img_path.'original'.$date.$original); + } + } + } + } + } + } + } + return ['status'=>true, 'data'=>$result]; + } + + /** + * 获取商品相册 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-07-10 + * @desc description + * @return [array] [一维数组但图片地址] + */ + private function GetFormGoodsPhotoParams() + { + // 原始图片 + if(!empty($_POST['photo']) && is_array($_POST['photo'])) + { + $result = $_POST['photo']; + } else { + $result = []; + } + + // 开始处理图片存储 + $images_name = 'photo_file'; + if(!empty($_FILES[$images_name])) + { + // 定义图片目录 + $root_path = ROOT_PATH; + $img_path = 'Public'.DS.'Upload'.DS.'goods_photo'.DS; + $date = DS.date('Y').DS.date('m').DS.date('d').DS; + + // 图像类库 + $images_obj = \Library\Images::Instance(['is_new_name'=>false]); + + // 图片存储处理 + for($i=0; $ifalse, 'msg'=>$error]; + } + + // 存储图片 + $temp_all = [ + 'tmp_name' => $_FILES[$images_name]['tmp_name'][$i], + 'type' => $_FILES[$images_name]['type'][$i], + ]; + $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); + if(!empty($original)) + { + // 根据原图再次生成小图 + $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); + $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); + + if(!empty($compr)) + { + $result[] = DS.$img_path.'compr'.$date.$small; + } else { + // 如果图片格式有误,则删除原图片 + $this->ImagesDelete($img_path.'original'.$date.$original); + } + } + } + } + + return ['status'=>true, 'data'=>$result]; + } + + /** + * 商品图片集合处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-08-07 + * @desc description + * @param [array] $data [字段列表] + */ + private function GetGoodsImagesParams($data) + { + $result = []; + if(!empty($data)) + { + // 定义图片目录 + $root_path = ROOT_PATH; + $img_path = 'Public'.DS.'Upload'.DS.'goods_images'.DS; + $date = DS.date('Y').DS.date('m').DS.date('d').DS; + + // 图像类库 + $images_obj = \Library\Images::Instance(['is_new_name'=>false]); + + foreach($data as $field) + { + if(!empty($_FILES[$field])) + { + $file = $_FILES[$field]; + + // 文件上传校验 + $error = FileUploadError($field); + if($error !== true) + { + return ['status'=>false, 'msg'=>$error]; + } + + // 存储图片 + $temp_all = [ + 'tmp_name' => $file['tmp_name'], + 'type' => $file['type'], + ]; + $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); + if(!empty($original)) + { + // 根据原图再次生成小图 + $compr = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'compr'.$date, 600); + $small = $images_obj->GetBinaryCompress($root_path.$img_path.'original'.$date.$original, $root_path.$img_path.'small'.$date, 100, 100); + + if(!empty($compr)) + { + $result[$field] = DS.$img_path.'compr'.$date.$small; + } else { + // 如果图片格式有误,则删除原图片 + $this->ImagesDelete($img_path.'original'.$date.$original); + } + } + } + } + } + + return ['status'=>true, 'data'=>$result]; + } + /** * 商品分类添加 * @author Devil diff --git a/service/Application/Admin/Controller/SiteController.class.php b/service/Application/Admin/Controller/SiteController.class.php index 1b7dd5d7b..42a1bc187 100755 --- a/service/Application/Admin/Controller/SiteController.class.php +++ b/service/Application/Admin/Controller/SiteController.class.php @@ -71,30 +71,9 @@ class SiteController extends CommonController */ public function Save() { - // 站点logo - if(isset($_FILES['home_site_logo_img']['error'])) - { - // 文件上传校验 - $error = FileUploadError('home_site_logo_img'); - if($error !== true) - { - $this->ajaxReturn($error, -1); - } - - // 文件类型 - list($type, $suffix) = explode('/', $_FILES['home_site_logo_img']['type']); - $path = 'Public'.DS.'Upload'.DS.'common'.DS.'images'.DS; - if(!is_dir($path)) - { - mkdir(ROOT_PATH.$path, 0777, true); - } - $filename = date('YmdHis').'_logo.'.$suffix; - $home_site_logo = $path.$filename; - if(move_uploaded_file($_FILES['home_site_logo_img']['tmp_name'], ROOT_PATH.$home_site_logo)) - { - $_POST['home_site_logo'] = DS.$home_site_logo; - } - } + // logo存储 + $this->ImagesSave('home_site_logo', 'home_site_logo_img'); + $this->ImagesSave('home_site_logo_wap', 'home_site_logo_wap_img'); // 站点状态值处理 if(!isset($_POST['home_user_reg_state'])) diff --git a/service/Application/Admin/Lang/zh-cn/site.php b/service/Application/Admin/Lang/zh-cn/site.php index b2b1d2044..6e8191cd0 100755 --- a/service/Application/Admin/Lang/zh-cn/site.php +++ b/service/Application/Admin/Lang/zh-cn/site.php @@ -8,7 +8,7 @@ * @datetime 2016-12-01T21:51:08+0800 */ return array( - 'site_site_logo_text' => '选择网站logo', + 'site_site_logo_text' => '选择logo', // 站点关闭状态列表 'site_site_state_list' => array( diff --git a/service/Application/Admin/View/Default/Site/Index.html b/service/Application/Admin/View/Default/Site/Index.html index 73e2ec8f8..f5d596d58 100755 --- a/service/Application/Admin/View/Default/Site/Index.html +++ b/service/Application/Admin/View/Default/Site/Index.html @@ -14,11 +14,22 @@ - value="{{$data.home_site_logo.value}}" /> + value="{{$data.home_site_logo.value}}" /> value="{{$data.home_site_logo.value}}" /> - +
+
+ + + value="{{$data.home_site_logo_wap.value}}" /> + value="{{$data.home_site_logo_wap.value}}" /> + + + +
+