where('status',1)->order('weight desc,id desc')->autopage()->select(); $list = list_domain_image($list,['image']); $this->success('success',$list); } //某个圈子详情 /*public function info_old(){ $id = input('id',0); $info = Db::name('topic_hub')->where(['status'=>1,'id'=>$id])->find(); $info = info_domain_image($info,['image']); //圈子成员 $user_list = Db::name('topic_user')->alias('tp') ->field('tp.user_id,user.avatar,user.nickname,user.gender,user.cityname,user.longitude,user.latitude') ->join('user','tp.user_id = user.id','LEFT') ->where('topic_id',$id)->autopage()->select(); $user_list = list_domain_image($user_list,['avatar']); $info['userlist'] = $user_list; //我是否已加入 $isjoin = Db::name('topic_user')->where(['topic_id'=>$id,'user_id'=>$this->auth->id])->find(); $info['isjoin'] = $isjoin ? 1 : 0; $this->success('success',$info); }*/ public function info(){ $id = input('id',0); $info = Db::name('topic_hub')->where(['status'=>1,'id'=>$id])->find(); $info = info_domain_image($info,['image']); $this->success('success',$info); } //加入某个圈子 /*public function join_topic(){ $id = input('topic_id',0); if(empty($id)){ $this->error(); } $check = Db::name('topic_user')->where(['user_id'=>$this->auth->id,'topic_id'=>$id])->find(); if($check){ $this->error('已经关注了此圈子'); } $data = [ 'user_id' => $this->auth->id, 'topic_id'=> $id, ]; Db::startTrans(); $new_id = Db::name('topic_user')->insertGetId($data); $rs = Db::name('topic_hub')->where('id',$id)->setInc('p_number'); if($new_id && $rs){ Db::commit(); $this->success(); } Db::rollback(); $this->error('操作失败'); }*/ //退出某个圈子 /*public function leave_topic(){ $id = input('topic_id',0); if(empty($id)){ $this->error(); } $check = Db::name('topic_user')->where(['user_id'=>$this->auth->id,'topic_id'=>$id])->find(); if(!$check){ $this->error('没有关注此圈子'); } Db::startTrans(); $del = Db::name('topic_user')->where(['user_id'=>$this->auth->id,'topic_id'=>$id])->delete(); $rs = Db::name('topic_hub')->where('id',$id)->setDec('p_number'); if($del && $rs){ Db::commit(); $this->success(); } Db::rollback(); $this->error('操作失败'); }*/ //我的圈子列表 /*public function my_lists(){ $list = Db::name('topic_user')->alias('tu') ->field('th.*') ->join('topic_hub th','tu.topic_id = th.id','LEFT') ->where(['tu.user_id' => $this->auth->id,'th.status'=>1])->order('tu.id desc,th.weight desc,th.id desc')->autopage()->select(); $list = list_domain_image($list,['image']); $this->success('success',$list); }*/ //热门圈子。头部圈子N个,每个圈子拿出最热的一个(评论最多的一个) public function top_list(){ $list = Db::name('topic_hub')->field('id,name')->where(['status'=>1])->order('weight desc,p_number desc,t_number desc')->autopage()->select(); if(empty($list)){ $this->success('success',$list); } foreach($list as $key => $val){ $child = Db::name('topic_dongtai')->alias('dt') ->field('dt.id,dt.content,dt.images,user.nickname') ->join('user','dt.user_id = user.id','LEFT') ->where('dt.topic_id',$val['id']) ->order('goodnum desc')->find(); $child = info_domain_image($child,['images']); if(!empty($child)){ $child['images'] = explode(',',$child['images'])[0]; } $list[$key]['child'] = $child; } $this->success('success',$list); } //某个圈子里的动态列表,全部,最新,最热 //放到 topicdongtai.php里了 //热门话题 public function hottopic() { $list = Db::name('topic_hub')->field('id, name, image, t_number, icon_type')->where('status',1)->order('weight desc,id desc')->autopage()->select(); $list = list_domain_image($list,['image']); if ($list) { $where['a.status'] = 0; //是否已删除:0=否,1=是 $where['a.auit_status'] = 1; //审核状态:0=待审核,1=通过,2=拒绝 $where['user.is_kefu'] = 0; if ($this->auth->gender == 1) { //男看女 $where['user.gender'] = 0; } elseif ($this->auth->gender == 0) { //女看男 $where['user.gender'] = 1; } else { $this->success('success', []); } $mt_topic_dongtai = Db::name('topic_dongtai a'); foreach ($list as &$v) { $where['a.topic_id'] = $v['id']; $v['t_number'] = $mt_topic_dongtai ->join('mt_user user', 'a.user_id = user.id', 'left') ->where($where)->count('a.id'); } } $this->success('success',$list); } //热门话题详情 public function hottopicinfo() { $id = input('id', 0, 'intval'); //热门话题id $info = Db::name('topic_hub')->field('id, name, info, image, t_number, icon_type')->where(['status'=>1,'id'=>$id])->find(); if (!$info) { $this->error('您的网络开小差了~'); } $info = info_domain_image($info,['image']); if ($info) { $where['a.status'] = 0; //是否已删除:0=否,1=是 $where['a.auit_status'] = 1; //审核状态:0=待审核,1=通过,2=拒绝 $where['user.is_kefu'] = 0; if ($this->auth->gender == 1) { //男看女 $where['user.gender'] = 0; } elseif ($this->auth->gender == 0) { //女看男 $where['user.gender'] = 1; } else { $this->success('success', []); } $mt_topic_dongtai = Db::name('topic_dongtai a'); $where['a.topic_id'] = $info['id']; $info['t_number'] = $mt_topic_dongtai ->join('mt_user user', 'a.user_id = user.id', 'left') ->where($where)->count('a.id'); } $this->success('success',$info); } }