Messagesys.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. use app\common\library\Getui;
  6. /**
  7. * 系统公告
  8. *
  9. * @icon fa fa-circle-o
  10. */
  11. class Messagesys extends Backend
  12. {
  13. /**
  14. * Messagesys模型对象
  15. * @var \app\admin\model\Messagesys
  16. */
  17. protected $model = null;
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new \app\admin\model\Messagesys;
  22. $this->view->assign("isIndexList", $this->model->getIsIndexList());
  23. $this->view->assign("isShowList", $this->model->getIsShowList());
  24. $this->view->assign("pushStatusList", $this->model->getPushStatusList());
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 推送到APP
  33. */
  34. public function tuisong(){
  35. $id = input('id',0);
  36. $info = Db::name('message_sys')->where('id',$id)->find();
  37. Db::name('message_sys')->where('id',$id)->update(['push_status' => 1]);
  38. $getui = new Getui();
  39. $title = $info['title_en'];
  40. $body = $info['info_en'];
  41. $rs = $getui->sendtoall($title, $body, 1, 'android');
  42. $rs = $getui->sendtoall($title, $body, 1, 'ios');
  43. $this->success('推送完成');
  44. }
  45. }