Wxapp.php 1.3 KB

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