Api.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. namespace Community\Src;
  3. use Dever;
  4. use Collection\Lib\Core;
  5. class Api extends Core
  6. {
  7. public function __construct()
  8. {
  9. $this->cate_id = Dever::input('cate_id');
  10. $this->type = Dever::input('type', 3);
  11. $this->type_id = Dever::input('type_id', 1);
  12. parent::__construct();
  13. }
  14. # 获取社区下的分类
  15. public function category()
  16. {
  17. $info_id = $this->id;
  18. $page_id = $this->page_id;
  19. $content_id = Dever::input('content_id');
  20. # 之后要通过合集id获取名字
  21. $cate_data = Dever::db('community/cate')->getAll();
  22. $where['info_id'] = $info_id;
  23. $community = Dever::db('collection/community')->one($where);
  24. $data['cate'] = array();
  25. if ($community && $community['cate']) {
  26. $cate = $community['cate'];
  27. $cate = explode(',', $cate);
  28. $cate_name = explode(',', $community['cate_name']);
  29. $i = 0;
  30. foreach ($cate_data as $k => $v) {
  31. if (in_array($v['id'], $cate)) {
  32. if (isset($cate_name[$i]) && $cate_name[$i]) {
  33. $v['name'] = $cate_name[$i];
  34. }
  35. $data['cate'][$i] = $v;
  36. $i++;
  37. }
  38. }
  39. }
  40. return $data;
  41. }
  42. # 获取社区下的帖子
  43. public function info()
  44. {
  45. $id = Dever::input('info_id');
  46. $data = Dever::load('community/lib/info')->getData('getAll', $this->uid, $this->cate_id, $this->type, $this->type_id, false, $id, $this->times, $this->day, $this->id);
  47. return $data;
  48. }
  49. # 获取弹幕、评论
  50. public function comment()
  51. {
  52. $user = Dever::input('user', false);
  53. $data = Dever::load('community/lib/comment')->getData('getAll', $this->uid, $this->type, $this->type_id, $user, $this->id);
  54. return $data;
  55. }
  56. # 获取聊天泡泡
  57. public function tips()
  58. {
  59. $user = Dever::input('user', false);
  60. $data = Dever::load('community/lib/tips')->getData('getAll', $this->uid, $this->type, $this->type_id, $user, $this->id);
  61. return $data;
  62. }
  63. # 发布弹幕、评论
  64. public function addComment()
  65. {
  66. $pic = Dever::input('pic');
  67. $playtime = Dever::input('playtime');
  68. $content = Dever::input('content');
  69. if (!$content) {
  70. Dever::alert('请填写内容');
  71. }
  72. $type_id = Dever::input('type_id');
  73. if (!$type_id) {
  74. Dever::alert('错误的信息');
  75. }
  76. $type = Dever::input('type');
  77. if (!$type) {
  78. Dever::alert('错误的信息');
  79. }
  80. Dever::load('community/lib/comment')->submit($this->uid, $type_id, $type, $pic, $content, $playtime, 'collection/info', $this->id);
  81. return 'yes';
  82. }
  83. # 发布聊天泡泡
  84. public function addTips()
  85. {
  86. $pic = Dever::input('pic');
  87. $playtime = Dever::input('playtime');
  88. $content = Dever::input('content');
  89. if (!$content) {
  90. Dever::alert('请填写内容');
  91. }
  92. $type_id = Dever::input('type_id');
  93. if (!$type_id) {
  94. Dever::alert('错误的信息');
  95. }
  96. $type = Dever::input('type');
  97. if (!$type) {
  98. Dever::alert('错误的信息');
  99. }
  100. $seat = Dever::db('user/seat')->one($type_id);
  101. if (!$seat || $seat['uid'] != $this->uid) {
  102. Dever::alert('这不是您的座位');
  103. }
  104. Dever::load('community/lib/tips')->submit($this->uid, $type_id, $type, $pic, $content, $playtime, 'collection/info', $this->id);
  105. return 'yes';
  106. }
  107. # 发布信息
  108. public function add()
  109. {
  110. $pic = Dever::input('pic');
  111. $content = Dever::input('content');
  112. if (!$content) {
  113. Dever::alert('请填写内容');
  114. }
  115. $cate_id = Dever::input('cate_id');
  116. if (!$cate_id) {
  117. Dever::alert('错误的信息');
  118. }
  119. $type_id = Dever::input('type_id');
  120. if (!$type_id) {
  121. Dever::alert('错误的信息');
  122. }
  123. $type = Dever::input('type');
  124. if (!$type) {
  125. Dever::alert('错误的信息');
  126. }
  127. $to_id = Dever::input('to_id');
  128. $to_uid = Dever::input('to_uid');
  129. Dever::load('community/lib/info')->submit($this->uid, $cate_id, $type_id, $type, $pic, $content, $to_id, $to_uid, $this->day, 'collection/info', $this->id);
  130. return 'yes';
  131. }
  132. # 点赞
  133. public function up()
  134. {
  135. $id = Dever::input('id');
  136. if (!$id) {
  137. Dever::alert('错误的信息');
  138. }
  139. $type = Dever::input('type', 20);
  140. if (!$type) {
  141. Dever::alert('错误的信息');
  142. }
  143. Dever::load('community/lib/up')->submit($this->uid, $id, $type);
  144. return 'yes';
  145. }
  146. # 反对
  147. public function oppose()
  148. {
  149. $id = Dever::input('id');
  150. if (!$id) {
  151. Dever::alert('错误的信息');
  152. }
  153. $type = Dever::input('type', 20);
  154. if (!$type) {
  155. Dever::alert('错误的信息');
  156. }
  157. Dever::load('community/lib/oppose')->submit($this->uid, $id, $type);
  158. return 'yes';
  159. }
  160. }