Shop.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\app\App as AppModel;
  4. use app\admin\model\Shop as ShopModel;
  5. class Shop extends Controller
  6. {
  7. /**
  8. * 小程序列表
  9. */
  10. public function index()
  11. {
  12. $model = new AppModel;
  13. $list = $list = $model->getList($this->postData());
  14. return $this->renderSuccess('', compact('list'));
  15. }
  16. /**
  17. * 进入商城
  18. */
  19. public function enter($app_id)
  20. {
  21. session('jjjshop_store', null);
  22. $model = new ShopModel;
  23. $model->login($app_id);
  24. return redirect('/shop#/login?from=admin');
  25. }
  26. /**
  27. * 添加应用
  28. */
  29. public function add()
  30. {
  31. $model = new AppModel;
  32. // 新增记录
  33. if ($model->add($this->postData())) {
  34. return $this->renderSuccess('添加成功');
  35. }
  36. return $this->renderError($model->getError() ?: '添加失败');
  37. }
  38. /**
  39. * 添加应用
  40. */
  41. public function edit($app_id)
  42. {
  43. $model = AppModel::detail($app_id);
  44. // 新增记录
  45. if ($model->edit($this->postData())) {
  46. return $this->renderSuccess('修改成功');
  47. }
  48. return $this->renderError($model->getError() ?: '修改失败');
  49. }
  50. /**
  51. * 删除小程序
  52. */
  53. public function delete($app_id)
  54. {
  55. // 小程序详情
  56. $model = AppModel::detail($app_id);
  57. if (!$model->setDelete()) {
  58. return $this->renderError('操作失败');
  59. }
  60. return $this->renderSuccess('操作成功');
  61. }
  62. /*
  63. *启用禁用
  64. */
  65. public function updateStatus($app_id)
  66. {
  67. $model = AppModel::detail($app_id);
  68. if (!$model->updateStatus()) {
  69. return $this->renderError('操作失败');
  70. }
  71. return $this->renderSuccess('操作成功');
  72. }
  73. }