rabin 5 years ago
parent
commit
d13c03c653
3 changed files with 47 additions and 3 deletions
  1. 23 0
      database/data.php
  2. 3 3
      database/page.php
  3. 21 0
      lib/Data.php

+ 23 - 0
database/data.php

@@ -37,6 +37,16 @@ $type = array
     1 => '永久',
     2 => '时间段',
 );
+
+$system = array
+(
+    -1 => '全部',
+    1 => 'H5',
+    2 => '安卓APP',
+    3 => '苹果APP',
+    4 => '微信小程序',
+);
+
 return array
 (
     # 表名
@@ -78,6 +88,19 @@ return array
             'edit'      => true,
         ),
 
+        'system'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '投放系统',
+            'default'   => '-1',
+            'desc'      => '投放系统',
+            'match'     => 'is_numeric',
+            'option'    => $system,
+            'update'    => 'radio',
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
         'type'      => array
         (
             'type'      => 'tinyint-1',

+ 3 - 3
database/page.php

@@ -69,9 +69,9 @@ return array
             'desc'      => '请选择页面类型',
             'match'     => 'is_numeric',
             'option'    => $type,
-            'update'    => 'radio',
-            'search'    => 'select',
-            'list'        => true,
+            //'update'    => 'radio',
+            //'search'    => 'select',
+            //'list'        => true,
         ),
         
         'reorder'       => array

+ 21 - 0
lib/Data.php

@@ -34,14 +34,35 @@ class Data
     {
         if ($data) {
             $time = time();
+            $source_type = $this->config(Dever::input('source_type', 'h5'));
             foreach ($data as $k => $v) {
                 foreach ($v['data'] as $k1 => $v1) {
                     if ($v1['type'] == 2 && ($time < $v1['sdate'] || $time > $v1['edate'])) {
                         unset($data[$k]['data'][$k1]);
+                    } elseif ($v1['system'] > 0 && $source_type != $v1['system']) {
+                        unset($data[$k]['data'][$k1]);
                     }
                 }
             }
         }
         return $data;
     }
+
+    private function config($type)
+    {
+        if ($type == 'ios') {
+            return 3;
+        }
+        if ($type == 'android') {
+            return 2;
+        }
+        if ($type == 'applet') {
+            return 4;
+        }
+        if ($type == 'h5') {
+            return 1;
+        }
+
+        return -1;
+    }
 }