Banner.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace app\api\controller\company;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 轮播图管理
  7. * 由于数据结构改变,全部废弃
  8. */
  9. class Banner extends Apic
  10. {
  11. protected $noNeedLogin = [];
  12. protected $noNeedRight = '*';
  13. //某门店的轮播图
  14. public function banner_list(){
  15. $where = [
  16. 'company_id' => $this->auth->company_id,
  17. 'position' => 0, //首页
  18. ];
  19. $index = Db::name('banner')->where($where)->order('weigh asc,id asc')->select();
  20. $index = list_domain_image($index,['image']);
  21. $where = [
  22. 'company_id' => $this->auth->company_id,
  23. 'position' => 1, //门店印象
  24. ];
  25. $store = Db::name('banner')->where($where)->order('weigh asc,id asc')->autopage()->select();
  26. $store = list_domain_image($store,['image']);
  27. $rs = [
  28. 'index' => $index,
  29. 'store' => $store,
  30. ];
  31. $this->success(1,$rs);
  32. }
  33. //设置轮播图
  34. public function edit(){
  35. $index = input('index','');
  36. $store = input('store','');
  37. $where = [
  38. 'company_id' => $this->auth->company_id,
  39. 'position' => 0, //首页
  40. ];
  41. Db::name('banner')->where('company_id',$this->auth->company_id)->delete();
  42. $data = [];
  43. if(!empty($index)){
  44. $index = explode(',',$index);
  45. foreach($index as $key => $val){
  46. $data[] = [
  47. 'company_id' => $this->auth->company_id,
  48. 'image' => $val,
  49. 'position' => 0,
  50. 'status' => 1,
  51. 'createtime' => time(),
  52. 'updatetime' => time(),
  53. ];
  54. }
  55. }
  56. if(!empty($store)){
  57. $store = explode(',',$store);
  58. foreach($store as $key => $val){
  59. $data[] = [
  60. 'company_id' => $this->auth->company_id,
  61. 'image' => $val,
  62. 'position' => 1,
  63. 'status' => 1,
  64. 'createtime' => time(),
  65. 'updatetime' => time(),
  66. ];
  67. }
  68. }
  69. if(!empty($data)){
  70. Db::name('banner')->insertAll($data);
  71. }
  72. $this->success();
  73. }
  74. }