12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- class Banner extends Api
- {
- protected $noNeedLogin = ['getList'];
- protected $noNeedRight = '*';
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = Db::name('platform_banner');
- }
- /**
- * 列表
- * @return void
- */
- public function getList()
- {
- try {
- $position = $this->request->param('position',0);//位置:0=首页,1=门店印象
- $field = 'id,title,image,url';
- $where['status'] = 1;
- $where['position'] = $position;
- $result = $this->model->field($field)->where($where)->order('weigh asc')->select();
- if (!empty($result)) {
- foreach ($result as $key => &$value) {
- !empty($value['image']) && $value['image'] = cdnurl($value['image']);
- }
- }
- $this->success('获取成功',$result);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- }
- /**
- * 门店列表
- * @return void
- */
- public function getCompanyList()
- {
- try {
- $companyId = $this->request->param('company_id',0);
- $companyId = !empty($companyId) ? $companyId : $this->auth->company_id;
- $field = 'id,title,image,url';
- $where['status'] = 1;
- $where['company_id'] = $companyId;
- $result = Db::name('banner')->field($field)->where($where)->order('weigh asc')->select();
- if (!empty($result)) {
- $result = list_domain_image($result, ['image']);
- }
- $this->success('获取成功',$result);
- } catch (Exception $e) {
- $this->error($e->getMessage());
- }
- }
- }
|