1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace Main\Src;
- use Dever;
- use Main\Lib\Core;
- class View extends Core
- {
- # 获取评论列表
- public function comment()
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的ID');
- }
- $type = Dever::input('type');
- if (!$type) {
- Dever::alert('错误的类型');
- }
- $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type);
- return $this->data;
- }
- private function get($method, $name, $type = 1)
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的'.$name.'ID');
- }
- $this->data['info'] = Dever::load($method)->get($id);
- if (!$this->data['info']) {
- Dever::alert('错误的'.$name.'ID');
- }
- # 获取评论列表
- $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type);
- # 获取相关推荐
- $this->data['relation'] = Dever::load($method)->getRelation($this->data['info']);
- if ($this->data['relation']) {
- foreach ($this->data['relation'] as $k => $v) {
- $this->data['relation'][$k] = $this->getInfo($type, $v);
- }
- }
- # 获取当前用户分享数
- if ($this->data['uid'] > 0) {
- $this->data['share'] = Dever::load('act/lib/share')->getRefluxNum($this->data['uid'], $id, $type);
- } else {
- $this->data['share'] = 0;
- }
-
- # 浏览量+1
- Dever::load($method)->addView($id);
- return $this->data;
- }
- # 获取图文详情
- public function article()
- {
- return $this->get('content/lib/article', '图文', 1);
- }
- # 获取视频详情
- public function vod()
- {
- return $this->get('video/lib/vod', '视频', 2);
- }
- # 获取直播详情
- public function live()
- {
- return $this->get('video/lib/live', '直播', 3);
- }
- }
|