diff --git a/application/plugins/answers/Admin.php b/application/plugins/answers/Admin.php index 21a046daa..dc96c7626 100644 --- a/application/plugins/answers/Admin.php +++ b/application/plugins/answers/Admin.php @@ -13,6 +13,7 @@ namespace app\plugins\answers; use think\Controller; use app\service\PluginsService; use app\plugins\answers\Service; +use app\service\SearchService; /** * 问答 - 后台管理 @@ -118,9 +119,6 @@ class Admin extends Controller */ public function sliderinfo($params = []) { - // 参数 - $params = input(); - // 数据 if(!empty($params['id'])) { @@ -151,7 +149,6 @@ class Admin extends Controller } // 开始处理 - $params = input(); return Service::SlideSave($params); } @@ -161,8 +158,9 @@ class Admin extends Controller * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-15T11:03:30+0800 + * @param [array] $params [输入参数] */ - public function sliderdelete() + public function sliderdelete($params = []) { // 是否ajax请求 if(!IS_AJAX) @@ -171,7 +169,6 @@ class Admin extends Controller } // 开始处理 - $params = input(); return Service::SlideDelete($params); } @@ -181,8 +178,9 @@ class Admin extends Controller * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2017-01-12T22:23:06+0800 + * @param [array] $params [输入参数] */ - public function sliderstatusupdate() + public function sliderstatusupdate($params = []) { // 是否ajax请求 if(!IS_AJAX) @@ -191,8 +189,70 @@ class Admin extends Controller } // 开始处理 - $params = input(); return Service::SlideStatusUpdate($params); } + + + /** + * 推荐商品编辑编辑 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function goodsinfo($params = []) + { + // 数据 + if(!empty($params['id'])) + { + $data_params = array( + 'where' => ['id'=>intval($params['id'])], + ); + $ret = Service::SlideList($data_params); + $this->assign('data', empty($ret['data'][0]) ? [] : $ret['data'][0]); + } + + return $this->fetch('../../../plugins/view/answers/admin/goodsinfo'); + } + + /** + * 商品搜索 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function goodssearch($params = []) + { + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 搜索数据 + return Service::GoodsSearchList($params); + } + + /** + * 商品保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function goodssave($params = []) + { + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + print_r($params);die; + } } ?> \ No newline at end of file diff --git a/application/plugins/answers/Service.php b/application/plugins/answers/Service.php index edea9c97a..adcf29cad 100644 --- a/application/plugins/answers/Service.php +++ b/application/plugins/answers/Service.php @@ -204,5 +204,42 @@ class Service } return DataReturn('编辑失败或数据未改变', -100); } + + /** + * 商品搜索 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + * @param [array] $params [输入参数] + */ + public static function GoodsSearchList($params = []) + { + // 条件 + $where = [ + ['g.is_delete_time', '=', 0], + ['g.is_shelves', '=', 1] + ]; + + // 关键字 + if(!empty($params['keywords'])) + { + $where[] = ['g.title', 'like', '%'.$params['keywords'].'%']; + } + + // 分类id + if(!empty($params['category_id'])) + { + $category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']], 1); + $category_ids[] = $params['category_id']; + $where[] = ['gci.category_id', 'in', $category_ids]; + } + + // 指定字段 + $field = 'g.id,g.title'; + + // 获取数据 + return GoodsService::CategoryGoodsList(['where'=>$where, 'm'=>0, 'n'=>100, 'field'=>$field]); + } } ?> \ No newline at end of file diff --git a/application/plugins/view/answers/admin/baseinfo.html b/application/plugins/view/answers/admin/baseinfo.html index abea0b93f..18e47919c 100755 --- a/application/plugins/view/answers/admin/baseinfo.html +++ b/application/plugins/view/answers/admin/baseinfo.html @@ -26,7 +26,7 @@
- +
@@ -40,6 +40,21 @@
+
+ + +
+ +
+ + +
+ +
+ + +
+
diff --git a/application/plugins/view/answers/admin/goodsinfo.html b/application/plugins/view/answers/admin/goodsinfo.html new file mode 100644 index 000000000..9fa0832e4 --- /dev/null +++ b/application/plugins/view/answers/admin/goodsinfo.html @@ -0,0 +1,72 @@ +{{include file="public/header" /}} + + +
+
+ + + {{if empty($data['id'])}} + 商品添加 + {{else /}} + 商品编辑 + {{/if}} + + 返回 + + +
+ +
+
+
+ + + +
+
+ +
+
可选
+
    +
    没有相关数据
    +
+
+ +
+
已选
+
    +
    没有相关数据
    + {{if !empty($goods_list)}} + {{foreach $goods_list as $v}} +
  • + {{$v.name}} + +
  • + {{/foreach}} + {{/if}} +
+
+
+
+ +
+ + +
+
+ +
+
+
+ + + +{{include file="public/footer" /}} + \ No newline at end of file diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php index d3c2c3fa8..4294206b8 100755 --- a/application/service/GoodsService.php +++ b/application/service/GoodsService.php @@ -310,10 +310,16 @@ class GoodsService } // 产地 - $v['place_origin_name'] = empty($v['place_origin']) ? null : RegionService::RegionName($v['place_origin']); + if(isset($v['place_origin_name'])) + { + $v['place_origin_name'] = empty($v['place_origin']) ? null : RegionService::RegionName($v['place_origin']); + } // 品牌 - $v['brand_name'] = empty($v['brand_id']) ? null : BrandService::BrandName($v['brand_id']); + if(isset($v['brand_id'])) + { + $v['brand_name'] = empty($v['brand_id']) ? null : BrandService::BrandName($v['brand_id']); + } // 时间 if(!empty($v['add_time'])) diff --git a/public/static/plugins/css/answers/admin.css b/public/static/plugins/css/answers/admin.css index 75de25c8a..230037d85 100644 --- a/public/static/plugins/css/answers/admin.css +++ b/public/static/plugins/css/answers/admin.css @@ -7,11 +7,12 @@ padding-bottom: 20px; } .answers-content .items .immages-tag { - border: 1px solid #eee; text-align: center; } .answers-content .items .immages-tag img { max-width: 100%; + border: 1px dashed #eee; + padding: 5px; } .answers-content .edit-submit { margin-bottom: 20px; @@ -35,4 +36,114 @@ ul.plugins-images-view li { width: 100%; height: auto; -} \ No newline at end of file +} + + +/** + * 商品推荐编辑 + */ +form.am-form { + margin-bottom: 20px; +} +form.am-form .am-form-group { + padding: 0; +} +.goods-container .goods-form-category, .goods-container .chosen-container, .goods-container .goods-form-keywords { + width: 30% !important; +} +.goods-container .chosen-container, .goods-container .goods-form-keywords { + display: -webkit-inline-box !important; +} +.goods-container .chosen-single { + width: 100%; +} +.goods-container .goods-form { + margin-bottom: 2px; +} +.goods-list { + overflow: hidden; + margin-bottom: 20px; + position: relative; +} +.goods-list .goods-items { + width: calc(50% - 50px); + height: 300px; +} +.goods-list .goods-items .title { + text-align: center; +} +.goods-list .goods-items .goods-content { + border: 1px solid #eee; + height: calc(100% - 25px); + overflow-y: scroll; + overflow-x: hidden; + border-radius: 2px; +} +.goods-list .goods-items .goods-content li { + padding: 5px 45px 5px 5px; + border-style: dotted; + border-color: #eaeaea; + border-width: 1px 0; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + max-width: 100%; + color: #666; + position: relative; +} +.goods-list .goods-items .goods-content li:nth-child(2) { + border-top: 0; +} +.goods-list .goods-items .goods-content li i { + cursor: pointer; + padding: 0 10px 0 5px; + position: absolute; + top: 5px; + right: 5px; +} +.goods-list .selected-all { + position: absolute; + top: 50%; + left: calc(50% - 30px); +} +.goods-container input[name="goods_category_ids"] { + position: absolute; + left: -1000000px; + top: -1000000px; +} +.goods-list i { + color: #888 !important; +} +.am-form-error .goods-items .goods-content { + border-color: #dd514c; +} + +.content-view { + max-width: 100%; + max-height: 200px; + overflow-y: auto; + overflow-x: hidden; +} +.content-view-win { + border: 1px solid #eee; + padding: 10px; +} +.content-view-win img, .content-view img { + max-width: 100%; +} + +@media only screen and (max-width: 641px) { + .goods-container .goods-form-category, .goods-container .goods-form-keywords + { + width: calc(55% - 60px) !important; + display: -webkit-inline-box !important; + } + .goods-container .chosen-container { + display: none !important; + } + + .content-view-td { + display: none; + } +} + diff --git a/public/static/plugins/js/answers/admin.js b/public/static/plugins/js/answers/admin.js new file mode 100644 index 000000000..18a6c24a4 --- /dev/null +++ b/public/static/plugins/js/answers/admin.js @@ -0,0 +1,107 @@ +$(function() +{ + // 添加元素到右侧 + function RightElementAdd(value, name) + { + if($('ul.ul-right').find('.items-li-'+value).length == 0) + { + var html = '
  • '+name+'
  • '; + $('ul.ul-right').append(html); + } + + // 右侧数据同步 + RightElementGoods(); + + // 左侧是否还有内容 + if($('ul.ul-left li').length == 0) + { + $('ul.ul-left .table-no').removeClass('none'); + } else { + $('ul.ul-left .table-no').addClass('none'); + } + } + + // 批量-商品id同步 + function RightElementGoods() + { + var value_all = []; + $('ul.ul-right li').each(function(k, v) + { + value_all[k] = $(this).find('span.name').data('value'); + }); + $('.goods-container input[name="goods_category_ids"]').val(value_all.join(',')).blur(); + + // 右侧是否还有数据 + if($('ul.ul-right li').length == 0) + { + $('ul.ul-right .table-no').removeClass('none'); + } else { + $('ul.ul-right .table-no').addClass('none'); + } + } + // 左侧点击到右侧 + $('ul.ul-left').on('click', 'i.am-icon-angle-right', function() + { + var value = $(this).prev().data('value'); + var name = $(this).prev().text(); + $(this).parent().remove(); + RightElementAdd(value, name); + }); + + // 左侧全部移动到右侧 + $('.selected-all').on('click', function() + { + $('ul.ul-left li').each(function(k, v) + { + var value = $(this).find('span.name').data('value'); + var name = $(this).find('span.name').text(); + $(this).remove(); + RightElementAdd(value, name); + }); + }); + + // 右侧删除 + $('ul.ul-right').on('click', 'i.am-icon-trash-o', function() + { + $(this).parent().remove(); + RightElementGoods(); + }); + + // 商品搜索 + $('.goods-form .search-submit').on('click', function() + { + var category_id = $('.goods-form .goods-form-category').val(); + var keywords = $('.goods-form .goods-form-keywords').val(); + console.log(category_id, keywords) + + // ajax请求 + $.ajax({ + url:$('.goods-form').data('search-url'), + type:'POST', + dataType:"json", + timeout:10000, + data:{"category_id": category_id, "keywords": keywords}, + success:function(result) + { + if(result.code == 0) + { + var html = ''; + for(var i in result.data) + { + html += '
  • '+result['data'][i]['title']+'
  • '; + } + $('ul.ul-left .table-no').addClass('none'); + $('ul.ul-left li').remove(); + $('ul.ul-left').append(html); + } else { + Prompt(result.msg); + } + }, + error:function() + { + Prompt('网络异常错误'); + } + }); + }); + +}); \ No newline at end of file