BaseMall.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 公共用户可以访问的类(不需要登录)
  4. */
  5. namespace app\home\controller;
  6. use think\facade\Lang;
  7. /**
  8. * ============================================================================
  9. * DSMall多用户商城
  10. * ============================================================================
  11. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  12. * 网站地址: http://www.csdeshang.com
  13. * ----------------------------------------------------------------------------
  14. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  15. * 不允许对程序代码以任何形式任何目的的再发布。
  16. * ============================================================================
  17. * 控制器
  18. */
  19. class BaseMall extends BaseHome {
  20. public function initialize() {
  21. parent::initialize();
  22. if(request()->isMobile() && config('ds_config.h5_force_redirect')){
  23. $this->isHomeUrl();
  24. }
  25. $this->template_dir = 'default/mall/'. strtolower(request()->controller()).'/';
  26. }
  27. /**
  28. * 手机端访问自动跳转
  29. */
  30. protected function isHomeUrl(){
  31. $controller = request()->controller();//取控制器名
  32. $action = request()->action();//取方法名
  33. $input = request()->param();//取参数
  34. $param = http_build_query($input);//将参数转换成链接形式
  35. if ($controller == 'Goods' && $action == 'index'){//商品详情
  36. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsdetail/Goodsdetail?'.$param);
  37. exit;
  38. }elseif ($controller == 'Showgroupbuy' && $action == 'index'){//抢购列表
  39. header('Location:'.config('ds_config.h5_site_url').'/pages/home/groupbuy/GroupBuyList');
  40. exit;
  41. }elseif ($controller == 'Search' && $action == 'index'){//搜索
  42. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodslist/Goodslist');
  43. exit;
  44. }elseif ($controller == 'Showgroupbuy' && $action == 'groupbuy_detail'){//抢购详情
  45. $goods_id = model('groupbuy')->getGroupbuyOnlineInfo(array(array('groupbuy_id' ,'=', $input['group_id'])))['goods_id'];
  46. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsdetail/Goodsdetail?goods_id='.$goods_id);
  47. exit;
  48. }elseif ($controller == 'Store' && $action == 'goods_all'){//店铺商品列表
  49. header('Location:'.config('ds_config.h5_site_url').'/pages/home/storegoodslist/Goodslist?'.$param);
  50. exit;
  51. }elseif ($controller == 'Category' && $action == 'goods'){//分类
  52. header('Location:'.config('ds_config.h5_site_url').'/pages/home/goodsclass/Goodsclass');
  53. exit;
  54. }else {
  55. header('Location:'.config('ds_config.h5_site_url'));exit;//其它页面跳转到首页
  56. }
  57. }
  58. }
  59. ?>