VisualConfig.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\controller\admin\system\diy;
  3. use app\common\repositories\system\config\ConfigValueRepository;
  4. use app\common\repositories\system\diy\DiyRepository;
  5. use app\common\repositories\system\groupData\GroupDataRepository;
  6. use app\common\repositories\system\groupData\GroupRepository;
  7. use crmeb\basic\BaseController;
  8. /**
  9. * 主题色
  10. */
  11. class VisualConfig extends BaseController
  12. {
  13. public function storeStreet()
  14. {
  15. return app('json')->success(systemConfig(['mer_location', 'store_street_theme']) + ['mer_location' => 0, 'store_street_theme' => 0]);
  16. }
  17. /**
  18. * 保存店铺街的配置
  19. * @return \think\response\Json
  20. * @author Qinii
  21. */
  22. public function setStoreStreet()
  23. {
  24. $data = $this->request->params(['mer_location', 'store_street_theme']);
  25. app()->make(ConfigValueRepository::class)->setFormData($data, 0);
  26. return app('json')->success('编辑成功');
  27. }
  28. /**
  29. * 个人中心 - 会员服务菜单及一键换色配置
  30. * @return \think\response\Json
  31. * @author Qinii
  32. */
  33. public function userIndex()
  34. {
  35. $my_banner = systemGroupData('my_banner');
  36. $my_menus = systemGroupData('my_menus');
  37. $theme = app()->make(DiyRepository::class)->getThemeVar(systemConfig('global_theme'));
  38. return app('json')->success(compact('my_banner', 'my_menus', 'theme'));
  39. }
  40. /**
  41. * 保存个人中心 - 会员服务菜单及一键换色配置
  42. * @return \think\response\Json
  43. * @author Qinii
  44. * @day 2023/4/11
  45. */
  46. public function setUserIndex()
  47. {
  48. $data = $this->request->params(['my_banner', 'my_menus']);
  49. $make = app()->make(GroupDataRepository::class);
  50. $make->setGroupData('my_banner', 0, $data['my_banner']);
  51. $make->setGroupData('my_menus', 0, $data['my_menus']);
  52. return app('json')->success('编辑成功');
  53. }
  54. /**
  55. * 可视化配置里显示的组合数据
  56. * @return \think\response\Json
  57. * @author Qinii
  58. * @day 2023/4/11
  59. */
  60. public function getThemeKey()
  61. {
  62. $key = ['new_home_banner', 'hot_home_banner', 'best_home_banner', 'good_home_banner', 'sign_day_config', 'points_mall_banner', 'points_mall_district', 'points_mall_scope', 'open_screen_advertising'];
  63. $data['menu'] = app()->make(GroupRepository::class)->getSearch([])->where('group_key', 'in', $key)->field('group_id,group_name,group_key')->select();
  64. return app('json')->success($data);
  65. }
  66. /**
  67. * 根据每个key
  68. * @param $key
  69. * @return \think\response\Json
  70. * @author Qinii
  71. * @day 2023/4/12
  72. */
  73. public function getTheme($key)
  74. {
  75. [$page, $limit] = $this->getPage();
  76. $groupRepository = app()->make(GroupRepository::class);
  77. $group = $groupRepository->getWhere(['group_key' => $key]);
  78. $data = app()->make(GroupDataRepository::class)->getGroupDataLst($this->request->merId(), $group->group_id, $page, $limit);
  79. if ($key == 'open_screen_advertising') {
  80. $data['config'] = systemConfig(['open_screen_switch', 'open_screen_time', 'open_screen_space']);
  81. }
  82. return app('json')->success($data);
  83. }
  84. /**
  85. * 写入可视化数据
  86. * @param $key
  87. * @author Qinii
  88. * @day 2023/4/11
  89. */
  90. public function setTheme($key)
  91. {
  92. $grouop = ['sign_day_config', 'points_mall_scope'];
  93. $config = $this->request->param('config', []);
  94. $list = $this->request->param('data', []);
  95. if ($config) {
  96. app()->make(ConfigValueRepository::class)->setFormData($config, 0);
  97. }
  98. $make = app()->make(GroupDataRepository::class);
  99. if (in_array($key, $grouop)) return app('json')->success('编辑成功');
  100. if ($list) {
  101. $make->setGroupData($key, 0, $list);
  102. } else {
  103. $make->clearGroup($key, 0);
  104. }
  105. return app('json')->success('编辑成功');
  106. }
  107. }