111
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 line
1.3 KiB

  1. <?php
  2. namespace app\common;
  3. use core\basic\Controller;
  4. use core\basic\Config;
  5. class HomeController extends Controller
  6. {
  7. public function __construct()
  8. {
  9. // 自动缓存基础信息
  10. cache_lg();
  11. cache_config();
  12. // 手机自适应主题
  13. if ($this->config('open_wap')) {
  14. if ($this->config('wap_domain') && $this->config('wap_domain') == get_http_host()) {
  15. $this->setTheme(get_theme() . '/wap'); // 已绑域名并且一致则自动手机版本
  16. } elseif (is_mobile() && $this->config('wap_domain') && $this->config('wap_domain') != get_http_host()) {
  17. if (is_https()) {
  18. $pre = 'https://';
  19. } else {
  20. $pre = 'http://';
  21. }
  22. header('Location:' . $pre . $this->config('wap_domain') . URL); // 手机访问并且绑定了域名,但是访问域名不一致则跳转
  23. } elseif (is_mobile()) { // 其他情况手机访问则自动手机版本
  24. $this->setTheme(get_theme() . '/wap');
  25. } else { // 其他情况,电脑版本
  26. $this->setTheme(get_theme());
  27. }
  28. } else { // 未开启手机,则一律电脑版本
  29. $this->setTheme(get_theme());
  30. }
  31. }
  32. }