From 87590024d52c9202115cf1f1eac40be796bc0005 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Mon, 17 Dec 2018 01:22:10 +0800 Subject: [PATCH] goods category --- application/admin/config/app.php | 18 +-- application/admin/controller/Admin.php | 1 + application/admin/controller/Goods.php | 3 + .../admin/controller/GoodsCategory.php | 112 ++------------ application/admin/controller/User.php | 1 + application/admin/lang/zh-cn.php | 15 ++ .../admin/view/default/goods/save_info.html | 4 +- .../view/default/goodscategory/index.html | 42 +++--- .../admin/view/default/public/footer.html | 2 +- application/service/GoodsService.php | 138 ++++++++++++++---- application/service/ResourcesService.php | 24 +++ application/service/SearchService.php | 4 +- extend/base/Uploader.php | 7 +- .../ueditor/themes/default/css/ueditor.css | 24 +-- .../common/lib/ueditor/ueditor.config.js | 2 +- 15 files changed, 226 insertions(+), 171 deletions(-) diff --git a/application/admin/config/app.php b/application/admin/config/app.php index 1890fd05e..a0b8b8c1e 100644 --- a/application/admin/config/app.php +++ b/application/admin/config/app.php @@ -50,7 +50,7 @@ return array( 'imageUrlPrefix' => '', // 上传保存路径,可以自定义保存路径和文件名格式 - 'imagePathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/image/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'imagePathFormat' => __MY_ROOT__.'static/upload/image/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 涂鸦图片上传配置项 @@ -61,7 +61,7 @@ return array( 'scrawlFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'scrawlPathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/scrawl/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'scrawlPathFormat' => __MY_ROOT__.'static/upload/image/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 上传大小限制,单位B 'scrawlMaxSize' => MyC('home_max_limit_image', 2048000, true), @@ -78,7 +78,7 @@ return array( 'snapscreenActionName' => 'uploadimage', // 上传保存路径,可以自定义保存路径和文件名格式 - 'snapscreenPathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/screenshot/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'snapscreenPathFormat' => __MY_ROOT__.'static/upload/image/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 图片访问路径前缀 'snapscreenUrlPrefix' => '', @@ -98,7 +98,7 @@ return array( 'catcherFieldName' => 'source', // 上传保存路径,可以自定义保存路径和文件名格式 - 'catcherPathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/catchimage/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'catcherPathFormat' => __MY_ROOT__.'static/upload/image/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 图片访问路径前缀 'catcherUrlPrefix' => '', @@ -118,7 +118,7 @@ return array( 'videoFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'videoPathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/video/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'videoPathFormat' => __MY_ROOT__.'static/upload/video/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 视频访问路径前缀 'videoUrlPrefix' => '', @@ -138,7 +138,7 @@ return array( 'fileFieldName' => 'upfile', // 上传保存路径,可以自定义保存路径和文件名格式 - 'filePathFormat' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/file/{yyyy}/{mm}/{dd}/{time}{rand:6}', + 'filePathFormat' => __MY_ROOT__.'static/upload/file/'.input('path_type', 'other').'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 文件访问路径前缀 'fileUrlPrefix' => '', @@ -155,7 +155,7 @@ return array( 'imageManagerActionName'=> 'listimage', // 指定要列出图片的目录 - 'imageManagerListPath' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/image/', + 'imageManagerListPath' => __MY_ROOT__.'static/upload/image/'.input('path_type', 'other').'/', // 每次列出文件数量 'imageManagerListSize' => 20, @@ -175,7 +175,7 @@ return array( 'fileManagerActionName' => 'listfile', // 指定要列出文件的目录 - 'fileManagerListPath' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/file/', + 'fileManagerListPath' => __MY_ROOT__.'static/upload/file/'.input('path_type', 'other').'/', // 文件访问路径前缀 'fileManagerUrlPrefix' => '', @@ -190,7 +190,7 @@ return array( 'videoManagerActionName' => 'listvideo', // 指定要列出文件的目录 - 'videoManagerListPath' => __MY_ROOT__.'static/upload/'.input('path_type', 'other').'/video/', + 'videoManagerListPath' => __MY_ROOT__.'static/upload/video/'.input('path_type', 'other').'/', // 文件访问路径前缀 'videoManagerUrlPrefix' => '', diff --git a/application/admin/controller/Admin.php b/application/admin/controller/Admin.php index 52020f5ac..b2b5075f8 100755 --- a/application/admin/controller/Admin.php +++ b/application/admin/controller/Admin.php @@ -55,6 +55,7 @@ class Admin extends Common 'number' => $number, 'total' => $total, 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, 'url' => url('admin/admin/index'), ); $page = new \base\Page($page_params); diff --git a/application/admin/controller/Goods.php b/application/admin/controller/Goods.php index 9e4b937e2..624ae5a1d 100755 --- a/application/admin/controller/Goods.php +++ b/application/admin/controller/Goods.php @@ -131,6 +131,9 @@ class Goods extends Common // 参数 $this->assign('params', $params); + // 编辑器文件存放地址 + $this->assign('editor_path_type', 'goods'); + return $this->fetch(); } diff --git a/application/admin/controller/GoodsCategory.php b/application/admin/controller/GoodsCategory.php index b5a05d4b7..5b7d796e8 100755 --- a/application/admin/controller/GoodsCategory.php +++ b/application/admin/controller/GoodsCategory.php @@ -1,7 +1,8 @@ assign('common_is_text_list', lang('common_is_text_list')); - $this->display('Index'); + + // 编辑器文件存放地址 + $this->assign('editor_path_type', 'goods_category'); + + return $this->fetch(); } /** @@ -62,43 +67,11 @@ class GoodsCategory extends Common $this->error(lang('common_unauthorized_access')); } - // 获取数据 - $field = array('id', 'pid', 'icon', 'name', 'sort', 'is_enable', 'bg_color', 'big_images', 'vice_name', 'describe', 'is_home_recommended'); - $data = db('GoodsCategory')->field($field)->where(array('pid'=>intval(I('id', 0))))->select(); - if(!empty($data)) - { - $image_host = config('IMAGE_HOST'); - foreach($data as &$v) - { - $v['is_son'] = $this->IsExistSon($v['id']); - $v['ajax_url'] = url('Admin/GoodsCategory/GetNodeSon', array('id'=>$v['id'])); - $v['delete_url'] = url('Admin/GoodsCategory/Delete'); - $v['icon_url'] = empty($v['icon']) ? '' : $image_host.$v['icon']; - $v['big_images_url'] = empty($v['big_images']) ? '' : $image_host.$v['big_images']; - $v['json'] = json_encode($v); - } - } - $msg = empty($data) ? lang('common_not_data_tips') : lang('common_operation_success'); - $this->ajaxReturn($msg, 0, $data); + // 开始操作 + $ret = GoodsService::GoodsCategoryNodeSon(input()); + return json($ret); } - /** - * [IsExistSon 节点是否存在子数据] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-25T15:22:47+0800 - * @param [int] $id [节点id] - * @return [string] [有数据ok, 则no] - */ - private function IsExistSon($id) - { - if(!empty($id)) - { - return (db('GoodsCategory')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no'; - } - return 'no'; - } /** * [Save 分类保存] @@ -115,62 +88,9 @@ class GoodsCategory extends Common $this->error(lang('common_unauthorized_access')); } - // icon - $this->FileSave('icon', 'file_icon', 'goods_category'); - - // 大图片 - $this->FileSave('big_images', 'file_big_images', 'goods_category'); - - // id为空则表示是新增 - $m = D('GoodsCategory'); - - // 公共额外数据处理 - $m->sort = intval(I('sort')); - - // 添加 - if(empty($_POST['id'])) - { - if($m->create($_POST, 1)) - { - // 额外数据处理 - $m->add_time = time(); - $m->name = I('name'); - $m->vice_name = I('vice_name'); - $m->describe = I('describe'); - $m->is_home_recommended = intval(I('is_home_recommended', 0)); - - // 写入数据库 - if($m->add()) - { - $this->ajaxReturn(lang('common_operation_add_success')); - } else { - $this->ajaxReturn(lang('common_operation_add_error'), -100); - } - } - } else { - // 编辑 - if($m->create($_POST, 2)) - { - // 额外数据处理 - $m->name = I('name'); - $m->upd_time = time(); - $m->vice_name = I('vice_name'); - $m->describe = I('describe'); - $m->is_home_recommended = intval(I('is_home_recommended', 0)); - - // 移除 id - unset($m->id, $m->pid); - - // 更新数据库 - if($m->where(array('id'=>I('id')))->save()) - { - $this->ajaxReturn(lang('common_operation_edit_success')); - } else { - $this->ajaxReturn(lang('common_operation_edit_error'), -100); - } - } - } - $this->ajaxReturn($m->getError(), -1); + // 开始操作 + $ret = GoodsService::GoodsCategorySave(input()); + return json($ret); } /** @@ -192,12 +112,12 @@ class GoodsCategory extends Common { if($m->delete(I('id'))) { - $this->ajaxReturn(lang('common_operation_delete_success')); + return json(lang('common_operation_delete_success')); } else { - $this->ajaxReturn(lang('common_operation_delete_error'), -100); + return json(lang('common_operation_delete_error'), -100); } } else { - $this->ajaxReturn($m->getError(), -1); + return json($m->getError(), -1); } } } diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index 9eafa7f1b..dc2be4d92 100755 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -56,6 +56,7 @@ class User extends Common 'number' => $number, 'total' => $total, 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, 'url' => url('admin/user/index'), ); $page = new \base\Page($page_params); diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index 22964fe0a..75705c0ba 100644 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -300,5 +300,20 @@ return array( 'goods_video_text' => '短视频', 'goods_video_tips' => '视频比图文更有具带入感,仅支持 mp4 格式', + + + // 商品分类 + 'goods_category_add_name' => '分类添加', + 'goods_category_edit_name' => '分类编辑', + + 'goods_category_big_images_text' => '大图片', + + 'goods_category_vice_name_text' => '副名称', + 'goods_category_vice_name_format' => '副名称最大60个字符', + + 'goods_category_describe_text' => '描述', + 'goods_category_describe_format' => '描述最大200个字符', + + 'goods_category_home_recommended_text' => '首页推荐', ); ?> \ No newline at end of file diff --git a/application/admin/view/default/goods/save_info.html b/application/admin/view/default/goods/save_info.html index 6b85b54da..dd66294a4 100755 --- a/application/admin/view/default/goods/save_info.html +++ b/application/admin/view/default/goods/save_info.html @@ -137,7 +137,7 @@ {{/if}}