123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\data\controller\base;
- use think\admin\Controller;
- use think\admin\model\SystemBase;
- /**
- * 图片内容管理
- * Class Slider
- * @package app\data\controller\base
- */
- class Slider extends Controller
- {
- /**
- * 跳转规则定义
- * @var string[]
- */
- protected $rules = [
- '#' => ['name' => '不跳转'],
- 'LK' => ['name' => '自定义链接'],
- //'NL' => ['name' => '新闻资讯列表'],
- //'NS' => ['name' => '新闻资讯详情', 'node' => 'data/news.item/select'],
- //'XW' => ['name' => '新闻资讯详情', 'node' => 'admin/xw/index'],
- ];
- /**
- * 数据类型
- * @var string
- */
- protected $type = '图片内容';
- /**
- * 页面类型
- * @var array
- */
- protected $types = [];
- /**
- * 控制器初始化
- * @return void
- */
- protected function initialize()
- {
- $this->types = SystemBase::mk()->items($this->type);
- foreach ($this->types as &$type) {
- if (preg_match('/^(.*?)#(\d+)$/', $type['name'], $matches)) {
- $type['name'] = $matches[1];
- $type['number'] = $matches[2];
- } else {
- $type['number'] = 0;
- }
- }
- }
- /**
- * 图片内容管理
- * @auth true
- * @menu true
- */
- public function index()
- {
- $this->title = '图片内容管理';
- $this->fetch();
- }
- /**
- * 编辑图片内容
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function edit()
- {
- $this->skey = input('get.type', '');
- $this->base = $this->types[$this->skey] ?? [];
- if (empty($this->base)) $this->error('未配置基础数据!');
- $this->number = $this->base['number'];
- $this->sysdata();
- }
- /**
- * 保存图片内容
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- private function sysdata()
- {
- if ($this->request->isGet()) {
- $this->data = sysdata($this->skey);
- $this->title = "{$this->base['name']}管理";
- $this->fetch('form');
- } else {
- if (sysdata($this->skey, json_decode(input('data'), true))) {
- $this->success("{$this->base['name']}保存成功!");
- } else {
- $this->error("{$this->base['name']}保存失败,请稍候再试!");
- }
- }
- }
- }
|