Ver Fonte

轮播图设置

lizhen_gitee há 1 ano atrás
pai
commit
b28baa3870

+ 49 - 2
application/api/controller/company/Banner.php

@@ -20,14 +20,14 @@ class Banner extends Apic
             'company_id' => $this->auth->company_id,
             'position'   => 0, //首页
         ];
-        $index = Db::name('banner')->where($where)->order('weigh desc,id desc')->select();
+        $index = Db::name('banner')->where($where)->order('weigh asc,id asc')->select();
         $index = list_domain_image($index,['image']);
 
         $where = [
             'company_id' => $this->auth->company_id,
             'position'   => 1, //门店印象
         ];
-        $store = Db::name('banner')->where($where)->order('weigh desc,id desc')->autopage()->select();
+        $store = Db::name('banner')->where($where)->order('weigh asc,id asc')->autopage()->select();
         $store = list_domain_image($store,['image']);
 
         $rs = [
@@ -39,6 +39,53 @@ class Banner extends Apic
 
     }
 
+    //设置轮播图
+    public function edit(){
+        $index = input('index','');
+        $store = input('store','');
+
+        $where = [
+            'company_id' => $this->auth->company_id,
+            'position'   => 0, //首页
+        ];
+        Db::name('banner')->where('company_id',$this->auth->company_id)->delete();
+
+        $data = [];
+
+        if(!empty($index)){
+            $index = explode(',',$index);
+            foreach($index as $key => $val){
+                $data[] = [
+                    'company_id' => $this->auth->company_id,
+                    'image' => $val,
+                    'position' => 0,
+                    'status' => 1,
+                    'createtime' => time(),
+                    'updatetime' => time(),
+                ];
+            }
+        }
+
+        if(!empty($store)){
+            $store = explode(',',$store);
+            foreach($store as $key => $val){
+                $data[] = [
+                    'company_id' => $this->auth->company_id,
+                    'image' => $val,
+                    'position' => 1,
+                    'status' => 1,
+                    'createtime' => time(),
+                    'updatetime' => time(),
+                ];
+            }
+        }
+
+        if(!empty($data)){
+            Db::name('banner')->insertAll($data);
+        }
+        $this->success();
+    }
+
 
 
 

+ 1 - 1
application/api/controller/company/Index.php

@@ -27,7 +27,7 @@ class Index extends Apic
             'status'     => 1,
             'position'  => 0
         ];
-        $list = Db::name('banner')->where($where)->order('weigh desc,id desc')->autopage()->select();
+        $list = Db::name('banner')->where($where)->order('weigh asc,id asc')->autopage()->select();
         $this->success(1,$list);
     }
 

+ 1 - 1
application/common.php

@@ -574,7 +574,7 @@ function localpath_to_netpath($path)
     } elseif (strrpos($path, 'http') !== false) {
         return $path;
     } else {
-        return config('site.domain_cdnurl') . str_replace("\\", "/", $path);
+        return config('upload.cdnurl') . str_replace("\\", "/", $path);
     }
 }