后台内容模块功能完善

This commit is contained in:
2020-03-31 16:17:45 +08:00
parent de73484cca
commit 85d33da0d4
24 changed files with 386 additions and 251 deletions

View File

@@ -157,4 +157,28 @@ function format_bytes($size, $delimiter = '') {
}
return round($size, 2) . $delimiter . $units[$i];
}
/**
* 获取文档封面图片
* @param int $cover_id
* @param string $field
* @return 完整的数据 或者 指定的$field字段值
* @author huajie <banhuajie@163.com>
*/
function get_cover($cover_id, $field = null) {
if (empty($cover_id)) {
return BASE_PATH . '/static/images/default.png';
}
$base_path = "";
$picture = \think\facade\Db::name('Picture')->where(array('status' => 1, 'id' => $cover_id))->find();
if ($field == 'path') {
if (!empty($picture['url'])) {
$picture['path'] = $picture['url'] ? $base_path . $picture['url'] : $base_path . '/static/images/default.png';
} else {
$picture['path'] = $picture['path'] ? $base_path . $picture['path'] : $base_path . '/static/images/default.png';
}
}
return empty($field) ? $picture : $picture[$field];
}

View File

@@ -9,6 +9,7 @@
namespace app\controller\admin;
use app\model\AdPlace;
use app\model\Ad as AdModel;
/**
* @title 广告管理
@@ -36,26 +37,19 @@ class Ad extends Base {
* @title 广告位添加
*/
public function add() {
$place = model('AdPlace');
if ($this->request->isPost()) {
$result = $place->change();
if (!empty($_POST['name'])) {
$result = $place->change();
if ($result) {
return $this->success("添加成功!");
} else {
return $this->error($place->getError());
}
$data = $this->request->post();
$result = AdPlace::create($data);
if (false !== $result) {
return $this->success("添加成功!");
} else {
return $this->error("标识不能为空!");
return $this->error('添加失败!');
}
} else {
$data = array(
'keyList' => $place->keyList,
$this->data = array(
'keyList' => AdPlace::$keyList,
);
$this->assign($data);
$this->setMeta("添加广告位");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -63,26 +57,24 @@ class Ad extends Base {
* @title 广告位编辑
*/
public function edit($id = null) {
$place = model('AdPlace');
if ($this->request->isPost()) {
$result = $place->change();
$data = $this->request->post();
$result = AdPlace::update($data, ['id' => $data['id']]);
if ($result) {
return $this->success("修改成功!", url('admin/ad/index'));
return $this->success("修改成功!", url('/admin/ad/index'));
} else {
return $this->error($this->adplace->getError());
return $this->error('修改失败!');
}
} else {
$info = db('AdPlace')->where(array('id' => $id))->find();
$info = AdPlace::find($id);
if (!$info) {
return $this->error("非法操作!");
}
$data = array(
$this->data = array(
'info' => $info,
'keyList' => $place->keyList,
'keyList' => AdPlace::$keyList,
);
$this->assign($data);
$this->setMeta("编辑广告位");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -108,19 +100,15 @@ class Ad extends Base {
* @title 广告列表
*/
public function lists($id = null) {
$map['place_id'] = $id;
$map[] = ['place_id', '=', $id];
$order = "id desc";
$list = db('Ad')->where($map)->order($order)->paginate(10, false, array(
'query' => $this->request->param(),
));
$data = array(
$list = AdModel::where($map)->order($order)->paginate($this->request->pageConfig);
$this->data = array(
'id' => $id,
'list' => $list,
'page' => $list->render(),
);
$this->assign($data);
$this->setMeta("广告管理");
return $this->fetch();
}
@@ -128,23 +116,22 @@ class Ad extends Base {
* @title 添加广告
*/
public function addad($id) {
$ad = model('ad');
if ($this->request->isPost()) {
$result = $ad->change();
$data = $this->request->post();
$result = AdModel::create($data);
if ($result) {
return $this->success("添加成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
return $this->success("添加成功!", url('/admin/ad/lists', ['id' => $data['place_id']]));
} else {
return $this->error($ad->getError());
return $this->error('添加失败!');
}
} else {
$info['place_id'] = $id;
$data = array(
$this->data = array(
'info' => $info,
'keyList' => $ad->keyList,
'keyList' => AdModel::$keyList,
);
$this->assign($data);
$this->setMeta("添加广告位");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -152,26 +139,25 @@ class Ad extends Base {
* @title 编辑广告
*/
public function editad($id = null) {
$ad = model('ad');
if ($this->request->isPost()) {
$result = $ad->change();
$data = $this->request->post();
$result = AdModel::update($data, ['id' => $data['id']]);
if ($result) {
return $this->success("修改成功!", url('admin/ad/lists', array('id' => $this->request->param('place_id'))));
return $this->success("修改成功!", url('/admin/ad/lists', ['id' => $data['place_id']]));
} else {
return $this->error($ad->getError());
return $this->error('修改失败!');
}
} else {
$info = db('ad')->where(array('id' => $id))->find();
$info = AdModel::find($id);
if (!$info) {
return $this->error("非法操作!");
}
$data = array(
$this->data = array(
'info' => $info,
'keyList' => $ad->keyList,
'keyList' => AdModel::$keyList,
);
$this->assign($data);
$this->setMeta("编辑广告位");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}

View File

@@ -40,13 +40,13 @@ class Client extends Base {
$result = ClientM::create($data);
if (false !== $result) {
return $this->success('成功添加', url('client/index'));
return $this->success('成功添加', url('/admin/client/index'));
} else {
return $this->error('添加失败!');
}
} else {
$info['appid'] = rand_string(10, 1); //八位数字appid
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
$info['appid'] = time(); //八位数字appid
$info['appsecret'] = \xin\helper\Str::random(32); //32位数字加字母秘钥
$this->data = array(
'info' => $info,
@@ -64,12 +64,12 @@ class Client extends Base {
$result = ClientM::update($data, ['id' => $this->request->param('id')]);
if (false !== $result) {
return $this->success('修改添加', url('client/index'));
return $this->success('修改添加', url('/admin/client/index'));
} else {
return $this->error($this->model->getError());
}
} else {
$info = $ClientM::where('id', $request->param('id'))->find();
$info = ClientM::where('id', $this->request->param('id'))->find();
$this->data = array(
'info' => $info,
@@ -81,7 +81,24 @@ class Client extends Base {
/**
* @title 删除客户端
*/
public function del(\think\Request $request) {
public function del() {
$id = $this->request->param('id', '');
$map = [];
if (!$id) {
return $this->error('请选择要操作的数据!');
}
if (is_array($id)) {
$map[] = ['id', 'IN', $id];
}else{
$map[] = ['id', '=', $id];
}
$result = ClientM::where($map)->delete();
if (false !== $result) {
return $this->success('删除成功');
} else {
return $this->error('删除失败!');
}
}
}

View File

@@ -19,11 +19,13 @@ use app\model\Attribute;
class Content extends Base {
public $modelInfo = [];
public $model = null;
public function initialize() {
parent::initialize();
$this->getContentMenu();
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list'])->toArray();
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray();
$this->model = Db::name($this->modelInfo['name']);
}
/**
@@ -33,12 +35,12 @@ class Content extends Base {
*/
public function index() {
if ($this->modelInfo['list_grid'] == '') {
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
return $this->error("列表定义不正确!", url('/admin/model/edit', array('id' => $this->modelInfo['id'])));
}
$order = "id desc";
$map = [];
$list = Db::name($this->modelInfo['name'])->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
'query' => $this->request->param(),
));
@@ -63,11 +65,11 @@ class Content extends Base {
*/
public function add() {
if ($this->request->isPost()) {
$result = $this->model->save($this->request->param());
$result = $this->model->save($this->request->post());
if ($result) {
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
return $this->success("添加成功!", url('/admin/'.$this->modelInfo['name'].'/index'));
} else {
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
return $this->error('添加失败!');
}
} else {
$info = [
@@ -76,13 +78,13 @@ class Content extends Base {
];
$this->data = [
'info' => $info,
'fieldGroup' => $this->getField($this->modelInfo),
'fieldGroup' => Attribute::getField($this->modelInfo),
];
if ($this->modelInfo['template_add']) {
$template = 'content/' . $this->modelInfo['template_add'];
$template = 'admin/content/' . $this->modelInfo['template_add'];
} else {
$template = 'public/edit';
$template = 'admin/public/edit';
}
return $this->fetch($template);
}
@@ -94,13 +96,11 @@ class Content extends Base {
*/
public function edit($id) {
if ($this->request->isPost()) {
$result = $this->model->save($this->request->param(), array('id' => $id));
$result = $this->model->save($this->request->post());
if ($result !== false) {
//记录行为
action_log('update_content', 'content', $result, session('auth_user.uid'));
return $this->success("更新成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
return $this->success("更新成功!", url('/admin/'.$this->modelInfo['name'].'/index'));
} else {
return $this->error($this->model->getError(), url('admin/content/edit', array('model_id' => $this->modelInfo['id'], 'id' => $id)));
return $this->error('修改失败!');
}
} else {
if (!$id) {
@@ -108,20 +108,18 @@ class Content extends Base {
}
$info = $this->model->find($id);
if (!$info) {
return $this->error($this->model->getError());
return $this->error('无此数据!');
}
$info['model_id'] = $this->modelInfo['id'];
$data = array(
$this->data = array(
'info' => $info,
'fieldGroup' => $this->getField($this->modelInfo),
'fieldGroup' => Attribute::getField($this->modelInfo, 'edit'),
);
if ($this->modelInfo['template_edit']) {
$template = 'content/' . $this->modelInfo['template_edit'];
$template = 'admin/content/' . $this->modelInfo['template_edit'];
} else {
$template = 'public/edit';
$template = 'admin/public/edit';
}
$this->assign($data);
$this->setMeta("编辑" . $this->modelInfo['title']);
return $this->fetch($template);
}
}
@@ -131,18 +129,21 @@ class Content extends Base {
* @author molong <ycgpp@126.com>
*/
public function del() {
$param = $this->request->param();
$id = $param['id'];
if (empty($id)) {
return $this->error("非法操作!");
$id = $this->request->param('id', '');
$map = [];
if (!$id) {
return $this->error('请选择要操作的数据!');
}
if (is_array($id)) {
$map[] = ['id', 'IN', $id];
}else{
$map[] = ['id', '=', $id];
}
$map['id'] = array('IN', $id);
$result = $this->model->where($map)->delete();
if (false !== $result) {
//记录行为
action_log('delete_content', 'content', $result, session('auth_user.uid'));
return $this->success("删除成功!");
} else {
return $this->error("删除失败!");
@@ -153,9 +154,14 @@ class Content extends Base {
* @title 设置状态
* @author molong <ycgpp@126.com>
*/
public function status($id, $status) {
$map['id'] = $id;
$result = $this->model->where($map)->setField('status', $status);
public function status() {
$id = $this->request->param('id', '');
$status = $this->request->param('status', 1);
if (!$id) {
return $this->error('请选择要操作的数据!');
}
$result = $this->model->where('id', $id)->update(['status' => $status]);
if (false !== $result) {
return $this->success("操作成功!");
} else {
@@ -167,9 +173,14 @@ class Content extends Base {
* @title 设置置顶
* @author molong <ycgpp@126.com>
*/
public function settop($id, $is_top) {
$map['id'] = $id;
$result = $this->model->where($map)->setField('is_top', $is_top);
public function settop() {
$id = $this->request->param('id', '');
$is_top = $this->request->param('is_top', 1);
if (!$id) {
return $this->error('请选择要操作的数据!');
}
$result = $this->model->where('id', $id)->update(['is_top' => $is_top]);
if (false !== $result) {
return $this->success("操作成功!");
} else {
@@ -177,66 +188,6 @@ class Content extends Base {
}
}
/**
* @title 获取字段信息
* @return array 字段数组
* @author molong <ycgpp@126.com>
*/
protected function getField() {
$field_group = parse_config_attr($this->modelInfo['attribute_group']);
$map['model_id'] = $this->modelInfo['id'];
if ($this->request->action() == 'add') {
$map['is_show'] = array('in', array('1', '2'));
} elseif ($this->request->action() == 'edit') {
$map['is_show'] = array('in', array('1', '3'));
}
//获得数组的第一条数组
$rows = Attribute::getFieldlist($map, 'id');
if (!empty($rows)) {
foreach ($rows as $key => $value) {
$list[$value['group_id']][] = $value;
}
foreach ($field_group as $key => $value) {
$fields[$value] = isset($list[$key]) ? $list[$key] : array();
}
} else {
$fields = array();
}
return $fields;
}
/**
* @title 创建搜索
* @return [array] [查询条件]
*/
protected function buildMap() {
$map = array();
$data = $this->request->param();
foreach ($data as $key => $value) {
if ($value) {
if ($key == 'keyword') {
$map['title'] = array("LIKE", "%$value%");
} elseif ($key == 'category') {
$map['category_id'] = $value;
} elseif ($key == 'create_time') {
$map['create_time'] = array('BETWEEN', array(strtotime($value[0]), strtotime($value[1])));
} else {
$map[$key] = $value;
}
}
}
if (isset($map['page'])) {
unset($map['page']);
}
if (isset($map['model_id'])) {
unset($map['model_id']);
}
$this->assign($data);
return $map;
}
/**
* 检测需要动态判断的文档类目有关的权限
*

View File

@@ -36,27 +36,23 @@ class Link extends Base {
* @title 添加链接
*/
public function add() {
$link = model('Link');
if ($this->request->isPost()) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
unset($data['id']);
$result = $link->save($data);
$result = LinkM::create($data);
if ($result) {
return $this->success("添加成功!", url('Link/index'));
return $this->success("添加成功!", url('/admin/link/index'));
} else {
return $this->error($link->getError());
return $this->error('添加失败!');
}
} else {
return $this->error($link->getError());
return $this->error('未提交数据');
}
} else {
$data = array(
'keyList' => $link->keyList,
$this->data = array(
'keyList' => LinkM::$keyList,
);
$this->assign($data);
$this->setMeta("添加友链");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -64,31 +60,27 @@ class Link extends Base {
* @title 修改链接
*/
public function edit() {
$link = model('Link');
$id = input('id', '', 'trim,intval');
$id = $this->request->param('id');
if ($this->request->isPost()) {
$data = input('post.');
$data = $this->request->post();
if ($data) {
$result = $link->save($data, array('id' => $data['id']));
if ($result) {
return $this->success("修改成功!", url('Link/index'));
$result = LinkM::update($data, array('id' => $data['id']));
if (false !== $result) {
return $this->success("修改成功!", url('/admin/link/index'));
} else {
return $this->error("修改失败!");
}
} else {
return $this->error($link->getError());
return $this->error('未提交数据');
}
} else {
$map = array('id' => $id);
$info = db('Link')->where($map)->find();
$info = LinkM::find($id);
$data = array(
'keyList' => $link->keyList,
$this->data = array(
'keyList' => LinkM::$keyList,
'info' => $info,
);
$this->assign($data);
$this->setMeta("编辑友链");
return $this->fetch('public/edit');
return $this->fetch('admin/public/edit');
}
}
@@ -96,18 +88,23 @@ class Link extends Base {
* @title 删除链接
*/
public function delete() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error('非法操作!');
}
$link = db('Link');
$id = $this->request->param('id', '');
$map = array('id' => array('IN', $id));
$result = $link->where($map)->delete();
if ($result) {
return $this->success("删除成功!");
$map = [];
if (!$id) {
return $this->error('请选择要操作的数据!');
}
if (is_array($id)) {
$map[] = ['id', 'IN', $id];
}else{
$map[] = ['id', '=', $id];
}
$result = LinkM::where($map)->delete();
if (false !== $result) {
return $this->success('删除成功');
} else {
return $this->error("删除失败!");
return $this->error('删除失败!');
}
}
}

View File

@@ -0,0 +1,5 @@
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;">
{volist name="option" id="item"}
<option value="{$item['key']}" {if $item['key'] == $value}selected{/if}>{$item['label']}</option>
{/volist}
</select>

View File

View File

View File

@@ -18,7 +18,7 @@
<div class="clearfix"></div>
</div>
<div class="filebox image">
<img src="{:config('base_url')}{$images['path']}" class="img-responsive">
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
</div>
</li>
{/if}

View File

@@ -18,7 +18,7 @@
<div class="clearfix"></div>
</div>
<div class="filebox image">
<img src="{:config('base_url')}{$images['path']}" class="img-responsive">
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
</div>
</li>
{/if}

View File

@@ -0,0 +1 @@
<input type="text" class="form-control" name="{$name}" id="{$name}" autocomplete="false" value="{$value}" style="width: 120px">

32
app/http/validate/Ad.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\validate;
use think\Validate;
/**
* 菜单验证
*/
class Ad extends Validate{
protected $rule = [
'title' => 'require',
'name' => 'require|unique:AdPlace',
];
protected $message = [
'title.require' => '广告位标题必须',
'name.require' => '广告位标识必须',
'name.unique' => '广告位标识已存在',
];
protected $scene = [
'adminadd' => ['title', 'name'],
'adminedit' => ['title', 'name'],
];
}

View File

@@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\validate;
use think\Validate;
use think\facade\Request;
use app\model\Attribute;
/**
* 菜单验证
*/
class Content extends Validate{
public function __construct(){
parent::__construct();
$param = Request::param();
$map = [];
$attr = Attribute::where($map)->select();
$rule = [];
$message = [];
$field = [];
foreach ($attr as $value) {
if ($value['is_must']) {
$rule[$value['name']] = 'require';
$message[$value['name'].'.require'] = $value['title'] . '不能为空!';
$field[] = $value['name'];
}
}
$this->rule = $rule;
$this->message = $message;
$this->scene = [
'adminadd' => $field,
'adminedit' => $field,
'useradd' => $field,
'useredit' => $field,
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\http\validate;
use think\Validate;
/**
* 菜单验证
*/
class Link extends Validate{
protected $rule = [
'title' => 'require',
'url' => 'require|url'
];
protected $message = [
'title.require' => '连接标题必须',
'url.require' => '连接地址必须',
'url.url' => '连接格式错误',
];
protected $scene = [
'adminadd' => ['title', 'url'],
'adminedit' => ['title', 'url'],
];
}

View File

@@ -12,25 +12,25 @@ namespace app\model;
/**
* 分类模型
*/
class Ad {
class Ad extends \think\Model{
protected $auto = array('update_time');
protected $insert = array('create_time');
protected $type = array(
protected $type = [
'id' => 'integer',
'cover_id' => 'integer',
);
];
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'place_id', 'title' => 'PLACE_ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'cover_id', 'title' => '广告图片', 'type' => 'image', 'help' => '', 'option' => ''),
array('name' => 'url', 'title' => '广告链接', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'photolist', 'title' => '辅助图片', 'type' => 'images', 'help' => '', 'option' => ''),
array('name' => 'listurl', 'title' => '辅助链接', 'type' => 'textarea', 'help' => '对应辅助图片的排序,一行一个', 'option' => ''),
array('name' => 'background', 'title' => '广告背景颜色', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'content', 'title' => '广告描述', 'type' => 'textarea', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '用')),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'place_id', 'title' => 'PLACE_ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'title', 'title' => '广告名称', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'cover_id', 'title' => '广告图片', 'type' => 'image', 'help' => '', 'option' => ''],
['name' => 'url', 'title' => '广告链接', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'photolist', 'title' => '辅助图片', 'type' => 'images', 'help' => '', 'option' => ''],
['name' => 'listurl', 'title' => '辅助链接', 'type' => 'textarea', 'help' => '对应辅助图片的排序,一行一个', 'option' => ''],
['name' => 'background', 'title' => '广告背景颜色', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'content', 'title' => '广告描述', 'type' => 'textarea', 'help' => '', 'option' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'用']]]
];
}

View File

@@ -30,17 +30,17 @@ class AdPlace extends \think\Model{
'6' => '代码广告',
);
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告位名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'name', 'title' => '广告位标识', 'type' => 'text', 'help' => '调用使用{:ad("广告位标识",参数)}', 'option' => ''),
array('name' => 'show_type', 'title' => '类型', 'type' => 'select', 'help' => '', 'option' => ''),
array('name' => 'show_num', 'title' => '显示条数', 'type' => 'num', 'help' => '', 'option' => ''),
array('name' => 'start_time', 'title' => '开始时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'end_time', 'title' => '结束时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'template', 'title' => '广告模版', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '禁用')),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'title', 'title' => '广告位名称', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'name', 'title' => '广告位标识', 'type' => 'text', 'help' => '调用使用{:ad("广告位标识",参数)}', 'option' => ''],
['name' => 'show_type', 'title' => '类型', 'type' => 'select', 'help' => '', 'option' => ''],
['name' => 'show_num', 'title' => '显示条数', 'type' => 'num', 'help' => '', 'option' => ''],
['name' => 'start_time', 'title' => '开始时间', 'type' => 'datetime', 'help' => '', 'option' => ''],
['name' => 'end_time', 'title' => '结束时间', 'type' => 'datetime', 'help' => '', 'option' => ''],
['name' => 'template', 'title' => '广告模版', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']]],
];
public function initialize() {
parent::initialize();

View File

@@ -80,4 +80,31 @@ class Attribute extends \think\Model {
}
}
public static function getField($model, $ac = "add"){
$list = [];
$group = $model['attr_group'];
$map = [];
$map[] = ['model_id', '=', $model['id']];
if ($ac == 'add') {
$map[] = ['is_show', 'IN', [1, 2]];
}else if ($ac == 'edit') {
$map[] = ['is_show', 'IN', [1, 3]];
}
$row = self::where('model_id', $model['id'])
->select()
->append(['option'])
->toArray();
foreach ($row as $key => $value) {
if (isset($group[$value['group_id']])) {
$list[$group[$value['group_id']]['label']][] = $value;
}else{
$list[$value['group_id']][] = $value;
}
}
return $list;
}
}

View File

@@ -17,24 +17,24 @@ class Link extends \think\Model {
protected $auto = ['update_time'];
protected $insert = ['create_time'];
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
array('name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''),
array('name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => ''),
array('name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => array(
'1' => '常用链接',
'2' => '网站导读',
'3' => '对公服务',
'4' => '校内服务',
), 'help' => ''),
array('name' => 'cover_id', 'title' => '网站LOGO', 'type' => 'image', 'help' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => array('1' => '启用', '0' => '用'), 'help' => ''),
array('name' => 'sort', 'title' => '链接排序', 'type' => 'text', 'help' => ''),
array('name' => 'descrip', 'title' => '描述', 'type' => 'textarea', 'help' => ''),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden'],
['name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''],
['name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => ''],
['name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => [
['key'=>'1', 'label' => '常用链接'],
['key'=>'2', 'label' => '网站导读'],
['key'=>'3', 'label' => '对公服务'],
['key'=>'4', 'label' => '校内服务'],
], 'help' => ''],
['name' => 'cover_id', 'title' => '网站LOGO', 'type' => 'image', 'help' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'用']], 'help' => ''],
['name' => 'sort', 'title' => '链接排序', 'type' => 'text', 'help' => ''],
['name' => 'descrip', 'title' => '描述', 'type' => 'textarea', 'help' => ''],
];
protected $type = array(
protected $type = [
'cover_id' => 'integer',
'sort' => 'integer'
);
];
}

View File

@@ -97,6 +97,18 @@ class Model extends \think\Model{
return $list;
}
public function getAttrGroupAttr($value, $data){
$list = [];
if ($data['attribute_group']) {
$row = explode(PHP_EOL, $data['attribute_group']);
foreach ($row as $r) {
list($key, $label) = explode(":", $r);
$list[$key] = ['key' => $key, 'label' => $label];
}
}
return $list;
}
public function getStatusTextAttr($value, $data) {
$status = [0 => '禁用', 1 => '启用'];
return $status[$data['status']];

View File

@@ -14,9 +14,9 @@ use app\model\Model;
$model = Model::where('status', '>', 0)->field(['id', 'name'])->select()->toArray();
foreach ($model as $value) {
Route::rule('/admin/' . $value['name'] . '/:function', 'admin.content/:function')->append(['name'=>$value['name']]);
Route::rule('/front/' . $value['name'] . '/:function', 'front.content/:function')->append(['name'=>$value['name']]);
Route::rule('/user/' . $value['name'] . '/:function', 'user.content/:function')->append(['name'=>$value['name']]);
Route::rule('/admin/' . $value['name'] . '/:function', 'admin.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule('/front/' . $value['name'] . '/:function', 'front.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule('/user/' . $value['name'] . '/:function', 'user.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
}
Route::rule('/', 'Front.Index/index');

View File

@@ -9,8 +9,8 @@
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
<a class="btn btn-primary" href="{:url('/admin/ad/add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/ad/del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
@@ -37,9 +37,9 @@
<td>{$item['create_time']}</td>
<td>{$item['update_time']}</td>
<td>
<a title="广告列表" href="{:url('lists?id='.$item['id'])}">广告列表</a>
<a title="移动" href="{:url('edit?id='.$item['id'])}">编辑</a>
<a title="删除" href="{:url('del?id='.$item['id'])}" class="confirm ajax-get">删除</a>
<a title="广告列表" href="{:url('/admin/ad/lists', ['id'=>$item['id']])}">广告列表</a>
<a title="移动" href="{:url('/admin/ad/edit', ['id'=>$item['id']])}">编辑</a>
<a title="删除" href="{:url('/admin/ad/del', ['id'=>$item['id']])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}

View File

@@ -9,8 +9,8 @@
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-success" href="{:url('addad?id='.$id)}"><i class="fa fa-plus-circle fa-lg"></i> 新 增</a>
<a class="btn btn-primary" href="{:url('index')}"><i class="fa fa-list fa-lg"></i> 广告位</a>
<a class="btn btn-success" href="{:url('/admin/ad/addad', ['id'=>$id])}"><i class="fa fa-plus-circle fa-lg"></i> 新 增</a>
<a class="btn btn-primary" href="{:url('/admin/ad/index')}"><i class="fa fa-list fa-lg"></i> 广告位</a>
</div>
</header>
<div class="main-box-body clearfix">
@@ -33,11 +33,11 @@
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item.id}"></td>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['create_time']|date='Y-m-d H:i',###}</td>
<td>{$item['update_time']|date='Y-m-d H:i',###}</td>
<td>{$item['create_time']}</td>
<td>{$item['update_time']}</td>
<td>
<a href="{:url('editad?id='.$item['id'])}">编辑</a>
<a href="{:url('delad?id='.$item['id'])}" class="confirm ajax-get">删除</a>
<a href="{:url('/admin/ad/editad', ['id'=>$item['id']])}">编辑</a>
<a href="{:url('/admin/ad/delad', ['id'=>$item['id']])}" class="confirm ajax-get">删除</a>
</td>
</tr>
{/volist}

View File

@@ -6,8 +6,8 @@
<h2>{$meta_title}</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{:url('add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
<a class="btn btn-primary" href="{:url('/admin/client/add')}">新 增</a>
<button class="btn btn-danger ajax-post confirm" url="{:url('/admin/client/del')}" target-form="ids">删 除</button>
</div>
</header>
<div class="main-box-body clearfix">
@@ -15,6 +15,7 @@
<table class="table table-hover">
<thead>
<tr>
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
<th>ID</th>
<th>名称</th>
<th>APPID</th>
@@ -27,6 +28,7 @@
<tbody>
{volist name="list" id="item"}
<tr>
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['appid']}</td>
@@ -34,8 +36,8 @@
<td>{$item['create_time']}</td>
<td>{$item['update_time']}</td>
<td>
<a href="{:url('client/edit?id='.$item['id'])}">编辑</a>
<a href="{:url('client/del?id='.$item['id'])}" class="ajax-post confirm">删除</a>
<a href="{:url('/admin/client/edit', ['id'=>$item['id']])}">编辑</a>
<a href="{:url('/admin/client/del', ['id'=>$item['id']])}" class="ajax-post confirm">删除</a>
</td>
</tr>
{/volist}

View File

@@ -22,7 +22,8 @@
<th width="60">ID</th>
<th>名称</th>
<th>排序</th>
<th>时间</th>
<th>添加时间</th>
<th>更新时间</th>
<th>操作</th>
</tr>
</thead>
@@ -33,6 +34,7 @@
<td>{$item['id']}</td>
<td>{$item['title']}</td>
<td>{$item['sort']}</td>
<td>{$item['create_time']}</td>
<td>{$item['update_time']}</td>
<td>
<a href="{:url('/admin/link/edit?id='.$item['id'])}">编辑</a>