Wxapp.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\controller;
  10. use app\store\model\Wxapp as WxappModel;
  11. use app\store\model\WxappNavbar as WxappNavbarModel;
  12. /**
  13. * 小程序管理
  14. * Class Wxapp
  15. * @package app\store\controller
  16. */
  17. class Wxapp extends Controller
  18. {
  19. /**
  20. * 小程序设置
  21. * @return mixed
  22. * @throws \think\exception\DbException
  23. */
  24. public function setting()
  25. {
  26. // 当前小程序信息
  27. $model = WxappModel::detail();
  28. if (!$this->request->isAjax()) {
  29. return $this->fetch('setting', compact('model'));
  30. }
  31. // 更新小程序设置
  32. if ($model->edit($this->postData('wxapp'))) {
  33. return $this->renderSuccess('更新成功');
  34. }
  35. return $this->renderError($model->getError() ?: '更新失败');
  36. }
  37. /**
  38. * 导航栏设置
  39. * @return array|mixed
  40. * @throws \think\exception\DbException
  41. */
  42. public function tabbar()
  43. {
  44. $model = WxappNavbarModel::detail();
  45. if (!$this->request->isAjax()) {
  46. return $this->fetch('tabbar', compact('model'));
  47. }
  48. $data = $this->postData('tabbar');
  49. if (!$model->edit($data)) {
  50. return $this->renderError('更新失败');
  51. }
  52. return $this->renderSuccess('更新成功');
  53. }
  54. }