Core.php 930 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Main\Lib;
  3. use Dever;
  4. class Core
  5. {
  6. protected $uid = -1;
  7. protected $use = array();
  8. protected $data = array();
  9. public function __construct()
  10. {
  11. $this->uid = Dever::load('passport/user')->check(false);
  12. if ($this->uid) {
  13. $this->user = Dever::load('passport/user')->info($this->uid);
  14. } else {
  15. $this->user = Dever::load('passport/user')->init();
  16. $this->uid = $this->user['id'];
  17. }
  18. if ($this->user) {
  19. $this->user['uid'] = $this->user['id'];
  20. }
  21. }
  22. public function checkLogin()
  23. {
  24. if (!$this->uid || $this->uid <= 0) {
  25. Dever::alert('请先登录', -2);
  26. }
  27. }
  28. public function alert($state)
  29. {
  30. if ($state) {
  31. return 'ok';
  32. } else {
  33. Dever::alert('操作失败');
  34. }
  35. }
  36. }