diff --git a/app/BaseController.php b/app/BaseController.php index 742ff28..f3d35a3 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -212,18 +212,16 @@ abstract class BaseController $htpw = Request::scheme().'://'. $www; return $htpw; } - - //得到当前系统安装前台域名 - protected function getIndexUrl() - { - $sys = $this->getSystem(); - $domain = $this->getHttpUrl($sys['domain']); - $syscy = $sys['clevel'] ? Lang::get('Authorized') : Lang::get('Free version'); - $runTime = $this->getRunTime(); - View::assign(['domain'=>$domain,'insurl'=>$sys['domain'],'syscy'=>$syscy,'clevel'=>$sys['clevel'],'runTime'=>$runTime]); - return $domain; - } + protected function getDomain() + { + return $this->getHttpUrl($this->getSystem()['domain']); + } + + /** + * 运行时间计算 + * @return string + */ protected function getRunTime() { //运行时间 @@ -242,78 +240,28 @@ abstract class BaseController } /** - * 获取文章链接地址 - * @param int $aid 文章id - * @param string $ename 所属分类ename - * @param string $appname 所属应用名 + * 非admin应用的文章url路由地址 + * @param int $aid + * @param $ename * @return string */ - protected function getRouteUrl(int $aid, string $ename = '', string $appname = '') : string + protected function getRouteUrl(int $aid, $ename = '') { - $indexUrl = $this->getIndexUrl(); + $domain = $this->getDomain(); + $appName = app('http')->getName(); + $articleUrl = (string) url('article_detail', ['id' => $aid]); + // 详情动态路由,$aid, $ename if(config('taoler.url_rewrite.article_as') == '/'){ - // 分类可变路由 - $artUrl = (string) url('article_detail', ['id' => (int) $aid, 'ename'=> $ename]); - //$artUrl = (string) Route::buildUrl('article_detail', ['id' => $aid, 'ename'=> $ename]); - } else { - $artUrl = (string) url('article_detail', ['id' => $aid]); - } -//halt($indexUrl,$artUrl); - //多应用时,文章所属应用 2022.11.17 - $app = app('http')->getName(); - if(empty($appname)) { - // 获取article所属应用的应用名 - $cid = Db::name('article')->where('id',$aid)->value('cate_id'); - $appname = Db::name('cate')->where('id',$cid)->value('appname'); + $articleUrl = (string) url('article_detail', ['id' => (int) $aid, 'ename'=> $ename]); } - // 判断index应用是否绑定域名 - $bind_index = array_search($appname, config('app.domain_bind')); - // 判断index应用是否域名映射 - $map_index = array_search($appname, config('app.app_map')); - // article 所属应用名 - $index = $map_index ?: $appname; // index应用名 +// // 判断应用是否绑定域名 +// $app_bind = array_search($appName, config('app.domain_bind')); +// // 判断应用是否域名映射 +// $app_map = array_search($appName, config('app.app_map')); - // 判断是否开启绑定 - //$domain_bind = array_key_exists('domain_bind',config('app')); - - // 判断index应用是否绑定域名 - //$bind_index = array_search('index',config('app.domain_bind')); - // 判断admin应用是否绑定域名 - $bind_admin = array_search('admin',config('app.domain_bind')); - - // 判断index应用是否域名映射 - //$map_index = array_search('index',config('app.app_map')); - // 判断admin应用是否域名映射 - $map_admin = array_search('admin',config('app.app_map')); - -// $index = $map_index ?: 'index'; // index应用名 - $admin = $map_admin ?: 'admin'; // admin应用名 - - if($bind_index) { -// echo 111; - // index或home前端(非admin应用)域名进行了绑定 -// $url = $indexUrl . str_replace($admin . '/','',$artUrl); - $url = $indexUrl . $artUrl; - } else { - if($bind_admin) { -// echo 222; - // admin绑定域名 - $url = $indexUrl .'/' . $index . $artUrl; - } elseif ($app == 'admin' && isset($map_admin)) { -// echo 333; -// var_dump($admin, $appname, $artUrl); - // admin进行了映射 - $url = $indexUrl . str_replace($admin, $index, $artUrl); - } else { -// echo 444; - // admin未绑定域名 - $url = $indexUrl . str_replace($app, $index, $artUrl); - } - - } -//halt($url); - return $url; + //a.appName不是admin + return $domain . $articleUrl; } /** @@ -459,33 +407,6 @@ abstract class BaseController } - /** - * baidu push api - * - * @param string $link - * @return void - */ - protected function baiduPushUrl(string $link) - { - // baidu 接口 - $api = config('taoler.baidu.push_api'); - if(!empty($api)) { - $url[] = $link; - $ch = curl_init(); - $options = array( - CURLOPT_URL => $api, - CURLOPT_POST => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => implode("\n", $url), - CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), - ); - curl_setopt_array($ch, $options); - curl_exec($ch); - curl_close($ch); - } - - } - /** * 上传接口 * @@ -553,7 +474,7 @@ abstract class BaseController //$dirname = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_DIRNAME); $dirname = date('Ymd',time()); //路径 - $path = 'storage/' . $this->uid . '/article_pic/' . $dirname . '/'; + $path = 'storage/download/article_pic/' . $dirname . '/'; //绝对文件夹 $fileDir = public_path() . $path; //文件绝对路径 @@ -602,4 +523,42 @@ abstract class BaseController return $content; } + /** + * array_filter过滤返回函数 + * @param $arr + * @return bool + */ + protected function filter($arr) :bool + { + if($arr === '' || $arr === null){ + return false; + } + return true; + } + + /** + * 过滤为空null等筛选参数 + * @param array $array + * @return array + */ + public function getParamFilter(array $array) :array + { + return array_filter($array, "filter"); + } + + /** + * 数组根据sort字段数值进行排序 + * @param array $array 数组 + * @param string $sort 排序字段 + * @return array 返回数组 + */ + public function getArrSort(array $array, string $sort = 'sort') :array + { + // 排序 + $cmf_arr = array_column($array, 'sort'); + array_multisort($cmf_arr, SORT_ASC, $array); + + return $array; + } + } diff --git a/app/admin/controller/content/Cate.php b/app/admin/controller/content/Cate.php index 8d4bbe7..a62e786 100644 --- a/app/admin/controller/content/Cate.php +++ b/app/admin/controller/content/Cate.php @@ -1,8 +1,8 @@ * @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved. @@ -11,194 +11,100 @@ namespace app\admin\controller\content; use app\common\controller\AdminController; +use think\App; use think\facade\View; use think\facade\Request; use think\facade\Db; -use think\facade\Cache; use taoler\com\Files; use app\common\lib\Msgres; -use app\common\model\Article; use app\common\model\Cate as CateModel; class Cate extends AdminController { + protected $model; + + public function __construct(App $app) + { + parent::__construct($app); + $this->model = new CateModel(); + } + /** * 浏览 * @return string */ public function index() { - //详情模板 - $sys = $this->getSystem(); - $template = Files::getDirName('../view/'.$sys['template'].'/index/article/'); - View::assign(['template'=>$template]); return View::fetch(); } //帖子分类 public function list() { - $cate = new CateModel(); - if(Request::isAjax()){ - return $cate->getList(); - } - + return $this->model->getList(); } - // 应用下article/view模板 - public function getAppNameView() - { - $appName = input('appname') ?: 'index'; - $sys = $this->getSystem(); - if(is_dir(root_path() . 'app' . DS . $appName . DS . 'view' . DS)){ - $viewPath = root_path() . 'app' . DS . $appName . DS . 'view' . DS . 'article' . DS; - } elseif(is_dir(root_path() . 'view' . DS . $sys['template'] . DS)) { - $viewPath = root_path() . 'view' . DS . $sys['template'] . DS . 'index' . DS . 'article' . DS; - } else { - $viewPath = ''; - } - $template = Files::getDirName($viewPath); - return json(['data' => $template]); - } - - //添加和编辑帖子分类 - public function addEdit() - { - $addOrEdit = !is_null(input('id'));//true是编辑false新增 - $msg = $addOrEdit ? lang('edit') : lang('add'); - if(Request::isAjax()) { - $data = Request::param(); - if(isset($data['id']) && $data['pid'] == $data['id']) return json(['code'=>-1,'msg'=> $msg.'不能作为自己的子类']); - $list = Db::name('cate')->cache('catename')->save($data); - - if($list){ - return json(['code'=>0,'msg'=> $msg.'分类成功']); - }else{ - return json(['code'=>-1,'msg'=> $msg.'分类失败']); - } - } - //详情模板 - $sys = $this->getSystem(); - $template = Files::getDirName('../view/'.$sys['template'].'/index/article/'); - // 如果是新增,pid=0,detpl默认第一个子模块,如果是编辑,查询出cate - $cate = $addOrEdit ? Db::name('cate')->field('detpl,pid,appname')->where(['delete_time' =>0])->find((int) input('id')) : ['pid'=>0,'detpl'=>$template[0],'appname'=>'index']; - // app下前台带模板的应用 - $appArr = []; - if(is_dir(root_path() . 'app' . DS . 'home')) { - $appArr = ['index','home']; - } else { - $appArr = ['index']; - } - View::assign(['template'=>$template,'cate'=>$cate, 'appname' => $appArr]); - return View::fetch(); - } - - //添加分类 - public function add() + //添加和编辑帖子分类 废弃 + public function addEdit() { $addOrEdit = !is_null(input('id'));//true是编辑false新增 - + $msg = $addOrEdit ? lang('edit') : lang('add'); if(Request::isAjax()) { $data = Request::param(); - if(isset($data['id']) && $data['pid'] == $data['id']) return json(['code'=>-1,'msg'=> '不能作为自己的子类']); + if(isset($data['id']) && $data['pid'] == $data['id']) return json(['code'=>-1,'msg'=> $msg.'不能作为自己的子类']); $list = Db::name('cate')->cache('catename')->save($data); - if($list){ - return json(['code'=>0,'msg'=> '添加成功']); - }else{ - return json(['code'=>-1,'msg'=> '添加失败']); + return json(['code'=>0,'msg'=> $msg.'成功']); } + return json(['code'=>-1,'msg'=> $msg.'失败']); } //详情模板 - $sys = $this->getSystem(); - $template = Files::getDirName('../view/'.$sys['template'].'/index/article/'); + $template = $this->getIndexTpl(); // 如果是新增,pid=0,detpl默认第一个子模块,如果是编辑,查询出cate - $cate = ['pid'=>0,'detpl'=>$template[0],'appname'=>'index']; - // app下前台带模板的应用 - $appArr = []; - if(is_dir(root_path() . 'app' . DS . 'home')) { - $appArr = ['index','home']; - } else { - $appArr = ['index']; - } - View::assign(['template'=>$template,'cate'=>$cate, 'appname' => $appArr]); - return View::fetch(); - } + $cate = $addOrEdit ? $this->model->getCateInfoById((int) input('id')) : ''; + $view = $addOrEdit ? 'edit' : 'add'; - //编辑分类 - public function edit() - { - if(Request::isAjax()) { - $data = Request::param(); - - if(isset($data['id']) && $data['pid'] == $data['id']) return json(['code'=>-1,'msg'=> '不能作为自己的子类']); - $list = Db::name('cate')->where('id', input('id'))->save($data); - - if($list){ - return json(['code'=>0,'msg'=> '编辑成功']); - }else{ - return json(['code'=>-1,'msg'=> '编辑失败']); - } - } - //详情模板 - $sys = $this->getSystem(); - $template = Files::getDirName('../view/'.$sys['template'].'/index/article/'); - // 如果是新增,pid=0,detpl默认第一个子模块,如果是编辑,查询出cate - $cate = Db::name('cate')->field('id,catename,ename,detpl,pid,appname,icon,sort,desc')->where(['delete_time' =>0])->find((int) input('id')); - // app下前台带模板的应用 - $appArr = []; - if(is_dir(root_path() . 'app' . DS . 'home')) { - $appArr = ['index','home']; - } else { - $appArr = ['index']; - } - View::assign(['template'=>$template,'cate'=>$cate, 'appname' => $appArr]); - return View::fetch(); + View::assign([ + 'template' => $template, + 'cate' => $cate + ]); + return View::fetch($view); } //删除帖子分类 public function delete() { - if(Request::isAjax()){ - $id = Request::param('id'); - $cate = new CateModel; - $result = $cate->del($id); - if($result == 1){ - return json(['code'=>0,'msg'=>'删除分类成功']); - }else{ - return json(['code'=>-1,'msg'=>$result]); - } - } + $result = $this->model->del(input('id')); + if($result == 1){ + return json(['code'=>0,'msg'=>'删除分类成功']); + } + return json(['code'=>-1,'msg' => $result]); } - - //帖子分类开启热点 - //评论审核 - public function hot() + // 动态审核 + public function check() { - $data = Request::only(['id','is_hot']); - $cate = Db::name('cate')->save($data); - if($cate){ - if($data['is_hot'] == 1){ - return json(['code'=>0,'msg'=>'设置热点成功','icon'=>6]); - } else { - return json(['code'=>0,'msg'=>'取消热点显示','icon'=>5]); - } - }else{ - $res = ['code'=>-1,'msg'=>'热点设置失败']; - } - return json($res); - } - - //array_filter过滤函数 - public function filtr($arr){ - if($arr === '' || $arr === null){ - return false; - } - return true; + $param = Request::only(['id','name','value']); + $data = ['id'=>$param['id'],$param['name']=>$param['value']]; + //获取状态 + $res = Db::name('cate')->save($data); + if($res){ + return json(['code'=>0,'msg'=>'设置成功','icon'=>6]); + } + return json(['code'=>-1,'msg'=>'设置失败']); } + /** + * index/view/article下模板文件 + * @return array + */ + protected function getIndexTpl() :array + { + $sys = $this->getSystem(); + return Files::getDirName('../view/'.$sys['template'].'/index/article/'); + } + } diff --git a/app/admin/controller/content/Forum.php b/app/admin/controller/content/Forum.php index 9727434..6e173c0 100644 --- a/app/admin/controller/content/Forum.php +++ b/app/admin/controller/content/Forum.php @@ -12,6 +12,7 @@ namespace app\admin\controller\content; use app\common\controller\AdminController; use app\common\model\Article; +use think\App; use think\facade\View; use think\facade\Request; use think\facade\Db; @@ -23,6 +24,14 @@ use think\response\Json; class Forum extends AdminController { + protected $model; + + public function __construct(App $app) + { + parent::__construct($app); + $this->model = new Article(); + } + /** * 浏览 * @return string @@ -32,87 +41,31 @@ class Forum extends AdminController return View::fetch(); } - //帖子列表 - public function list() - { - if(Request::isAjax()){ - $data = Request::only(['id','name','title','sec']); - $where =array(); - if (!empty($data['sec'])) { - switch ($data['sec']) { - case '1': - $data['a.status'] = 1; - break; - case '2': - $data['is_top'] = 1; - break; - case '3': - $data['is_hot'] = 1; - break; - case '4': - $data['is_reply'] = 0; - break; - case '5': - $data['a.status'] = -1; - break; - case '6': - $data['a.status'] = 0; - break; - } - } - unset($data['sec']); - unset($data['status']); + public function list() + { + $list = $this->model->getList(input('limit'),input('page')); + $res = []; + if($list['total']){ + foreach($list['data'] as $v) { + $res['data'][] = [ + 'id' => $v['id'], + 'poster' => $v['user']['name'], + 'avatar' => $v['user']['user_img'], + 'title' => htmlspecialchars($v['title']), + 'url' => $this->getArticleUrl($v['id'], 'index', $v['cate']['ename']), + 'content' => strip_tags($v['content']), + 'posttime' => $v['update_time'], + 'top' => $v['is_top'], + 'hot' => $v['is_hot'], + 'reply' => $v['is_reply'], + 'check' => $v['status'] + ]; - if(!empty($data['id'])){ - $data['a.id'] = $data['id']; - unset($data['id']); - } - - if(!empty($data['title'])){ - $where[] = ['title', 'like', '%'.$data['title'].'%']; - unset($data['title']); - } - - $map = array_filter($data,[$this,"filtr"]); - - $forumList = Db::name('article') - ->alias('a') - ->join('user u','a.user_id = u.id') - ->join('cate c','a.cate_id = c.id') - ->field('a.id as aid,ename,appname,name,user_img,title,content,a.update_time as update_time,is_top,a.is_hot as is_hot,is_reply,a.status as status') - ->where('a.delete_time',0) - ->where($map) - ->where($where) - ->order('a.create_time', 'desc') - ->paginate(15); - $res = []; - $count = $forumList->total(); - if($count){ - $res['code'] = 0; - $res['msg'] = ''; - $res['count'] = $count; - foreach($forumList as $k=>$v){ - $url = $this->getRouteUrl($v['aid'],$v['ename'],$v['appname']); - $res['data'][]= [ - 'id'=>$v['aid'], - 'poster'=>$v['name'], - 'avatar'=>$v['user_img'], - 'title'=>htmlspecialchars($v['title']), - 'url' => $url, - 'content' => strip_tags($v['content']), - 'posttime'=>date("Y-m-d",$v['update_time']), - 'top'=>$v['is_top'], - 'hot'=>$v['is_hot'], - 'reply'=>$v['is_reply'], - 'check'=>$v['status'] - ]; - } - } else { - $res = ['code'=>-1,'msg'=>'没有查询结果!']; - } - return json($res); - } - } + } + return json(['code' =>0, 'msg' => 'ok', 'count' => $list['total'], 'data' => $res['data']]); + } + return json(['code' =>-1, 'msg' => 'no data']); + } /** * 添加帖子文章 @@ -142,10 +95,9 @@ class Forum extends AdminController $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); // 获取分类ename,appname - $cateName = Db::name('cate')->field('ename,appname')->find($data['cate_id']); + $cateName = $this->model->field('ename,appname')->find($data['cate_id']); - $article = new Article(); - $result = $article->add($data); + $result = $this->model->add($data); if ($result['code'] == 1) { // 获取到的最新ID $aid = $result['data']['id']; @@ -162,9 +114,9 @@ class Forum extends AdminController // 清除文章tag缓存 Cache::tag('tagArtDetail')->clear(); - $link = $this->getRouteUrl((int)$aid, $cateName['ename'],$cateName['appname']); - // 推送给百度收录接口 - $this->baiduPushUrl($link); + $link = $this->getArticleUrl((int)$aid, 'index', $cateName['ename']); + + hook('SeoBaiduPush', ['link'=>$link]); // 推送给百度收录接口 $url = $result['data']['status'] ? $link : (string)url('index/'); $res = Msgres::success($result['msg'], $url); @@ -202,53 +154,47 @@ class Forum extends AdminController $validate = new \app\common\validate\Article(); $res = $validate->scene('Artadd')->check($data); - if(true !== $res){ - return Msgres::error($validate->getError()); - } else { - //获取内容图片音视频标识 - $iva= $this->hasIva($data['content']); - $data = array_merge($data,$iva); + if(!$res) return Msgres::error($validate->getError()); + //获取内容图片音视频标识 + $iva= $this->hasIva($data['content']); + $data = array_merge($data,$iva); - // 处理内容 - $data['content'] = $this->downUrlPicsReaplace($data['content']); - // 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 - $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); + // 处理内容 + $data['content'] = $this->downUrlPicsReaplace($data['content']); + // 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 + $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); - $result = $article->edit($data); - if($result == 1) { - //处理标签 - $artTags = Db::name('taglist')->where('article_id',$id)->column('tag_id','id'); - if(isset($tagId)) { - $tagIdArr = explode(',',$tagId); - foreach($artTags as $aid => $tid) { - if(!in_array($tid,$tagIdArr)){ - //删除被取消的tag - Db::name('taglist')->delete($aid); - } + $result = $article->edit($data); + if($result == 1) { + //处理标签 + $artTags = Db::name('taglist')->where('article_id',$id)->column('tag_id','id'); + if(isset($tagId)) { + $tagIdArr = explode(',',$tagId); + foreach($artTags as $aid => $tid) { + if(!in_array($tid,$tagIdArr)){ + //删除被取消的tag + Db::name('taglist')->delete($aid); } - //查询保留的标签 - $artTags = Db::name('taglist')->where('article_id',$id)->column('tag_id'); - $tagArr = []; - foreach($tagIdArr as $tid) { - if(!in_array($tid, $artTags)){ - //新标签 - $tagArr[] = ['article_id'=>$data['id'],'tag_id'=>$tid,'create_time'=>time()]; - } - } - //更新新标签 - Db::name('taglist')->insertAll($tagArr); } - //删除原有缓存显示编辑后内容 - Cache::delete('article_'.$id); - $link = $this->getRouteUrl((int) $id, $article->cate->ename, $article->cate->appname); - // 推送给百度收录接口 - $this->baiduPushUrl($link); - $editRes = Msgres::success('edit_success',$link); - } else { - $editRes = Msgres::error($result); + //查询保留的标签 + $artTags = Db::name('taglist')->where('article_id',$id)->column('tag_id'); + $tagArr = []; + foreach($tagIdArr as $tid) { + if(!in_array($tid, $artTags)){ + //新标签 + $tagArr[] = ['article_id'=>$data['id'],'tag_id'=>$tid,'create_time'=>time()]; + } + } + //更新新标签 + Db::name('taglist')->insertAll($tagArr); } - return $editRes; + //删除原有缓存显示编辑后内容 + Cache::delete('article_'.$id); + $link = $this->getRouteUrl((int) $id, $article->cate->ename, $article->cate->appname); + hook('SeoBaiduPush', ['link'=>$link]); // 推送给百度收录接口 + return Msgres::success('edit_success',$link); } + return Msgres::error($result); } View::assign(['article'=>$article]); diff --git a/app/admin/controller/user/User.php b/app/admin/controller/user/User.php index 1ca202c..3372eff 100644 --- a/app/admin/controller/user/User.php +++ b/app/admin/controller/user/User.php @@ -37,6 +37,7 @@ class User extends AdminController if(Request::isAjax()){ $datas = Request::only(['id','name','email','sex','status']); $map = array_filter($datas,[$this,'filtrArr']); + halt($map); $user = Db::name('user')->where(['delete_time'=>0])->where($map)->order('id desc')->paginate([ 'list_rows' => input('limit'), 'page' => input('page') @@ -98,7 +99,7 @@ class User extends AdminController public function edit() { if(Request::isAjax()){ - $data = Request::only(['name','email','user_img','password','phone','sex']); + $data = Request::only(['id','name','email','user_img','password','phone','sex']); $user = Db::name('user')->field('create_time')->find($data['id']); $salt = substr(md5($user['create_time']),-6); // 密码 diff --git a/app/admin/view/content/cate/add.html b/app/admin/view/content/cate/add.html index f27c1b3..4acd85e 100644 --- a/app/admin/view/content/cate/add.html +++ b/app/admin/view/content/cate/add.html @@ -16,14 +16,6 @@ - -
- -
@@ -41,7 +33,7 @@
@@ -77,7 +69,9 @@ ,form = layui.form ; var iconPicker = layui.iconPicker; var xmSelect = layui.xmSelect; - var initPid = "{$cate.pid}"; + var initPid = 0; + + let ADD_EDIT = "{:url('content.cate/addEdit')}"; //初始化图标选择 iconPicker.render({ @@ -93,7 +87,7 @@ form.on('submit(cate-save)', function(data) { $.ajax({ - url: "{:url('content.cate/add')}", + url: ADD_EDIT, data: JSON.stringify(data.field), dataType: 'json', contentType: 'application/json', @@ -119,22 +113,6 @@ return false; }); - // 根据应用名动态选择应用下模板 - form.on('select(appname)', function(data){ - var appName = data.value; - $("#tpl").children('option').remove(); - $.post("{:url('content.cate/getAppNameView')}", {appname:appName},function (res){ - var str = ''; - for(var i=0; i < res.data.length; i++ ) { - str += ''; - // $("select[name='detpl']").append(''); - } - $("#tpl").append(str); - // 动态select重新渲染 - form.render('select'); - }) - - }); (function (){ //分类菜单结构 $.ajax({ diff --git a/app/admin/view/content/cate/edit.html b/app/admin/view/content/cate/edit.html index a161e4a..1081f79 100644 --- a/app/admin/view/content/cate/edit.html +++ b/app/admin/view/content/cate/edit.html @@ -16,27 +16,25 @@
- -
- -
+
+
+
+
+
+
+
+
+
+
@@ -81,6 +83,8 @@ var iconPicker = layui.iconPicker; var xmSelect = layui.xmSelect; var initPid = "{$cate.pid}"; + + let ADD_EDIT = "{:url('content.cate/addEdit')}"; //初始化图标选择 iconPicker.render({ @@ -96,7 +100,7 @@ form.on('submit(cate-save)', function(data) { $.ajax({ - url: "{:url('content.cate/edit')}", + url: ADD_EDIT, data: JSON.stringify(data.field), dataType: 'json', contentType: 'application/json', @@ -122,23 +126,6 @@ return false; }); - // 根据应用名动态选择应用下模板 - form.on('select(appname)', function(data){ - var appName = data.value; - $("#tpl").children('option').remove(); - $.post("{:url('content.cate/getAppNameView')}", {appname:appName},function (res){ - var str = ''; - for(var i=0; i < res.data.length; i++ ) { - str += ''; - // $("select[name='detpl']").append(''); - } - $("#tpl").append(str); - // 动态select重新渲染 - form.render('select'); - }) - - }); - (function (){ //分类菜单结构 $.ajax({ diff --git a/app/admin/view/content/cate/index.html b/app/admin/view/content/cate/index.html index 190eb10..eb11cfe 100644 --- a/app/admin/view/content/cate/index.html +++ b/app/admin/view/content/cate/index.html @@ -36,8 +36,11 @@ - + - - - + + + {block name="link"}{/block}