NavbarController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use app\constants\NavbarLink;
  9. use app\models\AppNavbar;
  10. use app\models\Option;
  11. use yii\helpers\Json;
  12. /**
  13. * Class NavbarController
  14. * @package app\modules\admin\controllers
  15. */
  16. class NavbarController extends BaseController
  17. {
  18. /**
  19. * 获取默认数据
  20. */
  21. public function actionGetInfo()
  22. {
  23. $default = [
  24. 'frontColor' => '#000000',
  25. 'backgroundColor' => '#ffffff',
  26. 'bottomBackgroundColor' => '#ffffff',
  27. ];
  28. $navigation_bar_color = Option::get('navigation_bar_color', get_store_id(), 'navbar', Json::encode($default));
  29. $navbar = AppNavbar::getNavbar(get_store_id());
  30. return $this->asJson([
  31. 'code' => 0,
  32. 'data' => [
  33. 'navbar' => $navbar,
  34. 'navigation_bar_color' => Json::decode($navigation_bar_color['value']),
  35. 'link_list' => NavbarLink::getLink()
  36. ],
  37. ]);
  38. }
  39. public function actionSaveInfo()
  40. {
  41. $post = post_params();
  42. Option::set('navigation_bar_color', Json::encode($post['navigation_bar_color']), get_store_id(), 'navbar');
  43. Option::set('navbar', Json::encode($post['navbar']), get_store_id(), 'navbar');
  44. return $this->asJson([
  45. 'code' => 0,
  46. 'msg' => '保存成功'
  47. ]);
  48. }
  49. }