mod_room = Model('room'); $this->room_id = $room_id; $this->cur_user = intval($user); $room = $this->mod_room->getRoom($room_id); if(empty($room)) throw new Exception("房间不存在"); $this->room_info = new room_info($room); if(empty($this->room_info)) throw new Exception("聊天参数有误"); $this->participants = factory::participants($this->room_id); } public function show_cover() { $html = ""; $url = RESOURCE_SITE_URL. "/mobile/talk/images/cover.png"; $html.="
\"cover\"
"; echo $html; } public function show_group_header() { if($this->room_info->has_name()){ $name = $this->room_info->name(); }else{ $name = "未命名"; } $avartar = $this->room_info->avatar(); $desc = $this->room_info->room_desc(); $html ="
\"group_avatar\"

{$name}"; if($this->room_info->level() > 0) { $html.= ""; }; $html.= "

"; $html.= "

{$desc}

"; echo $html; } public function show_qrcode_btn() { if(isset($this->participants[$this->cur_user])){ echo "
"; } } public function show_group_notice() { $html = ""; $notice = $this->room_info->notice(); if(empty($notice)) { $html.= "

"; } else { $html.= "

【公告】{$notice}

"; } echo $html; } public function show_group_activity() { $html = ""; if(isset($this->participants[$this->cur_user])){ $html.="
room_id}\"> \"\"
room_id}\"> \"\"
room_id}\"> \"\"
"; } echo $html; } private function isManager($user) { return intval($user) === $this->room_info->owner(); } public function show_members() { $html = ''; if (!empty($this->participants) && isset($this->participants[$this->cur_user])) { $i = 1; $cnt = count($this->participants); foreach ($this->participants as $uids => $member) { if ($i < $cnt) { $div_head = "
"; } else { $div_head = "
"; } if($this->isManager($uids)) { $head = "\"\"

{$member['nickname']}

管理员
"; $html = $div_head . $head . $html; } else { $html .= $div_head; $html .= " \"\"

{$member['nickname']}

"; } $i++; } } if (isset($this->participants[$this->cur_user])) { $html .= "
\"\"
"; } if ($this->isManager($this->cur_user)) { $html .= "
\"\"
"; } echo $html; } public function show_group_body() { $html = ""; if (!empty($this->room_info) && isset($this->participants[$this->cur_user])) { $avartar = $this->room_info->avatar(); $name = $this->room_info->has_name() ? $this->room_info->name() : "未命名"; $notice = empty($this->room_info->notice()) ? "未设置" : "已设置"; $desc = empty($this->room_info->room_desc()) ? "未设置" : "已设置"; $cnt = $this->mod_room->applyCnts(['room_id'=>$this->room_id,"step"=>0]); $apply = $cnt > 0 ? "待处理" . $cnt : "暂无申请"; $click = false; $level = "已认证"; if($this->room_info->level() == 0) { $certs = $this->mod_room->findCert(["room_id"=>$this->room_id]); if(!empty($certs)) { if($certs['cstatus'] == 0) { $level = "待审核"; }elseif($certs['cstatus'] == 2 || $certs['cstatus'] == 3){ $click = true; $level = "待修改"; } }else{ $click = true; $level = "未认证"; } } $html.= "
"; $html.= $this->room_name_btn($click,$name); $html.= $this->room_avatar_btn($avartar); $html.= $this->room_cert_btn($click,$level); $html.= "
"; $html.= $this->room_manager_btn($desc,$notice,$apply,$cnt); } echo $html; } private function room_name_btn($click,$name) { if($click){ $html = "

群名称

{$name}
"; } else { $html = "

群名称

{$name}
"; } return $html; } private function room_avatar_btn($avartar){ $html = "

群头像

"; return $html; } private function room_cert_btn($click,$level) { if(!$this->isManager($this->cur_user)){ return ""; } if($click){ $html = "

群认证

{$level}
"; }else{ $html = "

群认证

{$level}
"; } return $html; } private function room_manager_btn($desc,$notice,$apply,$cnt){ if ($this->isManager($this->cur_user)) { $html = "
"; $html.= "

群公告

{$notice}

群介绍

{$desc}
"; if ($cnt > 0) { $html.="

入群申请

{$apply}
"; } else { $html.="

入群申请

{$apply}
"; } $html .="
"; }else{ $html = ""; } return $html; } public function show_personal_settings() { $html = ""; if (!empty($this->participants) && isset($this->participants[$this->cur_user])) { $html .= "

我在本群的昵称

{$this->participants[$this->cur_user]['nickname']}
"; } if ($this->isManager($this->cur_user)) { $html .= "

转让管理员

"; } echo $html; } public function show_group_footer() { $html = ""; if(isset($this->participants[$this->cur_user])) { $html .="
"; if ($this->isManager($this->cur_user)) { $pwd = $this->room_info->passwd(); if($pwd) { $html .= "

群密码

"; } else { $html .= "

群密码

"; } } $html .="

置顶聊天

消息免打扰

"; } if(isset($this->participants[$this->cur_user])) { $html.="

清空聊天记录

"; } echo $html; } public function show_footer_btn() { $html = ""; if (isset($this->participants[$this->cur_user])) { if($this->isManager($this->cur_user)) { //todo 解散群按钮 } else { $html .= "
删除并退出
"; } } else { $pwd = $this->room_info->passwd(); if($pwd){ $html .= "
密码入群
申请加群
"; } else { $html .= "
立即入群
"; } } echo $html; } public function show_qrcode() { $name = $this->room_info->name(); if(strlen($name) > 18) $name =mb_substr($name,0,6,'utf8')."..."; $avatar = $this->room_info->avatar(); $desc = $this->room_info->room_desc(); // $url = url_helper::room_invite_url($this->room_id,$this->cur_user); // $save_path = BASE_UPLOAD_PATH."/room/qrcodes/{$this->room_id}_{$this->cur_user}.png"; // $qrcode_path = BASE_SITE_URL . "/data/upload/room/qrcodes/{$this->room_id}_{$this->cur_user}.png?v=" . time(); $url = author_url::room_detail_url('room',$this->room_id); $save_path = BASE_UPLOAD_PATH."/room/qrcodes/{$this->room_id}.png"; $qrcode_path = BASE_SITE_URL . "/data/upload/room/qrcodes/{$this->room_id}.png?v=" . time(); if(!file_exists($save_path)) { util::qrcode_path($url, $save_path); } $html = "
\"\"

$name

$desc

\"\"

扫一扫上面的二维码图案。加入群聊

"; echo $html; } }