Parcourir la source

Merge branch 'talksec' of 121.43.114.153:/home/git/repositories/shopnc into talksec

stanley-king il y a 6 ans
Parent
commit
aab35df572

+ 1 - 0
data/logic/queue.logic.php

@@ -860,6 +860,7 @@ class queueLogic
             return callback(false);
         }
         else {
+            Log::record("OnUpdateRoom Start",Log::DEBUG);
             $ret = room_helper::OnUpdateRoom($roomid);
             return callback($ret);
         }

Fichier diff supprimé car celui-ci est trop grand
+ 2059 - 0
data/resource/mobile/comm/qrcode.js


+ 1 - 0
data/resource/mobile/talk/css/homepage.css

@@ -148,6 +148,7 @@ html,body {
     width: 50px;
     height: 50px;
     border-radius: 5px;
+    border: 1px solid #d5d5d5;
 }
 .quit a{
     background: #2B2B2B;

+ 4 - 2
helper/room/room_processor.php

@@ -14,6 +14,7 @@ use errcode;
 use algorithm;
 use QueueClient;
 use scope_trace;
+use Log;
 
 class room_processor implements IProcessor
 {
@@ -169,8 +170,9 @@ class room_processor implements IProcessor
                         $inviter = $room->userinfos($inviter);
                         $this->broad_access(msg_builder::invited_push($roomid, $newusers,$inviter,$room_info));
                         $this->broadcast_roomsg($room);
-
-                        $last_count = $room->usercount() - count($newusers);
+                        $left = $room->usercount(); $right = count($newusers);
+                        $last_count = $left - $right;
+                        Log::record("ready to update -------$last_count||$left||$right|| ",Log::DEBUG);
                         if($last_count >= 0 && $last_count < 10) {
                             QueueClient::push("OnUpdateRoom",['room_id' => $roomid]);
                         } else {

+ 144 - 97
helper/room/tpl_group_home.php

@@ -24,8 +24,9 @@ class tpl_group_home
     private $cur_user = 0;
     private $room_id = 0;
     private $participants = [];
+    private $relay_id = null;
 
-    public function __construct($user, $room_id)
+    public function __construct($user, $room_id,$relay_id=0)
     {
         if ($room_id <= 0) {
             throw new Exception("聊天参数有误");
@@ -33,6 +34,7 @@ class tpl_group_home
         $this->mod_room = Model('room');
         $this->room_id = $room_id;
         $this->cur_user = intval($user);
+        $this->relay_id = intval($relay_id);
 
         $room = $this->mod_room->getRoom($room_id);
         if(empty($room)) throw new Exception("房间不存在");
@@ -53,6 +55,10 @@ class tpl_group_home
         echo $html;
     }
 
+    public function get_room_info(){
+        return $this->room_info;
+    }
+
     public function show_group_header()
     {
         if($this->room_info->has_name()){
@@ -69,14 +75,18 @@ class tpl_group_home
                 </div>
                 <div class=\"group_name\">
                     <h3>
-                    {$name}";
-                    if($this->room_info->level() > 0) {
-                    $html.= "<span class='certification_logo'></span>";
-                };
-                    $html.= "</h3>";
+                {$name}";
 
-                    $html.= "<p>{$desc}</p>
+        if($this->room_info->level() > 0) {
+            $html.= "<span class='certification_logo'></span>
+                    </h3><p>{$desc}</p>
+                </div>";
+        }else{
+            $html.= "
+                    </h3><p>未认证</p>
                 </div>";
+        }
+
         echo $html;
     }
 
@@ -93,8 +103,8 @@ class tpl_group_home
         $notice = $this->room_info->notice();
         if(empty($notice))
         {
-            $html.= "<div class=\"group_notice_board\" style=\"display: none;\">
-                        <p class=\"text_overflow\"></p>
+            $html.= "<div class=\"group_notice_board\">
+                        <p class=\"text_overflow\">【公告】</p>
                      </div>";
         }
         else
@@ -134,14 +144,22 @@ class tpl_group_home
         return intval($user) === $this->room_info->owner();
     }
 
+    private function isFromQr(){
+        return ($this->relay_id > 0 && isset($this->participants[$this->relay_id]));
+    }
+
     public function show_members()
     {
         $html = '';
 
-        if (!empty($this->participants) && isset($this->participants[$this->cur_user])) {
+        if (!empty($this->participants) && isset($this->participants[$this->cur_user]))
+        {
+            //对内展示
             $i = 1;
             $cnt = count($this->participants);
-            foreach ($this->participants as $uids => $member) {
+
+            foreach ($this->participants as $uids => $member)
+            {
                 if ($i < $cnt) {
                     $div_head = "<div class=\"weui-flex__item member-detail\" data-member-id={$member['userid']}>";
                 } else {
@@ -169,30 +187,53 @@ class tpl_group_home
 
                 $i++;
             }
-        } else {
-            foreach ($this->participants as $uids => $member) {
-                if($this->isManager($member['userid']))
+
+            if (isset($this->participants[$this->cur_user])) {
+                $html .= "<div class=\"weui-flex__item\">
+                        <img src=\"" . RESOURCE_SITE_URL . "/mobile/talk/images/add_member.png\" id=\"add_member\" alt=\"\">
+                      </div>";
+            }
+
+            if ($this->isManager($this->cur_user)) {
+                $html .= "<div class=\"weui-flex__item\">
+                        <img src=\"" . RESOURCE_SITE_URL . "/mobile/talk/images/del_member.png\" id=\"del_member\" alt=\"\">
+                      </div>";
+            }
+
+        }
+        else
+        {
+            //对外展示 有在群中的relay_id则显示对应用户 or 默认管理员
+            if($this->relay_id > 0 && isset($this->participants[$this->relay_id]) )
+            {
+                foreach ($this->participants as $uids => $member)
                 {
-                    $html .=  "<div class=\"weui-flex__item member-detail\" data-member-id={$member['userid']} data-last='true'>
+
+                    if($this->relay_id == $member['userid']) {
+                        $html .=  "<div class=\"weui-flex__item member-detail\" data-member-id={$member['userid']} data-last='true'>
+                                <img src=\"{$member['avatar']}\" alt=\"\">
+                                <p>{$member['nickname']}</p>
+                            </div>";
+                    }
+                }
+            }
+            else
+            {
+                foreach ($this->participants as $uids => $member)
+                {
+                    if($this->isManager($member['userid']))
+                    {
+                        $html .=  "<div class=\"weui-flex__item member-detail\" data-member-id={$member['userid']} data-last='true'>
                                 <img src=\"{$member['avatar']}\" alt=\"\">
                                 <p>{$member['nickname']}</p>
                                 <span class=\"admin\">管理员</span>
                             </div>";
+                    }
                 }
             }
         }
 
-        if (isset($this->participants[$this->cur_user])) {
-            $html .= "<div class=\"weui-flex__item\">
-                        <img src=\"" . RESOURCE_SITE_URL . "/mobile/talk/images/add_member.png\" id=\"add_member\" alt=\"\">
-                      </div>";
-        }
 
-        if ($this->isManager($this->cur_user)) {
-            $html .= "<div class=\"weui-flex__item\">
-                        <img src=\"" . RESOURCE_SITE_URL . "/mobile/talk/images/del_member.png\" id=\"del_member\" alt=\"\">
-                      </div>";
-        }
         echo $html;
     }
 
@@ -228,11 +269,18 @@ class tpl_group_home
             $html.= "<div class=\"weui-cells\">";
             $html.= $this->room_name_btn($click,$name);
             $html.= $this->room_avatar_btn($avartar);
-            $html.= $this->room_cert_btn($click,$level);
+            $html.= $this->room_nickname_btn();
             $html.= "</div>";
 
-            $html.= $this->room_manager_btn($desc,$notice,$apply,$cnt);
 
+            if ($this->isManager($this->cur_user)) {
+                $html .= "<div class=\"weui-cells\">";
+//                $html.= $this->room_desc_btn($desc);
+//                $html.= $this->room_notice_btn($notice);
+                $html.= $this->room_cert_btn($click,$level);
+                $html.= $this->room_apply_btn($apply,$cnt);
+                $html.="</div>";
+            }
         }
         echo $html;
     }
@@ -271,9 +319,7 @@ class tpl_group_home
     }
 
     private function room_cert_btn($click,$level)
-    {   if(!$this->isManager($this->cur_user)){
-            return "";
-        }
+    {
         if($click){
             $html = "<div class=\"weui-cell weui-cell_access\" id=\"group_AC\">
                         <div class=\"weui-cell__bd\">
@@ -292,71 +338,73 @@ class tpl_group_home
         return $html;
     }
 
-    private function room_manager_btn($desc,$notice,$apply,$cnt){
-        if ($this->isManager($this->cur_user))
-        {
-            $html = "<div class=\"weui-cells\">";
-            $html.= "<div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id=\"edit_room_notice\">
-                        <div class=\"weui-cell__bd\">
-                            <p>群公告</p>
-                        </div>
-                        <div class=\"weui-cell__ft\" id=\"room-notice-btn\">{$notice}</div>
-                     </div>
-                    
-                     <div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id=\"edit_room_desc\">
-                        <div class=\"weui-cell__bd\">
-                            <p>群介绍</p>
-                        </div>
-                        <div class=\"weui-cell__ft\" id=\"room-desc-btn\">{$desc}</div>
-                     </div>
-                    ";
+    private function room_notice_btn($notice){
+        $html = "<div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id=\"edit_room_notice\">
+                    <div class=\"weui-cell__bd\">
+                        <p>群公告</p>
+                    </div>
+                    <div class=\"weui-cell__ft\" id=\"room-notice-btn\">{$notice}</div>
+                 </div>";
+        return $html;
+    }
 
-            if ($cnt > 0)
-            {
-                $html.="
-                    <div class=\"weui-cell weui-cell_access\">
-                        <div class=\"weui-cell__bd\">
-                            <p>入群申请</p>
-                        </div>
-                        <div class=\"weui-cell__ft\" id=\"room-apply-btn\" style=\"color: #FF4E4E\">{$apply}</div>
-                    </div>";
-            }
-            else
-            {
-                $html.="
-                    <div class=\"weui-cell weui-cell_access\">
-                        <div class=\"weui-cell__bd\">
-                            <p>入群申请</p>
-                        </div>
-                        <div class=\"weui-cell__ft\">{$apply}</div>
-                    </div>";
-            }
-            $html .="</div>";
-        }else{
-            $html = "";
+    private function room_desc_btn($desc){
+        $html = "<div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id=\"edit_room_desc\">
+                    <div class=\"weui-cell__bd\">
+                        <p>群介绍</p>
+                    </div>
+                    <div class=\"weui-cell__ft\" id=\"room-desc-btn\">{$desc}</div>
+                 </div>";
+        return $html;
+    }
+
+    private function room_apply_btn($apply,$cnt)
+    {
+        if ($cnt > 0)
+        {
+            $html ="
+                <div class=\"weui-cell weui-cell_access\">
+                    <div class=\"weui-cell__bd\">
+                        <p>入群申请</p>
+                    </div>
+                    <div class=\"weui-cell__ft\" id=\"room-apply-btn\" style=\"color: #FF4E4E\">{$apply}</div>
+                </div>";
         }
+        else
+        {
+            $html ="
+                <div class=\"weui-cell weui-cell_access\">
+                    <div class=\"weui-cell__bd\">
+                        <p>入群申请</p>
+                    </div>
+                    <div class=\"weui-cell__ft\">{$apply}</div>
+                </div>";
+        }
+        return $html;
+    }
+
+    private function room_nickname_btn()
+    {
+        $html = "
+        <div class=\"weui-cells\">
+            <div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id='edit_nickname'>
+                <div class=\"weui-cell__bd\">
+                    <p>我在本群的昵称</p>
+                </div>
+                <div class=\"weui-cell__ft group-nickname\">{$this->participants[$this->cur_user]['nickname']}</div>
+            </div>
+        </div>";
 
         return $html;
     }
 
-    public function show_personal_settings()
+    public function change_manager_btn()
     {
         $html = "";
 
         if (!empty($this->participants) && isset($this->participants[$this->cur_user])) {
-            $html .= "
-            <div class=\"weui-cells\">
-                <div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id='edit_nickname'>
-                    <div class=\"weui-cell__bd\">
-                        <p>我在本群的昵称</p>
-                    </div>
-                    <div class=\"weui-cell__ft group-nickname\">{$this->participants[$this->cur_user]['nickname']}</div>
-                </div>
-            </div>";
-        }
-
-        if ($this->isManager($this->cur_user)) {
-            $html .= "
+            if ($this->isManager($this->cur_user)) {
+                $html .= "
             <div class=\"weui-cells\">
                 <div class=\"weui-cell weui-cell_access\" href=\"javascript:;\" id='change_owner' >
                     <div class=\"weui-cell__bd\">
@@ -364,8 +412,8 @@ class tpl_group_home
                     </div>
                 </div>
             </div>";
+            }
         }
-
         echo $html;
     }
 
@@ -465,7 +513,8 @@ class tpl_group_home
         else
         {
             $pwd = $this->room_info->passwd();
-            if($pwd){
+            $from_qr = $this->isFromQr();
+            if($pwd && !$from_qr){
                 $html .= "
                 <div class=\"join_item_btn\">
                    <div class=\"quit\" id=\"add_group_pwd\">
@@ -481,7 +530,7 @@ class tpl_group_home
                 $html .= "
                 <div class=\"join_item_btn\">
                     <div class=\"quit\" id=\"add_group\">
-                        <a href=\"javascript:;\" class=\"weui-btn weui-btn_primary\">立即入群</a>
+                        <a href=\"javascript:;\" class=\"weui-btn weui-btn_primary\" data-relay-id='{$this->relay_id}'>立即入群</a>
                     </div>
                 </div>";
             }
@@ -500,13 +549,13 @@ class tpl_group_home
 //        $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();
+          $url = url_helper::room_detail_url('room',$this->room_id,$this->cur_user);
+//        $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);
-        }
+//        if(!file_exists($save_path)) {
+//            util::qrcode_path($url, $save_path);
+//        }
 
         $html = "<div class=\"qrcode\">
                         <div class=\"qrcode_info\">
@@ -516,9 +565,7 @@ class tpl_group_home
                                 <p>$desc</p>
                             </div>
                         </div>
-                        <div class=\"group_qrcode\">
-                            <img src=\"$qrcode_path\" alt=\"\">
-                        </div>
+                        <div class=\"group_qrcode\" id='show-qrcode' data-qrcode-url=\"{$url}\"></div>
                         <p class=\"prompt\">
                             扫一扫上面的二维码图案。加入群聊
                         </p>

+ 3 - 1
helper/room_helper.php

@@ -88,7 +88,9 @@ class room_helper
             {
                 $info = new member_info($item);
                 if($info->hasAvatar()) {
-                    $result[] = $info->avatar();
+                    $avatar = $info->avatar();
+                    Log::record("avatar_url:{$avatar}");
+                    $result[] = $avatar;
                 }
             }
             catch (Exception $ex) {

+ 10 - 4
helper/url_helper.php

@@ -90,9 +90,12 @@ class url_helper
         $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_invite&client_type=ajax&room_id={$room_id}&relay_id={$relay_id}";
         return $url;
     }
-    public static function room_detail_url($talk_type,$talk_id)
+    public static function room_detail_url($talk_type,$talk_id,$relay_id = 0)
     {
-        $url = BASE_SITE_URL . "/mobile/index.php?act=member_talk&op=room_detail&client_type=wap&talk_type={$talk_type}&talk_id={$talk_id}";
+        if($relay_id <= 0) {
+            $relay_id = session_helper::relay_id();
+        }
+        $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_detail&client_type=wap&talk_type={$talk_type}&talk_id={$talk_id}&relay_id={$relay_id}";
         return $url;
     }
 }
@@ -165,8 +168,11 @@ class author_url
         $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_invite&client_type=ajax&room_id={$room_id}&relay_id={$relay_id}";
         return $url;
     }
-    public static function room_detail_url($talk_type,$talk_id){
-        $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_detail&client_type=wap&talk_type={$talk_type}&talk_id={$talk_id}";
+    public static function room_detail_url($talk_type,$talk_id,$relay_id = 0){
+        if($relay_id <= 0) {
+            $relay_id = session_helper::relay_id();
+        }
+        $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_detail&client_type=wap&talk_type={$talk_type}&talk_id={$talk_id}&relay_id={$relay_id}";
         return $url;
     }
 }

+ 21 - 7
mobile/control/member_talk.php

@@ -487,18 +487,21 @@ class member_talkControl extends mbMemberControl
     {
         $talk_type = trim($_GET['talk_type']);
         $talk_id = intval($_GET['talk_id']);
+        $relay_id = intval($_GET['relay_id']);
         if($talk_id <= 0) {
             return self::outerr(errcode::ErrParamter);
         }
 
         $user = session_helper::memberid();
-        $param = ["talk_type" => $talk_type, "talk_id"   => $talk_id , "member_id" => $user ];
+        $param = ["talk_type" => $talk_type, "talk_id"   => $talk_id , "member_id" => $user,"room_name"=>"","relay_id"=>$relay_id];
 
         if($talk_type == "room")
         {
             $room_id = $talk_id;
             try {
-                $tpl = new room\tpl_group_home($user,$talk_id);
+                $tpl = new room\tpl_group_home($user,$talk_id,$relay_id);
+                $room_name = $tpl->get_room_info()->name();
+                $param["room_name"] = $room_name;
                 return self::outsuccess(['tpl' => $tpl,"param" => $param],'talk/homepage_room');
             } catch (Exception $ex) {
                 Log::record("member_talk.room_detail error: room_id={$room_id} user={$user}",Log::ERR);
@@ -797,6 +800,7 @@ class member_talkControl extends mbMemberControl
     public function send_applyOp()
     {
         $room_id = intval($_GET['room_id']);
+        $relay_id = intval($_GET['relay_id']);
         if($room_id <= 0) {
             return self::outerr(errcode::ErrParamter,"请求失败");
         }
@@ -808,11 +812,20 @@ class member_talkControl extends mbMemberControl
             return self::outerr(errcode::ErrParamter,"房间不存在");
         }
 
+
+        $isFromQr = false;
+        if($relay_id > 0) {
+            $parts = new room\room_parts($room_id);
+            $uids = $parts->allparts();
+            $isFromQr = in_array($relay_id,$uids) ? true : false;
+        }
+
         $pwd = $room['passwd'];
         $owner = $room['room_owner'];
-        if(empty($pwd))
-        {
-            $ret = room\factory_client::instance()->invite($room_id,$owner,[$member]);
+        $inviter = $isFromQr ? $relay_id : $owner;
+        if(empty($pwd) || $isFromQr) {
+            //立即入群
+            $ret = room\factory_client::instance()->invite($room_id,$inviter,[$member]);
             if($ret === false) {
                 return self::outerr(errcode::ErrRoom,"进群失败");
             }
@@ -826,7 +839,7 @@ class member_talkControl extends mbMemberControl
         else
         {
             $apply = intval($_GET['apply']);
-            if(empty($apply))
+            if($apply == 1)
             {
                 if(strtolower(trim($_GET['passwd'])) === strtolower($pwd))
                 {
@@ -846,6 +859,7 @@ class member_talkControl extends mbMemberControl
             }
             else
             {
+                //发送入群申请
                 $msg = trim($_GET['msg']);
                 if(strlen($msg) >= 100){
                     return self::outerr(errcode::ErrParamter,"入群申请过长,请缩短一些");
@@ -920,7 +934,7 @@ class member_talkControl extends mbMemberControl
         return true;
     }
 
-    public function room_applyOp(){
+    public function room_applysOp(){
         return self::outsuccess(null,'talk/room_apply');
     }
 

+ 32 - 4
mobile/templates/default/talk/homepage_room.php

@@ -35,7 +35,7 @@
 
 <?php $output['tpl']->show_group_body(); ?>
 
-<?php $output['tpl']->show_personal_settings(); ?>
+<?php //$output['tpl']->change_manager_btn();  //转让管理员暂时关闭?>
 
 <?php $output['tpl']->show_group_footer(); ?>
 
@@ -52,6 +52,8 @@
         src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/new_bridge.js?<?php echo bonus_version(); ?>"></script>
 <script type="text/javascript"
         src="<?php echo RESOURCE_SITE_URL; ?>/js/ajaxfileupload/ajaxfileupload.js?<?php echo bonus_version(); ?>"></script>
+<script type="text/javascript"
+        src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/qrcode.js"></script>
 <script type="text/javascript">
     $(function () {
 
@@ -59,7 +61,9 @@
 
             var talk_id = "<?php echo $output['param']['talk_id'];   ?>";
 
-            var cur_mid ="<?php echo $output['param']['member_id'];   ?>";
+            var cur_mid = "<?php echo $output['param']['member_id'];  ?>";
+
+            var relay_id = "<?php echo $output['param']['relay_id'];  ?>";
 
             var jsBridge = new Bridge();
 
@@ -572,16 +576,26 @@
                 $.get('/mobile/index.php?act=member_talk&op=send_apply',
                     {
                         room_id: talk_id,
+                        relay_id:relay_id,
                         client_type: 'ajax'
                     }, function (res) {
                         $.hideLoading();
                         var result = JSON.parse(res);
-                        console.log(result);
                         if (result.code != 200) {
                             $.alert(result.message);
                             return;
                         }
-                        $.toast('进入成功',1000);
+                        $.toast('进入成功',1000,function(){
+                            var jsonobject = {
+                                action:"chat_to",
+                                params:{
+                                    talk_type:"room",
+                                    talk_id:talk_id,
+                                    name:'<?php echo str_replace("'","",$output['param']['room_name'])?>'
+                                }
+                            };
+                            jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
+                        });
                     });
             });
 
@@ -596,6 +610,7 @@
                             $.get('/mobile/index.php?act=member_talk&op=send_apply',
                                 {
                                     passwd :input,
+                                    relay_id:relay_id,
                                     room_id: talk_id,
                                     client_type: 'ajax'
                                 }, function (res) {
@@ -632,6 +647,7 @@
                                     apply:1,
                                     msg :input,
                                     room_id: talk_id,
+                                    relay_id:relay_id,
                                     client_type: 'ajax'
                                 }, function (res) {
                                     $.hideLoading();
@@ -763,6 +779,18 @@
             $("#room-apply-btn").on('click',function () {
                 window.location.href = "/mobile/index.php?act=member_talk&op=room_apply&talk_id="+talk_id;
             })
+
+
+            var make_qrcode = function () {
+                var typeNumber = 10;
+                var errorCorrectionLevel = 'L';
+                var qrCode = qrcode(typeNumber, errorCorrectionLevel);
+                qrCode.addData(document.getElementById('show-qrcode').getAttribute('data-qrcode-url'));
+                qrCode.make();
+                document.getElementById('show-qrcode').innerHTML = qrCode.createImgTag(3,2);
+            }
+
+            make_qrcode();
         }
     );
 </script>