|
@@ -295,6 +295,8 @@ class Topicdongtai extends Api
|
|
|
$info['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
}
|
|
|
|
|
|
+ //是否收藏
|
|
|
+ $info['is_collect'] = $this->is_collect($id,$this->auth->id);
|
|
|
|
|
|
$this->success('success',$info);
|
|
|
}
|
|
@@ -525,7 +527,7 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $this->success(1,$floor_list);
|
|
|
+ $this->success('success',$floor_list);
|
|
|
}
|
|
|
|
|
|
//单独某一层的详细
|
|
@@ -539,7 +541,7 @@ class Topicdongtai extends Api
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
->where(['a.id'=>$answer_id])->find();
|
|
|
if(empty($floor_info)){
|
|
|
- $this->success(1,[]);
|
|
|
+ $this->success('success',[]);
|
|
|
}
|
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
|
$floor_info['createtime'] = get_last_time($floor_info['createtime']);
|
|
@@ -799,8 +801,156 @@ class Topicdongtai extends Api
|
|
|
->where('msg.user_id',$this->auth->id)->autopage()->select();
|
|
|
$list = list_domain_image($list,['avatar']);
|
|
|
|
|
|
- $this->success(1,$list);
|
|
|
+ $this->success('success',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //删除动态
|
|
|
+ public function delete() {
|
|
|
+ $id = input('id', 0, 'intval');
|
|
|
+ if (!$id) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+ $info = Db::name('topic_dongtai')->find($id);
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+ if ($info['user_id'] != $this->auth->id) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = Db::name('topic_dongtai')->where(['id' => $id])->setField('status', 1);
|
|
|
+ if (!$rs) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('删除成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //举报
|
|
|
+ public function report(){
|
|
|
+ $dt_id = input('dt_id',0);
|
|
|
+
|
|
|
+ $check = Db::name('topic_dongtai')->where('id',$dt_id)->find();
|
|
|
+ if(empty($check)){
|
|
|
+ $this->error('不存在的动态');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['dt_id'] = $dt_id;
|
|
|
+ $data['user_id'] = $this->auth->id;
|
|
|
+ $data['to_user_id'] = $check['user_id'];
|
|
|
+ $data['createtime'] = time();
|
|
|
+
|
|
|
+ Db::name('topic_dongtai_report')->insertGetId($data);
|
|
|
+ $this->success('举报成功');
|
|
|
}
|
|
|
+
|
|
|
+ //收藏,取消收藏
|
|
|
+ public function collect(){
|
|
|
+ $where = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'table' => 'topic_dongtai',
|
|
|
+ 'table_id' => input('id',0),
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_collect')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ Db::name('user_collect')->where($where)->delete();
|
|
|
+ $this->success('已取消收藏');
|
|
|
+ }else{
|
|
|
+ Db::name('user_collect')->insertGetId($where);
|
|
|
+ $this->success('收藏成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //我的收藏
|
|
|
+ public function my_collect(){
|
|
|
+
|
|
|
+ $collect_id = Db::name('user_collect')->where(['table'=>'topic_dongtai','user_id'=>$this->auth->id])->column('table_id');
|
|
|
+ $where = ['dt.id'=>['IN',$collect_id]];
|
|
|
+
|
|
|
+ $where['dt.status'] = 0;
|
|
|
+ $where['dt.auit_status'] = 1;
|
|
|
+ $orderby = 'dt.id desc';
|
|
|
+
|
|
|
+ $list = Db::name('topic_dongtai')->alias('dt')
|
|
|
+ ->join('user','dt.user_id = user.id','LEFT')
|
|
|
+ ->join('user_wallet uw','user.id = uw.user_id','LEFT')
|
|
|
+ ->join('topic_hub th','dt.topic_id = th.id','LEFT')
|
|
|
+ ->field('dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.idcard_status,user.real_status,user.is_hideaddress,th.name,uw.vip_endtime')
|
|
|
+ ->where($where)
|
|
|
+ ->order($orderby)->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['images','avatar']);
|
|
|
+
|
|
|
+ //追加是否点赞
|
|
|
+ if(!empty($list)){
|
|
|
+ $ids = array_column($list,'id');
|
|
|
+ $map = [
|
|
|
+ 'dt_id' => ['IN',$ids],
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ $good_list = Db::name('topic_dongtai_good')->where($map)->select();
|
|
|
+ $mt_user_greet = Db::name('user_greet'); //是否打过招呼
|
|
|
+ $mt_gift_user_dongtai = Db::name('gift_user_dongtai');
|
|
|
+
|
|
|
+
|
|
|
+ foreach ($list as &$val) {
|
|
|
+ $val['name'] = $val['name'] ? : '';
|
|
|
+ $val['birthday'] = birthtime_to_age($val['birthday']);
|
|
|
+ $val['createtime'] = get_last_time($val['createtime']);
|
|
|
+ $val['cityname'] = $val['is_hideaddress'] ? '' : $val['address'];
|
|
|
+
|
|
|
+ //用户vip
|
|
|
+ $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0;
|
|
|
+ unset($val['vip_endtime']);
|
|
|
+
|
|
|
+ //是否点过赞:0否 1是
|
|
|
+ $val['isgood'] = 0;
|
|
|
+ foreach($good_list as $k => $v){
|
|
|
+ if($val['id'] == $v['dt_id']){
|
|
|
+ $val['isgood'] = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //礼物数量
|
|
|
+ $val['gift_count'] = $mt_gift_user_dongtai->where(['dt_id' => $val['id']])->count('id');
|
|
|
+ //查询是否打过招呼
|
|
|
+ $count = $mt_user_greet->where(['user_id' => $this->auth->id, 'user_to_id' => $val['user_id']])->count('id');
|
|
|
+ if ($count) {
|
|
|
+ $val['is_chat'] = 1; //是否打过招呼: 1是 0否
|
|
|
+ } else {
|
|
|
+ $val['is_chat'] = 0; //是否打过招呼: 1是 0否
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建视频缩略图
|
|
|
+ $val['images_thumb'] = '';
|
|
|
+ if ($val['type'] == 2) {
|
|
|
+ $images_url = explode('.', $val['images']);
|
|
|
+ unset($images_url[count($images_url) - 1]);
|
|
|
+ $val['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //动态是否收藏
|
|
|
+ private function is_collect($dt_id,$uid){
|
|
|
+ $where = [
|
|
|
+ 'user_id' => $uid,
|
|
|
+ 'table' => 'topic_dongtai',
|
|
|
+ 'table_id' => $dt_id,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_collect')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//动态收到礼物列表
|
|
@@ -878,26 +1028,4 @@ class Topicdongtai extends Api
|
|
|
|
|
|
$this->success('success', $list);
|
|
|
}
|
|
|
-
|
|
|
- //删除动态
|
|
|
- public function deldongtai() {
|
|
|
- $id = input('id', 0, 'intval');
|
|
|
- if (!$id) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
- $info = Db::name('topic_dongtai')->find($id);
|
|
|
- if (!$info) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
- if ($info['user_id'] != $this->auth->id) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
-
|
|
|
- $rs = Db::name('topic_dongtai')->where(['id' => $id])->setField('status', 1);
|
|
|
- if (!$rs) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('删除成功');
|
|
|
- }
|
|
|
}
|