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('platform_banner');
  14. }
  15. /**
  16. * 列表
  17. * @return void
  18. */
  19. public function getList()
  20. {
  21. try {
  22. $position = $this->request->param('position',0);//位置:0=首页,1=门店印象
  23. $field = 'id,title,image,url';
  24. $where['status'] = 1;
  25. $where['position'] = $position;
  26. $result = $this->model->field($field)->where($where)->order('weigh asc')->select();
  27. if (!empty($result)) {
  28. foreach ($result as $key => &$value) {
  29. !empty($value['image']) && $value['image'] = cdnurl($value['image']);
  30. }
  31. }
  32. $this->success('获取成功',$result);
  33. } catch (Exception $e) {
  34. $this->error($e->getMessage());
  35. }
  36. }
  37. }