|
@@ -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;
|
|
|
+ }
|
|
|
}
|