| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- <?php
- namespace app\admin\controller;
- use think\Controller;
- use think\Exception;
- use think\Session;
- use think\Request;
- use think\Log;
- use think\cache\driver\Redis;
- class Index extends Common
- {
- /**
- * 主页显示
- *
- * @access public
- * @return string
- */
- public function index()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- ]);
- return $this->fetch();
- }//end index()
- /**
- * 用户列表
- *
- * @access public
- * @return string
- */
- public function userList()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取用户列表.
- $userList = model('User')->userList();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'userList' => $userList['data']['userList'],
- 'page' => $userList['data']['page'],
- 'currentPage' => $userList['data']['currentPage'],
- ]);
- return $this->fetch('userlist');
- }//end userList()
- /**
- * 修改用户
- *
- * @access public
- * @return string
- */
- public function updateUser()
- {
- try {
- model('User')->updateUser();
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json(['code' => 1, 'data' => '', 'msg' => lang('MC01004')]);
- }//end updateUser()
- /**
- * 平台列表
- *
- * @access public
- * @return string
- */
- public function platformList()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取平台列表.
- $platformList = model('Platform')->platformList();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'platformList' => $platformList['data']['platformList'],
- 'page' => $platformList['data']['page'],
- 'currentPage' => $platformList['data']['currentPage'],
- ]);
- return $this->fetch('platformlist');
- }//end platformList()
- /**
- * 修改平台
- *
- * @access public
- * @return string
- */
- public function updatePlatform()
- {
- if(request()->isAjax()) {
- try {
- $back = model('Platform')->updatePlatform();
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json($back);
- }
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取平台数据.
- $platform = model('Platform')->platform();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'platform' => $platform['data']['platform'],
- ]);
- return $this->fetch('updateplatform');
- }//end updatePlatform()
- /**
- * 删除所选平台
- *
- * @access public
- * @return string
- */
- public function delPlatform()
- {
- $ids = $_GET['ids'];
- try {
- $back = model('Platform')->delPlatform($ids);
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json(['code' => 1, 'data' => $ids, 'msg' => lang('MC01003')]);
- }
- /**
- * 删除所选用户
- *
- * @access public
- * @return string
- */
- public function delUser()
- {
- $ids = $_GET['ids'];
- try {
- $back = model('User')->delUser($ids);
- } catch (\Exception $e) {
- Log::write($e->delUser(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json(['code' => 1, 'data' => $ids, 'msg' => lang('MC01003')]);
- }
- /**
- * 删除所选消息
- *
- * @access public
- * @return string
- */
- public function delMessage()
- {
- $ids = $_GET['ids'];
- try {
- $back = model('Message')->delMessage($ids);
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json(['code' => 1, 'data' => $ids, 'msg' => lang('MC01003')]);
- }
- /**
- * 新增平台
- *
- * @access public
- * @return string
- */
- public function addPlatform()
- {
- if(request()->isAjax()) {
- try {
- $back = model('Platform')->addPlatform();
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json($back);
- }
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- ]);
- return $this->fetch('addplatform');
- }//end addPlatform()
- /**
- * 平台用户列表
- *
- * @access public
- * @return string
- */
- public function platformUser()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取平台用户列表.
- $userList = model('UserPlatform')->userList();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'userList' => $userList['data']['userList'],
- 'page' => $userList['data']['page'],
- 'currentPage' => $userList['data']['currentPage'],
- ]);
- return $this->fetch('platformuser');
- }//end platformUser()
- /**
- * 删除平台用户
- *
- * @access public
- * @return string
- */
- public function delPlatUser()
- {
- try {
- model('UserPlatform')->deleteUser();
- } catch (\Exception $e) {
- Log::write($e->getMessage(), 'error');
- return json(['code' => -2, 'data' => '', 'msg' => lang('EC01002')]);
- }
- return json(['code' => 1, 'data' => '', 'msg' => lang('MC01004')]);
- }//end delPlatUser()
- /**
- * 修改用户密码
- *
- * @access public
- * @return string
- */
- public function updatePassword()
- {
- $code = -2;
- $msg = lang('EC01002');
- $data = [];
- try {
- // 修改密码.
- $backData = model('Admin')->updatePassword();
- if ($backData['code'] === 1) {
- $code = 1;
- $msg = $backData['msg'];
- $data = $backData['data'];
- // 失败则返回错误信息.
- } else {
- $msg = $backData['msg'];
- }
- } catch (Exception $e) {
- Log::write($e->getMessage(), 'error');
- }
- return json(['code' => $code, 'data' => $data, 'msg' => $msg]);
- }//end updatePassword()
- /**
- * 消息列表
- *
- * @access public
- * @return string
- */
- public function messageList()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取消息列表.
- $messageList = model('message')->messageList();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'messageList' => $messageList['data']['messageList'],
- 'page' => $messageList['data']['page'],
- 'currentPage' => $messageList['data']['currentPage'],
- ]);
- return $this->fetch('messagelist');
- }//end messageList()
- /**
- * 消息详情
- *
- * @access public
- * @return string
- */
- public function messageInfo()
- {
- // 获取管理员信息.
- $adminInfo = session('admin');
- // 获取当前模块地址.
- $getModular = $this->getModular();
- // 获取消息详情.
- $messageList = model('message')->messageInfo();
- // 传递参数.
- $this->assign([
- 'adminInfo' => $adminInfo,
- 'getPath' => $getModular['path'],
- 'getAction' => $getModular['action'],
- 'messageInfo' => $messageList['data']['messageInfo'],
- ]);
- return $this->fetch('messageinfo');
- }//end messageInfo()
- }
|