diff --git a/service/Application/Admin/Controller/CommonController.class.php b/service/Application/Admin/Controller/CommonController.class.php index cc0771ab7..fa16348e0 100755 --- a/service/Application/Admin/Controller/CommonController.class.php +++ b/service/Application/Admin/Controller/CommonController.class.php @@ -484,7 +484,7 @@ class CommonController extends Controller // 存储图片 $temp_all = [ 'tmp_name' => $_FILES[$images_name]['tmp_name'][$i], - 'type' => $_FILES[$images_name]['type'][$i] + 'type' => $_FILES[$images_name]['type'][$i], ]; $original = $images_obj->GetOriginal($temp_all, $root_path.$img_path.'original'.$date); if(!empty($original)) @@ -507,6 +507,65 @@ class CommonController extends Controller 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) + { + $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/GoodsController.class.php b/service/Application/Admin/Controller/GoodsController.class.php index 57e3815e7..6604a241f 100755 --- a/service/Application/Admin/Controller/GoodsController.class.php +++ b/service/Application/Admin/Controller/GoodsController.class.php @@ -177,13 +177,22 @@ class GoodsController extends CommonController $this->assign('region_province_list', M('Region')->where(['pid'=>0, 'is_enable'=>1])->select()); // 商品分类 - $field = 'id,name,icon'; - $category = M('GoodsCategory')->field($field)->where(['is_enable'=>1, 'pid'=>0])->order('sort asc')->select(); + $field = 'id,name'; + $m = M('GoodsCategory'); + $category = $m->field($field)->where(['is_enable'=>1, 'pid'=>0])->order('sort asc')->select(); if(!empty($category)) { foreach($category as &$v) { - $v['items'] = M('GoodsCategory')->field($field)->where(['is_enable'=>1, 'pid'=>$v['id']])->order('sort asc')->select(); + $two = $m->field($field)->where(['is_enable'=>1, 'pid'=>$v['id']])->order('sort asc')->select(); + if(!empty($two)) + { + foreach($two as &$vs) + { + $vs['items'] = $m->field($field)->where(['is_enable'=>1, 'pid'=>$vs['id']])->order('sort asc')->select(); + } + } + $v['items'] = $two; } } $this->assign('category_list', $category); @@ -270,6 +279,14 @@ class GoodsController extends CommonController $this->ajaxReturn($content_app['msg'], -1); } + // 集合主图片 + $images_field = ['file_home_recommended_images']; + $images = $this->GetGoodsImagesParams($images_field); + if($images['status'] === false) + { + $this->ajaxReturn($images['msg'], -1); + } + // 基础数据 $data = [ 'title' => I('title'), @@ -289,6 +306,7 @@ class GoodsController extends CommonController 'images' => isset($photo['data'][0]) ? $photo['data'][0] : '', 'photo_count' => count($photo['data']), 'is_home_recommended' => intval(I('is_home_recommended')), + 'home_recommended_images' => empty($images['data']['file_home_recommended_images']) ? '' : $images['data']['file_home_recommended_images'], ]; // 添加/编辑 diff --git a/service/Application/Admin/Lang/zh-cn/goods.php b/service/Application/Admin/Lang/zh-cn/goods.php index d4b5268ee..af7a40ea8 100755 --- a/service/Application/Admin/Lang/zh-cn/goods.php +++ b/service/Application/Admin/Lang/zh-cn/goods.php @@ -90,5 +90,10 @@ return array( 'goods_so_keyword_tips' => '标题/型号', + 'goods_category_level_two' => '二级', + 'goods_category_level_three' => '三级', + + 'goods_home_recommended_images_text'=> '首页推荐图片', + 'goods_home_recommended_images_tips'=> '留空则取相册第一张图', ); ?> \ No newline at end of file diff --git a/service/Application/Admin/View/Default/Express/Index.html b/service/Application/Admin/View/Default/Express/Index.html index 12fd8feae..c6af02103 100755 --- a/service/Application/Admin/View/Default/Express/Index.html +++ b/service/Application/Admin/View/Default/Express/Index.html @@ -27,7 +27,7 @@
- {{$image_host}}{{$data.images_url}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" id="form-img-icon" class="block m-t-5 am-img-thumbnail am-radius" width="50" height="50" data-default="{{$image_host}}{{$data.images_url}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" /> +
diff --git a/service/Application/Admin/View/Default/Goods/SaveInfo.html b/service/Application/Admin/View/Default/Goods/SaveInfo.html index 6e075c7f5..d8822fa06 100755 --- a/service/Application/Admin/View/Default/Goods/SaveInfo.html +++ b/service/Application/Admin/View/Default/Goods/SaveInfo.html @@ -68,7 +68,10 @@ - >{{$vs.name}} + + + + @@ -116,6 +119,16 @@ value="{{$data.buy_max_number}}" />
+
+ + + value="{{$data.home_recommended_images}}"" data-validation-message="{{:L('common_select_images_tips')}}" readonly="readonly" /> + + + + {{$image_host}}{{$data.home_recommended_images}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" id="form-img-home_recommended_images" class="block m-t-5 am-img-thumbnail am-radius" width="150" height="150" data-default="{{$image_host}}{{$data.home_recommended_images}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" data-del-default="{{$image_host}}/Public/Admin/Default/Images/default-images.png" /> +
checked="true" /> diff --git a/service/Application/Admin/View/Default/GoodsCategory/Index.html b/service/Application/Admin/View/Default/GoodsCategory/Index.html index 763f9167b..855d22cf0 100755 --- a/service/Application/Admin/View/Default/GoodsCategory/Index.html +++ b/service/Application/Admin/View/Default/GoodsCategory/Index.html @@ -27,7 +27,7 @@
- {{$image_host}}{{$data.images_url}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" id="form-img-icon" class="block m-t-5 am-img-thumbnail am-radius" width="50" height="50" data-default="{{$image_host}}{{$data.images_url}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" /> +
@@ -37,7 +37,7 @@
- {{$image_host}}{{$data.big_images}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" id="form-img-big_images" class="block m-t-5 am-img-thumbnail am-radius" width="50" height="50" data-default="{{$image_host}}{{$data.big_images}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" /> +
diff --git a/service/Public/Common/Js/Common.js b/service/Public/Common/Js/Common.js index db2e7c95d..25efadb40 100755 --- a/service/Public/Common/Js/Common.js +++ b/service/Public/Common/Js/Common.js @@ -1091,8 +1091,10 @@ $(function() // 图片组合input清除按钮 $(document).on('click', '.original-images-url-delete', function() { + var images = $($(this).data('image-tag')).data('del-default') || $($(this).data('image-tag')).attr('data-default'); $($(this).data('input-tag')).val(''); - $($(this).data('image-tag')).attr('src', $($(this).data('image-tag')).data('default')); + $($(this).data('image-tag')).attr('src', images); + $($(this).data('image-tag')).attr('data-default', images); $($(this).data('tips-tag')).html(''); var $file_tag = $($(this).data('file-tag')); if($file_tag.val().length > 0) diff --git a/service/Public/Upload/goods_images/compr/2018/08/07/201808071606035112750988.jpg b/service/Public/Upload/goods_images/compr/2018/08/07/201808071606035112750988.jpg new file mode 100644 index 000000000..23eba0e4c Binary files /dev/null and b/service/Public/Upload/goods_images/compr/2018/08/07/201808071606035112750988.jpg differ diff --git a/service/Public/Upload/goods_images/compr/2018/08/07/201808071607529296412425.jpg b/service/Public/Upload/goods_images/compr/2018/08/07/201808071607529296412425.jpg new file mode 100644 index 000000000..23eba0e4c Binary files /dev/null and b/service/Public/Upload/goods_images/compr/2018/08/07/201808071607529296412425.jpg differ diff --git a/service/Public/Upload/goods_images/compr/2018/08/07/20180807160906551366842.jpg b/service/Public/Upload/goods_images/compr/2018/08/07/20180807160906551366842.jpg new file mode 100644 index 000000000..d70351cbc Binary files /dev/null and b/service/Public/Upload/goods_images/compr/2018/08/07/20180807160906551366842.jpg differ diff --git a/service/Public/Upload/goods_images/original/2018/08/07/201808071606035112750988.jpg b/service/Public/Upload/goods_images/original/2018/08/07/201808071606035112750988.jpg new file mode 100644 index 000000000..643485d35 Binary files /dev/null and b/service/Public/Upload/goods_images/original/2018/08/07/201808071606035112750988.jpg differ diff --git a/service/Public/Upload/goods_images/original/2018/08/07/201808071607529296412425.jpg b/service/Public/Upload/goods_images/original/2018/08/07/201808071607529296412425.jpg new file mode 100644 index 000000000..643485d35 Binary files /dev/null and b/service/Public/Upload/goods_images/original/2018/08/07/201808071607529296412425.jpg differ diff --git a/service/Public/Upload/goods_images/original/2018/08/07/20180807160906551366842.jpg b/service/Public/Upload/goods_images/original/2018/08/07/20180807160906551366842.jpg new file mode 100644 index 000000000..fe70945ef Binary files /dev/null and b/service/Public/Upload/goods_images/original/2018/08/07/20180807160906551366842.jpg differ diff --git a/service/Public/Upload/goods_images/small/2018/08/07/201808071606035112750988.jpg b/service/Public/Upload/goods_images/small/2018/08/07/201808071606035112750988.jpg new file mode 100644 index 000000000..327983825 Binary files /dev/null and b/service/Public/Upload/goods_images/small/2018/08/07/201808071606035112750988.jpg differ diff --git a/service/Public/Upload/goods_images/small/2018/08/07/201808071607529296412425.jpg b/service/Public/Upload/goods_images/small/2018/08/07/201808071607529296412425.jpg new file mode 100644 index 000000000..327983825 Binary files /dev/null and b/service/Public/Upload/goods_images/small/2018/08/07/201808071607529296412425.jpg differ diff --git a/service/Public/Upload/goods_images/small/2018/08/07/20180807160906551366842.jpg b/service/Public/Upload/goods_images/small/2018/08/07/20180807160906551366842.jpg new file mode 100644 index 000000000..aa04f49a6 Binary files /dev/null and b/service/Public/Upload/goods_images/small/2018/08/07/20180807160906551366842.jpg differ