dever 5 年之前
父节点
当前提交
997b5bde56

+ 4 - 2
app/collection/database/function.php

@@ -5,7 +5,7 @@ $type = array
     'cate' 		=> '集合',
     'community' => '社区',
     'shop' 		=> '商城',
-    'times' 		=> '时光',
+    'times' 	=> '时光',
     //'jump' 		=> '穿越',
     //'befall' 	=> '降临',
     //'music' 	=> '音乐',
@@ -21,6 +21,8 @@ $status = array
 $direction = array
 (
 	'left' => '左侧展开',
+	//'right' => '右侧展开',
+	'down' => '从下方展开',
 );
 return array
 (
@@ -177,7 +179,7 @@ return array
         # 列表 商城要加入选品列表
         'list_button' => array
         (
-            
+            'list' => array('商品管理', '"product&search_option_info_id={info_id}&oper_table=function&top_table=info&top_project=collection"' , '"{type}" == "shop"'),
         ),
     ),
 

+ 23 - 36
app/collection/database/product.php

@@ -1,27 +1,5 @@
 <?php
 
-$status = Dever::config('base')->status;
-
-$text = array
-(
-    1 => '上左',
-    2 => '上中',
-    3 => '上右',
-    4 => '中左',
-    5 => '正中',
-    6 => '中右',
-    7 => '下左',
-    8 => '下中',
-    9 => '下右',
-    //10 => '自定义',
-);
-
-$bgcolor_type = array
-(
-    1 => '设置背景颜色',
-    2 => '不设置背景颜色',
-);
-
 return array
 (
     # 表名
@@ -63,22 +41,31 @@ return array
             'desc'      => '选择产品',
             'match'     => 'option',
             'update'    => 'select',
-            'show'      => 'type=11',
             'update_search' => 'goods/lib/manage.search',
         ),
 
-        'status'        => array
+        'name'      => array
         (
-            'type'      => 'int-11',
-            'name'      => '发布状态',
-            'default'   => '1',
-            'desc'      => '发布状态',
-            'match'     => 'is_numeric',
-            //'update'  => 'select',
-            'option'    => $status,
-            'search'    => 'select',
-            //'list'        => true,
-            //'edit'        => true,
+            'type'      => 'varchar-180',
+            'name'      => '商品标题-可以为空,不填写自动获取原商品标题',
+            'default'   => '',
+            'desc'      => '商品标题',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'pic_cover'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '商品图片-图片尺寸随意或等比尺寸,建议尺寸750*1386px,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,不传则自动获取原商品图片',
+            'default'   => '',
+            'desc'      => '商品图片',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '750*1386',
         ),
 
         'reorder'       => array
@@ -88,7 +75,7 @@ return array
             'default'   => '1',
             'desc'      => '请输入排序',
             'match'     => 'option',
-            //'update'  => 'text',
+            'update'  => 'text',
             'search'    => 'order',
             'list'      => true,
             'order'     => 'desc',
@@ -130,11 +117,11 @@ return array
             'option' => array
             (
                 'info_id' => 'yes',
-                'content_id' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
             'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
             'col' => '*',
         ),
     ),

+ 10 - 0
app/collection/database/user_record.php

@@ -51,6 +51,16 @@ return array
             'update'    => 'text',
         ),
 
+        'parent_page_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '父级章节id',
+            'default'   => '',
+            'desc'      => '章节id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
         'page_id'      => array
         (
             'type'      => 'int-11',

+ 30 - 2
app/collection/lib/Core.php

@@ -10,14 +10,42 @@ class Core
 	protected $uid;
     protected $user;
 	protected $year;
+    protected $times;
+    protected $parent_page_id;
+    protected $page_id;
+    protected $key = 'dreamland1985';
 
     public function __construct()
     {
+        $this->checkCode();
     	# 获取当前的用户信息
         $this->token = Dever::input('token');
         $this->uid = 1;
         $this->user = Dever::load('passport/api')->info($this->uid);
-        # 获取时光id
-        $this->times = Dever::input('times');
+    }
+
+    protected function checkCode()
+    {
+        $this->code = Dever::input('code');
+        if ($this->code) {
+            $code = Dever::decode($this->code, $this->key);
+            $code = explode('_', $code);
+            $this->id = $code[1];
+            $this->parent_page_id = $code[2];
+            $this->page_id = $code[3];
+            $this->index = $code[4];
+            $this->times = $code[5];
+        } else {
+            $this->id = Dever::input('id');
+        }
+    }
+
+    protected function getCode($id, $parent_page_id, $page_id, $index, $times_id)
+    {
+        $key = 'dlv1_' . $id. '_' . $parent_page_id . '_' . $page_id . '_' . $index . '_' . $times_id;
+
+        $code = Dever::encode($key, $this->key);
+
+        return $code;
     }
 }

+ 104 - 71
app/collection/src/Api.php

@@ -9,8 +9,11 @@ class Api extends Core
 {
     public function __construct()
     {
-        $this->id = Dever::input('id');
         parent::__construct();
+
+        if (!$this->id) {
+            Dever::alert('错误的参数');
+        }
     }
 
     public function data()
@@ -54,44 +57,54 @@ class Api extends Core
             $where['uid'] = $this->uid;
             $record = Dever::db('collection/user_record')->one($where);
             if ($record) {
-                $data['page_id'] = $record['page_id'];
-                $data['times'] = $record['times_id'];
-                $data['index'] = $record['index'];
+                $parent_page_id = $record['parent_page_id'];
+                $page_id = $record['page_id'];
+                $times = $record['times_id'];
+                $index = $record['index'];
             } else {
                 # 获取最新的章节页id
                 $page_where['info_id'] = $data['info']['id'];
                 $page_where = $this->getTimes($page_where);
                 $page = Dever::db('collection/page')->child($page_where);
-                $data['page_id'] = 0;
+                $parent_page_id = $page_id = 0;
                 if ($page) {
-                    $data['page_id'] = $page[0]['id'];
+                    $parent_page_id = $page[0]['page_id'];
+                    $page_id = $page[0]['id'];
+                } else {
+                    Dever::alret('内容还没有准备好');
                 }
-                $data['times'] = 0;
+                $times = 0;
                 if ($this->times) {
-                    $data['times'] = $this->times;
+                    $times = $this->times;
                 }
-                $data['index'] = 0;
+                $index = 0;
             }
+
+            # 获取code
+            $data['code'] = $this->getCode($data['info']['id'], $parent_page_id, $page_id, $index, $times);
         }
 
         return $data;
     }
 
-    private function getTimes($where)
+    # 获取合集下的内容
+    public function getContent()
     {
-        # 获取当前年份的最新的时光
-        if (!$this->times) {
-            $where['year'] = date('Y');
-            $times = Dever::db('collection/times')->getNew($where);
-            if ($times) {
-                $this->times = $times['id'];
-            }
-        }
-        if ($this->times) {
-            $where['times_id'] = $this->times;
-        }
+        $data['info_id'] = $this->id;
+        $data['page_id'] = $this->page_id;
+        $data['parent_page_id'] = $this->parent_page_id;
+        $data['index'] = $this->index;
+        $data['times_id'] = $this->times;
+        # 获取用户信息
+        $data['user'] = $this->user;
 
-        return $where;
+        # 获取每个模块
+        $data['items'] = Dever::load('collection/lib/content')->getList($this->id, $this->page_id);
+
+        
+        $data['func'] = $this->getFunc();
+        
+        return $data;
     }
 
     # 获取合集下的购买内容
@@ -113,6 +126,18 @@ class Api extends Core
         return $data;
     }
 
+    # 获取合集下的商品
+    public function getProduct()
+    {
+        $where['info_id'] = $this->id;
+        $data['product'] = Dever::db('collection/product')->getAll($where);
+        if ($data['product']) {
+            
+        }
+
+        return $data;
+    }
+
     # 获取榜单数据
     public function getRankingData()
     {
@@ -136,53 +161,11 @@ class Api extends Core
         return $data;
     }
 
-    # 获取合集下的内容
-    public function getContent()
-    {
-        $page_id = Dever::input('page_id');
-        $data['items'] = Dever::load('collection/lib/content')->getList($this->id, $page_id);
-
-        $page = Dever::db('collection/page')->one($page_id);
-        $data['info_id'] = $this->id;
-        $data['page_id'] = $page_id;
-        $data['parent_page_id'] = $page['page_id'];
-
-        # 获取用户信息
-        $data['user'] = $this->user;
-
-        # 获取功能
-        $where['info_id'] = $this->id;
-        $func = Dever::db('collection/function')->getAll($where);
-        $data['func'] = array();
-        if ($func) {
-            foreach ($func as $k => $v) {
-                $data['func'][$v['type']] = array
-                (
-                    'show' => false,
-                    'index' => 5,
-                    'top' => 0,
-                    'padding' => '0rpx',
-                    'width' => $v['width'],
-                    'direction' => strtolower($v['direction']),
-                    'param' => array(),
-                    'button' => array
-                    (
-                        'bgColor' => $v['bgcolor'],
-                        'text' => $v['name'],
-                        'fontSize' => 28,
-                        'color' => $v['color'],
-                    ),
-                );
-            }
-        }
-        return $data;
-    }
-
     # 获取合集下的分类
     public function category()
     {
-        $parent_page_id = Dever::input('parent_page_id');
-        $page_id = Dever::input('page_id');
+        $parent_page_id = $this->parent_page_id;
+        $page_id = $this->page_id;
         $where['info_id'] = $this->id;
         $data['cate'] = Dever::db('collection/page')->main($where);
         if ($data['cate']) {
@@ -213,8 +196,6 @@ class Api extends Core
     # 获取合集下的时光
     public function times()
     {
-        $parent_page_id = Dever::input('parent_page_id');
-        $page_id = Dever::input('page_id');
         $where['info_id'] = $this->id;
         $data['cur'] = $this->times;
         $data['times'] = Dever::db('collection/times')->main($where);
@@ -232,10 +213,12 @@ class Api extends Core
     public function getPageId()
     {
         $where['info_id'] = $this->id;
-        $where = $this->getTimes($where);
+        $where['times_id'] = Dever::input('times_id');
         $page = Dever::db('collection/page')->getOne($where);
         if ($page) {
-            return $page;
+            # 获取code
+            $data['code'] = $this->getCode($this->id, $page['page_id'], $page['id'], 0, $page['times_id']);
+            return $data;
         }
         Dever::alert('error');
     }
@@ -246,7 +229,8 @@ class Api extends Core
         $where['info_id'] = $this->id;
         $where['uid'] = $this->uid;
         $record = Dever::db('collection/user_record')->one($where);
-        $where['page_id'] = Dever::input('page_id');
+        $where['parent_page_id'] = $this->parent_page_id;
+        $where['page_id'] = $this->page_id;
         $where['times_id'] = $this->times;
         $where['content_id'] = Dever::input('content_id');
         $where['index'] = Dever::input('index');
@@ -291,4 +275,53 @@ class Api extends Core
 
         return $data;
     }
+
+    # 获取功能
+    private function getFunc()
+    {
+        $where['info_id'] = $this->id;
+        $func = Dever::db('collection/function')->getAll($where);
+        $result = array();
+        if ($func) {
+            foreach ($func as $k => $v) {
+                $result[$v['type']] = array
+                (
+                    'show' => false,
+                    'index' => 5,
+                    'top' => 0,
+                    'padding' => '0rpx',
+                    'width' => $v['width'],
+                    'direction' => strtolower($v['direction']),
+                    'param' => array(),
+                    'button' => array
+                    (
+                        'bgColor' => $v['bgcolor'],
+                        'text' => $v['name'],
+                        'fontSize' => 28,
+                        'color' => $v['color'],
+                    ),
+                );
+            }
+        }
+
+        return $result;
+    }
+
+    # 获取时光
+    private function getTimes($where)
+    {
+        # 获取当前年份的最新的时光
+        if (!$this->times) {
+            $where['year'] = date('Y');
+            $times = Dever::db('collection/times')->getNew($where);
+            if ($times) {
+                $this->times = $times['id'];
+            }
+        }
+        if ($this->times) {
+            $where['times_id'] = $this->times;
+        }
+
+        return $where;
+    }
 }

+ 6 - 5
app/community/src/Api.php

@@ -3,22 +3,23 @@
 namespace Community\Src;
 
 use Dever;
+use Collection\Lib\Core;
 
-class Api
+class Api extends Core
 {
 	public function __construct()
 	{
-        $this->uid = 1;
-		$this->cate_id = Dever::input('cate_id');
+        $this->cate_id = Dever::input('cate_id');
         $this->type = Dever::input('type', 3);
         $this->type_id = Dever::input('type_id', 1);
+        parent::__construct();
 	}
 
     # 获取社区下的分类
     public function category()
     {
-    	$info_id = Dever::input('info_id');
-    	$page_id = Dever::input('page_id');
+    	$info_id = $this->id;
+    	$page_id = $this->page_id;
         $content_id = Dever::input('content_id');
 
     	# 之后要通过合集id获取名字