Newbanner.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\api\controller\company;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 门店印象轮播图管理
  7. */
  8. class Newbanner extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = '*';
  12. //某门店的轮播图
  13. public function banner_list(){
  14. $where = [
  15. 'company_id' => $this->auth->company_id,
  16. ];
  17. $store = Db::name('banner')->where($where)->order('weigh asc,id asc')->select();
  18. $store = list_domain_image($store,['image']);
  19. $this->success(1,$store);
  20. }
  21. //设置轮播图
  22. public function edit(){
  23. $index = input('images','');
  24. Db::name('banner')->where('company_id',$this->auth->company_id)->delete();
  25. $data = [];
  26. if(!empty($index)){
  27. $index = explode(',',$index);
  28. foreach($index as $key => $val){
  29. $data[] = [
  30. 'company_id' => $this->auth->company_id,
  31. 'image' => $val,
  32. 'position' => 0,
  33. 'status' => 1,
  34. 'createtime' => time(),
  35. 'updatetime' => time(),
  36. ];
  37. }
  38. }
  39. if(!empty($data)){
  40. Db::name('banner')->insertAll($data);
  41. }
  42. $this->success();
  43. }
  44. }