diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 29ac1ce..1a3dff9 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -1,18 +1,21 @@ mer_type = $mer_type; + $this->merchant = $merchant; + $this->path = [ + 'index' => 'merchant/system/merchant/type/index', + 'read' => 'merchant/system/merchant/type/read', + 'add' => 'merchant/system/merchant/type/add' + ]; } - /** + /** * 空白菜单页,由前端 ajax 获取数据 */ - function Index() + public function Index() { - return View('merchant/system/merchant/type/index'); + return View($this->path['index']); } /** * 添加/编辑 表单页 */ - public function Form() + public function Form(MenuModel $menu, FormatList $format) { - if ($param['mer_id']>0) { - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - // halt($detail['slider_image_arr']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $param = get_params(); + $id = isset($param['id']) ? (int)$param['id'] : 0; + + if (!empty($id)) { + // 进入编辑页,显示店铺数据 + $detail = $this->merchant->Find($id); } - return view(); + if (empty($detail)) { + $detail = [ + "create_time" => '', + "description" => '', + "id" => '', + "margin" => 0, + "is_margin" => 0, + "type_info" => '', + "description" => '', + "type_name" => '', + "update_time" => '' + ]; + } + + // 查出商户所有菜单数据 + $data = $menu->Search([], 1); + View::assign('dataTree', $format->FormatCategory($data['list'])); + View::assign('detail', $detail); + + return view($this->path['add']); } /** - * 显示店铺类型列表 + * 输出店铺类型列表数据 * * @return \think\Response */ public function Lst() { - echo 1723; $param = get_params(); - $where = []; - if (isset($param['keywords']) && !empty($param['keywords'])){ - $where[]=['store_name','like','%'.$param['keywords'].'%']; - } - $list = $this->model->getStoreProductList($where,$param); + $page = empty($param['page']) ? 1 : (int)$param['page']; + $limit = empty($param['limit']) ? 10 : (int)$param['limit']; - return table_assign(0, '', $list); + $data = $this->merchant->GetList($page, $limit); + + return table_assign(0, '', $data); } /** + * TODO: 关联权限待完成 + * * 添加店铺类型. * * @return \think\Response */ public function Add() { - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - return to_assign(0,'操作成功'); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** - * 显示指定的店铺详情 + * 查看指定的店铺详情 * - * @param int $id * @return \think\Response */ - public function Detail($id) + public function Read() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - return view(); - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $id = isset($param['id']) ? (int)$param['id'] : 0; + + $detail = $this->merchant->Find($id); + + if (!empty($detail)) { + View::assign('detail', $detail); + return view($this->path['read']); + } else { + throw new \think\exception\HttpException(404, '找不到页面'); + } } /** - * 显示编辑资源表单页. + * TODO: 关联权限待完成 + * 编辑指定菜单. * * @param int $id * @return \think\Response */ - public function edit($id) + public function Edit() { - return to_assign(0,''); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** @@ -132,36 +173,39 @@ class MerchantType extends BaseController * @param int $id * @return \think\Response */ - public function del($id) + public function Del() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $type = isset($param['type']) ? $param['type'] : 0; + if (empty($param['id'])) { + return 0; + } + $id = (int)$param['id']; - $this->model->delStoreProductById($product_id,1); + $rows = $this->merchant->Del($id); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } + /** * 备注表单页 */ - public function MarkForm() - { - return View(''); - } /** * 店铺类型备注 */ public function Mark() { + $params = get_params(); return to_assign(0, ''); } /** * 店铺类型说明 */ - public function Description(){ - View::assign('detail',[]); - return View('merchant/system/merchant/descr/index',['id'=>1]); + public function Description() + { + View::assign('detail', []); + return View('merchant/system/merchant/descr/index', ['id' => 1]); } } diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index c65f134..1432f04 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -52,16 +52,19 @@ Route::group(function(){ Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ '_alias' => '列表', ]); - Route::get('detail/:id', '/detail')->name('systemMerchantTypeDetail')->option([ + Route::get('read', '/read')->name('systemMerchantTypeDetail')->option([ '_alias' => '详情', ]); + Route::get('form', '/form')->name('systemMerchantTypeAdd')->option([ + '_alias' => '添加/编辑页', + ]); Route::post('add', '/add')->name('systemMerchantTypeAdd')->option([ '_alias' => '添加', ]); - Route::put('edit/:id', '/edit')->name('systemMerchantTypeUpdate')->option([ + Route::put('edit', '/edit')->name('systemMerchantTypeUpdate')->option([ '_alias' => '编辑', ]); - Route::delete('del/:id', '/del')->name('systemMerchantTypeDelete')->option([ + Route::delete('del', '/del')->name('systemMerchantTypeDelete')->option([ '_alias' => '删除', ]); Route::get('mark/:id', '/markForm')->name('systemMerchantTypeMarkForm')->option([ @@ -69,7 +72,7 @@ Route::group(function(){ '_auth' => false, '_form' => 'systemMerchantTypeMark', ]); - Route::post('mark/:id', '/mark')->name('systemMerchantTypeMark')->option([ + Route::post('mark', '/mark')->name('systemMerchantTypeMark')->option([ '_alias' => '备注', ]); diff --git a/app/admin/view/merchant/system/merchant/type/add.html b/app/admin/view/merchant/system/merchant/type/add.html index d5368fe..25d57e3 100644 --- a/app/admin/view/merchant/system/merchant/type/add.html +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -13,139 +13,64 @@ {block name="body"}
@@ -155,95 +80,130 @@ {block name="script"} + {/block} - \ No newline at end of file + diff --git a/app/admin/view/merchant/system/merchant/type/index.html b/app/admin/view/merchant/system/merchant/type/index.html index a2bb254..c5a0624 100644 --- a/app/admin/view/merchant/system/merchant/type/index.html +++ b/app/admin/view/merchant/system/merchant/type/index.html @@ -3,23 +3,21 @@ {block name="body"}商品名称* | +店铺类型名称 | + autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly> | |||||||||
商户商品分类* | -
-
-
-
+ | 店铺类型要求 | ++ | ||||||||
品牌选择* | -
-
-
-
- |
- ||||||||||
商品封面图 | -
-
-
-
-
-
-
-
- |
- ||||||||||
商品轮播图 | -
-
-
-
-
-
-
- {volist name='detail.slider_image_arr' id='vo'}
- {if $vo}
-
- |
- ||||||||||
单位* | -- | ||||||||||
商品关键字* | -- | ||||||||||
售价* | +店铺保证金 | - | |||||||||
成本价* | -- | ||||||||||
市场价* | -- | ||||||||||
库存* | -+ autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly> | ||||||||||
商品简介 | +店铺权限 | ++ + + | +|||||||||
其它说明 | |||||||||||
商品详情 | +创建时间 | - + {$detail.create_time} + | +|||||||||
修改时间 | ++ {$detail.update_time} |