Banner.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class Banner extends Api
  6. {
  7. protected $noNeedLogin = [];
  8. protected $noNeedRight = '*';
  9. protected $model = null;
  10. public function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->model = Db::name('banner');
  14. }
  15. /**
  16. * 列表
  17. * @return void
  18. */
  19. public function getList()
  20. {
  21. try {
  22. $companyId = $this->request->param('company_id',0);
  23. $position = $this->request->param('position',0);//位置:0=首页,1=门店印象
  24. $field = 'id,title,image,url';
  25. $where['status'] = 1;
  26. $where['position'] = $position;
  27. $where['company_id'] = $companyId;
  28. $result = $this->model->field($field)->where($where)->order('weigh asc')->select();
  29. if (!empty($result)) {
  30. !empty($result['image']) && $result['image'] = cdnurl($result['image']);
  31. }
  32. $this->success('获取成功',$result);
  33. } catch (Exception $e) {
  34. $this->error($e->getMessage());
  35. }
  36. }
  37. }