Index.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php namespace App\Http\Controllers\Admin;
  2. use Illuminate\Support\Facades\Cache;
  3. use App\Facades\Servers\WechatMini\Mini;
  4. /**
  5. * 后台控制器
  6. *
  7. * @author 刘相欣
  8. *
  9. * */
  10. class Index extends Auth{
  11. public function index()
  12. {
  13. // 获取菜单
  14. $this->getMenu('admin');
  15. // 请求结果
  16. return $this->fetch();
  17. }
  18. /**
  19. * 欢迎页
  20. *
  21. * */
  22. public function welcome()
  23. {
  24. // 结果数据
  25. $link = cache('admin:wechat:mini:index:mpurl');
  26. // 不存在数据
  27. if ( is_null($link) ) {
  28. // 从数据库获取数据
  29. $link = Mini::getUrlLink('pages/index/index');
  30. // 存起来
  31. cache(['admin:wechat:mini:index:mpurl'=>$link],$link ? now()->addDays(28) : now()->addMinutes(3));
  32. }
  33. // 分配参数
  34. $this->assign('link',$link);
  35. // 加载模板
  36. return $this->fetch();
  37. }
  38. /**
  39. * 清理缓存
  40. *
  41. * */
  42. public function refresh()
  43. {
  44. // 清除缓存
  45. Cache::flush();
  46. // 加载模板
  47. return json_send(['code'=>'success','msg'=>'刷新成功']);
  48. }
  49. }