Theme.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\shop;
  3. use app\common\controller\Backend;
  4. use think\Session;
  5. /**
  6. * 移动端主题
  7. *
  8. * @icon fa fa-gears
  9. */
  10. class Theme extends Backend
  11. {
  12. /**
  13. * 查看
  14. */
  15. public function index()
  16. {
  17. if ($this->request->isPost()) {
  18. $preview = $this->request->post('preview');
  19. $navbar = $this->request->post('navbar/a', []);
  20. $theme = $this->request->post('theme/a', []);
  21. $tabbar = $this->request->post('tabbar/a', []);
  22. $tabbar['midButton'] = (bool)$tabbar['midButton'];
  23. $tabbar['borderTop'] = (bool)$tabbar['borderTop'];
  24. if (isset($tabbar['list'])) {
  25. foreach ($tabbar['list'] as $index => &$item) {
  26. $item['midButton'] = isset($item['midButton']) && $item['midButton'] ? true : false;
  27. $item = array_merge($item, [
  28. 'count' => 0,
  29. 'isDot' => false,
  30. 'badgeColor' => $theme['color'], //字体颜色
  31. 'badgeBgColor' => $theme['bgColor'], //背景颜色
  32. ]);
  33. }
  34. $tabbar['list'] = array_values($tabbar['list']);
  35. }
  36. $theme = array_merge($theme, [
  37. 'ladder' => 10,//前景色和背景色的阶梯数
  38. 'number' => 9,//取第几个的阶梯颜色
  39. 'border' => 5,//边框取第几个阶梯数
  40. ]);
  41. $navbar['isshow'] = true;
  42. $tabbar['isshow'] = true;
  43. $config = [
  44. 'navbar' => $navbar,
  45. 'theme' => $theme,
  46. 'tabbar' => $tabbar,
  47. ];
  48. //如果是预览模式则写入session
  49. if ($preview) {
  50. Session::set("previewtheme-shop", $config);
  51. } else {
  52. \addons\shop\library\Theme::set($config);
  53. }
  54. $this->success();
  55. }
  56. $config = \addons\shop\library\Theme::get();
  57. $this->view->assign("themeConfig", $config);
  58. $this->assignconfig("themeConfig", $config);
  59. return $this->view->fetch();
  60. }
  61. }