Common.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\blog\controller\wxapp;
  3. use addons\blog\model\Category;
  4. use think\Config;
  5. /**
  6. * 公共
  7. */
  8. class Common extends Base
  9. {
  10. protected $noNeedLogin = '*';
  11. /**
  12. * 初始化
  13. */
  14. public function init()
  15. {
  16. //首页Tab列表
  17. $tabList = [['id' => 0, 'title' => '全部']];
  18. $channelList = Category::where('status', 'normal')
  19. ->field('id,pid,name,nickname,diyname')
  20. ->order('weigh desc,id desc')
  21. ->select();
  22. foreach ($channelList as $index => $item) {
  23. $tabList[] = ['id' => $item['id'], 'title' => $item['name']];
  24. }
  25. //配置信息
  26. $upload = Config::get('upload');
  27. $upload['cdnurl'] = $upload['cdnurl'] ? $upload['cdnurl'] : cdnurl('', true);
  28. $upload['uploadurl'] = $upload['uploadurl'] == 'ajax/upload' ? cdnurl('/ajax/upload', true) : $upload['cdnurl'];
  29. $config = [
  30. 'upload' => $upload
  31. ];
  32. $data = [
  33. 'tabList' => $tabList,
  34. 'config' => $config
  35. ];
  36. $this->success('', $data);
  37. }
  38. }