rules.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chengxun
  5. * Date: 2017/7/18
  6. * Time: 16:14
  7. */
  8. use think\Route;
  9. use think\Request;
  10. use think\Cookie;
  11. use think\Config;
  12. use app\common\model\DomainConfig;
  13. $host = Request::instance()->host();
  14. $domain_model = new DomainConfig();
  15. $domain_data = $domain_model->get_host_module($host);
  16. //$path = 'logs';
  17. //$msg = $domain_data;
  18. //if (! is_dir($path)) {
  19. // mkdir($path);
  20. //}
  21. //$filename = $path . '/' . date('YmdHi') . '.log';
  22. //$content = date("Y-m-d H:i:s")."\r\n".json_encode($msg,JSON_UNESCAPED_UNICODE)."\r\n \r\n \r\n ";
  23. //file_put_contents($filename, $content, FILE_APPEND);
  24. if($host !== null){
  25. if(empty($domain_data)){
  26. if(Request::instance()->isMobile()){
  27. header('Location: '.Config::get('url.mobile'));
  28. exit;
  29. }else{
  30. header('Location: '.Config::get('url.home'));
  31. exit;
  32. }
  33. }elseif ($domain_data['user_id'] > 0){
  34. $con = Request::instance()->controller();
  35. $fun = Request::instance()->action();
  36. Route::domain($host,$domain_data['module']);
  37. Route::rule('','shop/index');
  38. Route::rule('index/index','shop/index');
  39. Cookie::set('shop_id',$domain_data['user_id']);
  40. }else{
  41. Route::domain($host,$domain_data['module']);
  42. }
  43. if($domain_data['module'] != 'shop'){
  44. Route::rule('goods/:id','detail/index');//商品链接
  45. }
  46. //Route::rule('user','user/index');
  47. Route::rule('share/:code','share/index');//分享链接
  48. Route::rule('sweep/:r','Spc/sweep');//扫码二维码
  49. // Route::rule('c/:c','Spc/sweep');//扫码二维码
  50. // Route::rule('d/:d','Spc/sweep');//扫码二维码
  51. Route::rule('query/:data','Spc/query');//扫码结果页
  52. Route::rule('archive/:token','Spc/archive');//追溯档案展示
  53. }