dever 4 years ago
parent
commit
29a95e029b

+ 17 - 1
app/community/database/up.php

@@ -111,9 +111,25 @@ return array
 				'state' => 1,
 			),
 			'type' => 'all',
-			'order' => array('id' => 'desc'),
+			'order' => array('cdate' => 'desc'),
 			'page' => array(15, 'list'),
 			'col' => 'uid,type,type_id,cdate',
 		),
+
+		'getHot' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('cdate' => 'desc'),
+			'limit' => '0,10',
+			'col' => '*',
+		),
 	)
 );

+ 23 - 0
app/community/lib/Core.php

@@ -31,6 +31,29 @@ class Core
         return $info;
     }
 
+    # 获取当前的点赞名单
+    public function getData($id, $type, $collection_id)
+    {
+        $where['type'] = $type;
+        $where['type_id'] = $id;
+        $info = Dever::db($this->table)->getHot($where);
+        
+        $result = array();
+        if ($info) {
+            foreach ($info as $k => $v) {
+                $user = Dever::load('user/lib/info')->get($v['uid'], $collection_id, true);
+                $result[] = array
+                (
+                    'id' => $user['id'],
+                    'username' => $user['username'],
+                    'author' => $user['author'],
+                );
+            }
+        }
+
+        return $result;
+    }
+
     # 更新提交数据
     public function submit($uid, $id, $type, $data = array())
     {

+ 9 - 3
app/community/lib/Moment.php

@@ -107,6 +107,7 @@ class Moment
 
     private function one($uid, $info, $times = false, $collection_id = false)
     {
+        $key = 30;
         $info['pic'] = explode(',', $info['pic']);
         $info['user'] = Dever::load('user/lib/info')->get($info['uid'], $collection_id, true);
         
@@ -114,6 +115,11 @@ class Moment
 
         # 点赞数
         $info['num_up'] = $info['num_up'] + 0;
+        $info['up_list'] = array();
+        if ($info['num_up'] > 0) {
+            # 批量获取最新的点赞名单
+            $info['up_list'] = Dever::load('community/lib/up')->getData($info['id'], $key, $collection_id);
+        }
 
         # 反对数
         $info['num_oppose'] = $info['num_oppose'] + 0;
@@ -122,10 +128,10 @@ class Moment
 
         if ($uid) {
             # 是否点赞
-            $info['is_up'] = Dever::load('community/lib/up')->get($uid, $info['id'], 20);
+            $info['is_up'] = Dever::load('community/lib/up')->get($uid, $info['id'], $key);
 
             # 是否反对
-            $info['is_oppose'] = Dever::load('community/lib/oppose')->get($uid, $info['id'], 20);
+            $info['is_oppose'] = Dever::load('community/lib/oppose')->get($uid, $info['id'], $key);
         }
 
         # 评论数
@@ -140,7 +146,7 @@ class Moment
         # 获取热门的子信息
         $info['child'] = array();
         if ($info['type'] < 20) {
-            $child = $this->getData('getHot', $uid, 30, $info['id'], true, 1, false, false, $collection_id);
+            $child = $this->getData('getHot', $uid, $key, $info['id'], true, 1, false, false, $collection_id);
             if ($child && $child['info']) {
                 $info['child'] = $child['info'];
                 $info['child_total'] = $child['total'];

+ 1 - 0
app/community/src/Api.php

@@ -60,6 +60,7 @@ class Api extends Core
     {
         $id = Dever::input('info_id');
         $data = Dever::load('community/lib/moment')->getData('getAll', $this->uid, $this->type, $this->type_id, false, $id, $this->times, $this->day, $this->id);
+        $data['user'] = $this->user;
         return $data;
     }