BaseMall.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * 公共用户可以访问的类(不需要登录)
  4. */
  5. namespace app\home\controller;
  6. use think\facade\Lang;
  7. /**
  8. * ============================================================================
  9. *
  10. * ============================================================================
  11. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  12. * 网站地址: https://www.valimart.net/
  13. * ----------------------------------------------------------------------------
  14. *
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class BaseMall extends BaseHome {
  19. public function initialize() {
  20. parent::initialize();
  21. if(request()->isMobile() && config('ds_config.h5_force_redirect')){
  22. $this->isHomeUrl();
  23. }
  24. $this->template_dir = 'default/mall/'. strtolower(request()->controller()).'/';
  25. }
  26. /**
  27. * 手机端访问自动跳转
  28. */
  29. protected function isHomeUrl(){
  30. $controller = request()->controller();//取控制器名
  31. $action = request()->action();//取方法名
  32. $input = request()->param();//取参数
  33. $param = http_build_query($input);//将参数转换成链接形式
  34. if ($controller == 'Goods' && $action == 'index'){//商品详情
  35. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsdetail/Goodsdetail?'.$param);
  36. exit;
  37. }elseif ($controller == 'Showgroupbuy' && $action == 'index'){//抢购列表
  38. header('Location:'.config('ds_config.h5_site_url').'/pages/home/groupbuy/GroupBuyList');
  39. exit;
  40. }elseif ($controller == 'Search' && $action == 'index'){//搜索
  41. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodslist/Goodslist');
  42. exit;
  43. }elseif ($controller == 'Showgroupbuy' && $action == 'groupbuy_detail'){//抢购详情
  44. $goods_id = model('groupbuy')->getGroupbuyOnlineInfo(array(array('groupbuy_id' ,'=', $input['group_id'])))['goods_id'];
  45. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsdetail/Goodsdetail?goods_id='.$goods_id);
  46. exit;
  47. }elseif ($controller == 'Store' && $action == 'goods_all'){//店铺商品列表
  48. header('Location:'.config('ds_config.h5_site_url').'/pages/home/storegoodslist/Goodslist?'.$param);
  49. exit;
  50. }elseif ($controller == 'Category' && $action == 'goods'){//分类
  51. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsclass/Goodsclass');
  52. exit;
  53. }else {
  54. header('Location:'.config('ds_config.h5_site_url'));exit;//其它页面跳转到首页
  55. }
  56. }
  57. }
  58. ?>