From 41308be2a45729a5f66f4f81cb7ac49692561047 Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 17 Apr 2020 15:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AF=BC=E8=88=AA=E7=AE=A1?= =?UTF-8?q?=E7=90=86,=E5=8F=AF=E7=94=A8=E4=BA=8E=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=AF=BC=E8=88=AA,=E8=BD=AE=E6=92=AD=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Nav.php | 129 ++++++++++++++ app/common/ColumnFormat.php | 18 ++ app/model/Nav.php | 18 ++ .../20200417060522_create_table_nav.php | 51 ++++++ view/admin/common/left_system.html | 28 +++ view/admin/nav/create.html | 159 +++++++++++++++++ view/admin/nav/edit.html | 164 ++++++++++++++++++ view/admin/nav/index.html | 108 ++++++++++++ 8 files changed, 675 insertions(+) create mode 100644 app/admin/controller/Nav.php create mode 100644 app/common/ColumnFormat.php create mode 100644 app/model/Nav.php create mode 100644 database/migrations/20200417060522_create_table_nav.php create mode 100644 view/admin/nav/create.html create mode 100644 view/admin/nav/edit.html create mode 100644 view/admin/nav/index.html diff --git a/app/admin/controller/Nav.php b/app/admin/controller/Nav.php new file mode 100644 index 0000000..7b18422 --- /dev/null +++ b/app/admin/controller/Nav.php @@ -0,0 +1,129 @@ +param('type',1); + + $list = ModelNav::order('sort asc')->order('id asc')->where('type',$type)->paginate(); + + View::assign('type', $type); + View::assign('list', $list); + return View::fetch(); + } + + /** + * 显示创建资源表单页. + * + * @return \think\Response + */ + public function create() + { + // + + return View::fetch(); + } + + /** + * 保存新建的资源 + * + * @param \think\Request $request + * @return \think\Response + */ + public function save(Request $request) + { + // + $post_data = $request->post(); + + ModelNav::create($post_data); + + return $this->success('添加成功', url('index',[ + 'type'=>$request->param('type',1), + 'show_img'=>$request->param('show_img'), + 'show_target'=>$request->param('show_target'), + 'show_xcx'=>$request->param('show_xcx'), + ])); + } + + /** + * 显示指定的资源 + * + * @param int $id + * @return \think\Response + */ + public function read($id) + { + // + } + + /** + * 显示编辑资源表单页. + * + * @param int $id + * @return \think\Response + */ + public function edit($id) + { + // + + $model_nav = ModelNav::find($id); + + + View::assign('nav', $model_nav); + return View::fetch(); + } + + /** + * 保存更新的资源 + * + * @param \think\Request $request + * @param int $id + * @return \think\Response + */ + public function update(Request $request, $id) + { + // + $post_data = $request->post(); + $model_nav = ModelNav::find($id); + + $model_nav->save($post_data); + + return $this->success('保存成功', url('index',[ + 'type'=>$model_nav->getData('type'), + 'show_img'=>$request->param('show_img'), + 'show_target'=>$request->param('show_target'), + 'show_xcx'=>$request->param('show_xcx'), + ])); + } + + /** + * 删除指定资源 + * + * @param int $id + * @return \think\Response + */ + public function delete($id) + { + // + + ModelNav::destroy($id); + + return $this->success("删除成功"); + } +} diff --git a/app/common/ColumnFormat.php b/app/common/ColumnFormat.php new file mode 100644 index 0000000..7cb484d --- /dev/null +++ b/app/common/ColumnFormat.php @@ -0,0 +1,18 @@ +setLimit(10) + ->setSigned(false); + } + public static function loadDeleteTime(){ + return Column::make('delete_time','integer') + ->setLimit(10) + ->setSigned(false); + } +} diff --git a/app/model/Nav.php b/app/model/Nav.php new file mode 100644 index 0000000..44b1171 --- /dev/null +++ b/app/model/Nav.php @@ -0,0 +1,18 @@ +table('nav',['comment'=>'多功能导航,可兼容多种类型','sign'=>false]); + + $table->addColumn('title','string',['limit'=>100,'comment'=>'名称标题']); + $table->addColumn(Column::make('sort','integer')->setSigned(false)->setComment('排序,越小越靠前')); + $table->addColumn(Column::make('create_time','integer')->setSigned(false)->setLimit(10)->setComment('添加时间')); + $table->addColumn(ColumnFormat::timestamp('update_time')); + $table->addColumn(ColumnFormat::timestamp('delete_time')); + $table->addColumn(Column::make('type','integer')->setLimit(10)->setSigned(false)->setComment('类型,用于区分业务场景:1:PC导航,2:PC轮播图,3:PC友情链接')); + $table->addColumn(Column::make('img','string')->setLimit(100)->setComment('图片')); + $table->addColumn(Column::make('target','string')->setLimit(10)->setSigned(false)->setComment('网页链接打开对象,_BLANK,_SELF,iframe_name')); + $table->addColumn(Column::make('xcx_type','integer')->setLimit(10)->setComment('小程序打开方式,1:小程序导航页面,2:普通页面,3:web-view,4:其他小程序,5:电话')); + $table->addColumn(Column::make('value','string')->setLimit(100)->setComment('对象值,有可能是网页链接,小程序导航页面路径,小程序普通页面路径,电话')); + $table->addColumn(Column::make('xcx_appid','string')->setLimit(30)->setComment('小程序appid,目标是其他小程序是有效')); + $table->addIndex('delete_time'); + $table->addIndex('type'); + $table->addIndex('sort'); + $table->create(); + } +} diff --git a/view/admin/common/left_system.html b/view/admin/common/left_system.html index e47c295..04bbe6d 100644 --- a/view/admin/common/left_system.html +++ b/view/admin/common/left_system.html @@ -12,5 +12,33 @@ 用户协议管理 + + \ No newline at end of file diff --git a/view/admin/nav/create.html b/view/admin/nav/create.html new file mode 100644 index 0000000..1d97a1a --- /dev/null +++ b/view/admin/nav/create.html @@ -0,0 +1,159 @@ + + + + + + + + PC导航管理 + {include file="common/_require"} + + + + + + +
+ {include file="common/_header"} + + {include file="common/left_system"} + +
+ +
+
+ + 首页 + 系统信息 + +
+
+
+
+
+ 添加 +
+
+ + + + + +
+
标题
+
+ +
+
+ + {if $Request.param.show_img == 1 } +
+
图片
+
+ +
+
上传
+
+
+ +
+
+
+ {/if} + {if $Request.param.show_target == 1 } +
+
打开方式
+
+ + +
+
+
+
链接
+
+ +
+
+ {/if} + {if $Request.param.show_xcx == 1 } +
+
小程序打开类型
+
+ + + + +
+
+
+
小程序页面
+
+ +
+
+
+
小程序appid
+
+ +
小程序打开类型为其他小程序时生效
+
+
+ {/if} +
+
排序
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+ + + {include file="common/_footer"} +
+ + + + + \ No newline at end of file diff --git a/view/admin/nav/edit.html b/view/admin/nav/edit.html new file mode 100644 index 0000000..a1bd93c --- /dev/null +++ b/view/admin/nav/edit.html @@ -0,0 +1,164 @@ + + + + + + + + PC导航管理 + {include file="common/_require"} + + + + + + +
+ {include file="common/_header"} + + {include file="common/left_system"} + +
+ +
+
+ + 首页 + 系统信息 + +
+
+
+
+
+ 编辑 +
+
+ + + +
+
标题
+
+ +
+
+ + {if $Request.param.show_img == 1 } +
+
图片
+
+ +
+
上传
+
+
+ +
+
+
+ {/if} + {if $Request.param.show_target == 1 } +
+
打开方式
+
+ + +
+
+
+
链接
+
+ +
+
+ {/if} + {if $Request.param.show_xcx == 1 } +
+
小程序打开类型
+
+ + + + +
+
+
+
小程序页面
+
+ +
+
+
+
小程序appid
+
+ +
小程序打开类型为其他小程序时生效
+
+
+ {/if} +
+
排序
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+ + + {include file="common/_footer"} +
+ + + + + \ No newline at end of file diff --git a/view/admin/nav/index.html b/view/admin/nav/index.html new file mode 100644 index 0000000..8ec5046 --- /dev/null +++ b/view/admin/nav/index.html @@ -0,0 +1,108 @@ + + + + + + + + PC导航管理 + {include file="common/_require"} + + + + + + +
+ {include file="common/_header"} + + {include file="common/left_system"} + +
+ +
+
+ + 首页 + 系统信息 + +
+
+
+ 添加 +
+ +
+ + + + + + + + + + + + + {volist name='list' id='vo'} + + + + + + + + + + + {/volist} + {if condition="count($list) == 0" } + + + + {/if} + +
ID名称链接排序操作
{$vo.id}{$vo.title}{$vo.value}{$vo.sort} +
+ 编辑 +
删除
+
+
暂无数据
+
+ {$list|raw} +
+
+
+
+
+ + + {include file="common/_footer"} +
+ + + + + + \ No newline at end of file