123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-02-17
- // +—————————————————————————————————————————————————————————————————————
- /**
- * 引导页
- */
- namespace app\admin\controller;
- use cmf\controller\AdminBaseController;
- use think\Db;
- class GuideController extends AdminbaseController {
- public function set(){
- $config=DB::name("option")->where("option_name='guide'")->value("option_value");
- $this->assign('config',json_decode($config,true) );
-
- return $this->fetch();
- }
-
- public function setPost(){
- if ($this->request->isPost()) {
-
- $config = $this->request->param('post/a');
- $time=$config['time'];
- if(!$time||$time<1){
- $this->error("图片展示时间错误");
- }
- if(floor($time)!=$time){
- $this->error("图片展示时间错误");
- }
-
- //查询已存在的内容
- $info=DB::name("option")->where("option_name='guide'")->value("option_value");
-
- $rs = DB::name('option')->where("option_name='guide'")->update(['option_value'=>json_encode($config)] );
- if($rs===false){
- $this->error("保存失败!");
- }
-
-
- if($info){
- $option_value=json_decode($info,true);
-
-
- }
-
- $this->success("保存成功!");
-
- }
- }
-
- public function index(){
- $config=DB::name("option")->where("option_name='guide'")->value("option_value");
-
- $config = json_decode($config,true);
-
- $type=$config['type'];
-
- $map['type']=$type;
-
-
- $lists = Db::name("guide")
- ->where($map)
- ->order("list_order asc, id desc")
- ->paginate(20);
-
- $lists->each(function($v,$k){
- $v['thumb']=get_upload_path($v['thumb']);
- return $v;
- });
-
- $page = $lists->render();
- $this->assign('lists', $lists);
- $this->assign("page", $page);
-
- $this->assign('type', $type);
-
- return $this->fetch();
- }
-
- public function del(){
- $id = $this->request->param('id', 0, 'intval');
-
- $rs = DB::name('guide')->where("id={$id}")->delete();
- if(!$rs){
- $this->error("删除失败!");
- }
-
-
- $this->success("删除成功!");
-
- }
- //排序
- public function listOrder() {
-
- $model = DB::name('guide');
- parent::listOrders($model);
-
-
-
- $this->success("排序更新成功!");
-
- }
-
- public function add(){
- $config=DB::name("option")->where("option_name='guide'")->value("option_value");
-
- $config = json_decode($config,true);
-
- $type=$config['type'];
-
- if($type==1){
- $map['type']=$type;
-
- $count=DB::name("guide")->where($map)->count();
- if($count>=1){
- $this->error("引导页视频只能存在一个");
- }
- }
-
- $this->assign('type', $type);
-
- return $this->fetch();
- }
- public function addPost(){
- if ($this->request->isPost()) {
-
- $data = $this->request->param();
- $thumb=$data['thumb'];
- if(!$thumb){
- $this->error("请上传引导页图片/视频");
- }
-
- $data['href']=html_entity_decode($data['href']);
- $data['addtime']=time();
- $data['uptime']=time();
-
- $id = DB::name('guide')->insertGetId($data);
- if(!$id){
- $this->error("添加失败!");
- }
-
-
-
- $this->success("添加成功!");
-
- }
- }
-
- public function edit(){
-
- $id = $this->request->param('id', 0, 'intval');
-
- $data=Db::name('guide')
- ->where("id={$id}")
- ->find();
- if(!$data){
- $this->error("信息错误");
- }
-
- $this->assign('data', $data);
- return $this->fetch();
- }
-
- public function editPost(){
- if ($this->request->isPost()) {
-
- $data = $this->request->param();
-
- $thumb=$data['thumb'];
- if(!$thumb){
- $this->error("请上传引导页图片");
- }
-
- $data['href']=html_entity_decode($data['href']);
- $data['uptime']=time();
-
- $rs = DB::name('guide')->update($data);
- if($rs===false){
- $this->error("修改失败!");
- }
-
-
-
-
- $this->success("修改成功!");
- }
- }
- }
|