123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- namespace app\admin\controller;
- use library\Controller;
- use library\tools\Data;
- use think\Db;
- class Banner extends Controller
- {
-
- public $table = 'banner';
-
- public function index()
- {
- $this->title = '轮播图';
- $query = $this->_query($this->table)->like('title,phone,mail')->equal('status');
- $query->order('id desc')->page();
- }
-
- protected function _index_page_filter(&$data)
- {
- }
-
- public function add()
- {
- $this->applyCsrfToken();
- $this->_form($this->table, 'form');
- }
-
- public function edit()
- {
- $this->applyCsrfToken();
- $this->_form($this->table, 'form');
- }
-
- public function pass()
- {
- $this->applyCsrfToken();
- if ($this->request->isGet()) {
- $this->verify = false;
- $this->_form($this->table, 'pass');
- } else {
- $post = $this->request->post();
- if ($post['password'] !== $post['repassword']) {
- $this->error('两次输入的密码不一致!');
- }
- if (Data::save($this->table, ['id' => $post['id'], 'password' => md5($post['password'])], 'id')) {
- $this->success('密码修改成功,下次请使用新密码登录!', '');
- } else {
- $this->error('密码修改失败,请稍候再试!');
- }
- }
- }
-
- public function _form_filter(&$data)
- {
- if ($this->request->isPost()) {
-
- } else {
- $data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');
- $this->authorizes = Db::name('SystemAuth')->where(['status' => '1'])->order('sort desc,id desc')->select();
- }
- }
-
- public function forbid()
- {
- if (in_array('10000', explode(',', $this->request->post('id')))) {
- $this->error('系统超级账号禁止操作!');
- }
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => '0']);
- }
-
- public function resume()
- {
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => '1']);
- }
-
- public function remove()
- {
- if (in_array('10000', explode(',', $this->request->post('id')))) {
- $this->error('系统超级账号禁止删除!');
- }
- $this->applyCsrfToken();
- $this->_delete($this->table);
- }
- }
|