Diyview.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\api\controller;
  11. use app\model\diy\Template;
  12. use app\model\web\DiyView as DiyViewModel;
  13. /**
  14. * 自定义模板
  15. * @package app\api\controller
  16. */
  17. class Diyview extends BaseApi
  18. {
  19. /**
  20. * 基础信息
  21. */
  22. public function info()
  23. {
  24. $id = isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : 0;
  25. $name = isset($this->params[ 'name' ]) ? $this->params[ 'name' ] : '';
  26. if (empty($id) && empty($name)) {
  27. return $this->response($this->error('', 'REQUEST_DIY_ID_NAME'));
  28. }
  29. $this->initStoreData();
  30. // 如果是连锁运营模式,则进入门店页面
  31. if ($name == 'DIY_VIEW_INDEX' && $this->store_data[ 'config' ][ 'store_business' ] == 'store') {
  32. $name = 'DIY_STORE';
  33. }
  34. $diy_view = new DiyViewModel();
  35. $condition = [
  36. [ 'site_id', '=', $this->site_id ]
  37. ];
  38. if (!empty($id)) {
  39. $condition[] = [ 'id', '=', $id ];
  40. } elseif (!empty($name)) {
  41. $condition[] = [ 'name', '=', $name ];
  42. $condition[] = [ 'is_default', '=', 1 ];
  43. }
  44. $info = $diy_view->getSiteDiyViewDetail($condition);
  45. if (!empty($info[ 'data' ])) {
  46. $diy_view->modifyClick([ [ 'id', '=', $info[ 'data' ][ 'id' ] ], [ 'site_id', '=', $this->site_id ] ]);
  47. }
  48. // 如果是连锁运营模式,标题显示门店名称
  49. // if ($name == 'DIY_STORE' && $this->store_data[ 'config' ][ 'store_business' ] == 'store' && $this->store_data[ 'store_info' ]) {
  50. // $info[ 'data' ][ 'value' ] = json_decode($info[ 'data' ][ 'value' ], true);
  51. // $info[ 'data' ][ 'value' ][ 'global' ][ 'title' ] = $this->store_data[ 'store_info' ][ 'store_name' ];
  52. // $info[ 'data' ][ 'value' ] = json_encode($info[ 'data' ][ 'value' ]);
  53. // }
  54. return $this->response($info);
  55. }
  56. /**
  57. * 平台端底部导航
  58. * @return string
  59. */
  60. public function bottomNav()
  61. {
  62. $site_id = $this->site_id;
  63. if (empty($site_id)) {
  64. return $this->response($this->error('', 'REQUEST_SITE_ID'));
  65. }
  66. $diy_view = new DiyViewModel();
  67. $info = $diy_view->getBottomNavConfig($site_id);
  68. return $this->response($info);
  69. }
  70. /**
  71. * 风格
  72. */
  73. public function style()
  74. {
  75. $site_id = $this->site_id;
  76. if (empty($site_id)) {
  77. return $this->response($this->error('', 'REQUEST_SITE_ID'));
  78. }
  79. $diy_view = new DiyViewModel();
  80. $res = $diy_view->getStyleConfig($this->site_id);
  81. return $this->response($res);
  82. }
  83. }