123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <?php
- namespace Content\V1;
- use Dever;
- use Content\Lib\Base;
- class News extends Base
- {
-
-
- public function index_api()
- {
-
- $this->data['cate'] = Dever::load('set/cate-one', $this->data['info']['cate_id']);
- if ($this->data['cate']) {
-
-
- $this->data['cate_child'] = Dever::load('set/cate-getAll', array('option_cate_id' => $this->data['cate']['id']));
- foreach($this->data['cate_child'] as $k => $v) {
- $this->data['cate_child'][$k]['pic'] = $this->replacePic($v['pic']);
- }
- if ($this->data['cate_child'] && isset($this->data['cate_child'][0])) {
- $news = Dever::load('content/news-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $this->data['cate_child'][0]['id']));
- if ($news) {
- foreach ($news as $k => $v) {
- $v['cdate'] = date('m-d', $v['cdate']);
- $this->data['cate_child'][0]['news'][$k] = $this->one($v, 2);
- }
- }
- }
- }
- return $this->data;
- }
- private function focus($cate)
- {
- $this->data['focus'] = Dever::load('content/focus-getAll', array('option_cate_id_parent' => $cate));
- if ($this->data['focus']) {
- foreach ($this->data['focus'] as $k => $v) {
- $this->data['focus'][$k]['pic'] = $this->replacePic($v['pic']);
- }
- }
- }
-
- public function list_api()
- {
- $cateid = Dever::input('cateid');
- if ($cateid > 0) {
- $cate = Dever::load('set/cate-one', $cateid);
- $this->data['news'] = array();
- if ($cate) {
- $this->data['news'] = Dever::load('content/news-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $cate['id']));
- if ($this->data['news']) {
- foreach ($this->data['news'] as $k => $v) {
- $this->data['news'][$k] = $this->one($v, 2);
- }
- }
- }
- }
- return $this->data;
- }
-
- public function view_api()
- {
- $id = Dever::input('id');
- if ($id > 0) {
- $this->data['news'] = Dever::load('content/news-one', $id);
- if ($this->data['news']) {
- $this->data['news'] = $this->one($this->data['news'], 2);
-
- Dever::load('content/news-addView', $id);
- } else {
- Dever::alert('错误的资讯id');
- }
- } else {
- Dever::alert('错误的资讯id');
- }
- $this->data['vote'] = $this->vote(1, $id);
- return $this->data;
- }
- }
|