huangdong 6 years ago
parent
commit
4e7e059ef2

File diff suppressed because it is too large
+ 2059 - 0
data/resource/mobile/comm/qrcode.js


+ 59 - 28
helper/room/tpl_group_home.php

@@ -24,6 +24,7 @@ class tpl_group_home
     private $cur_user = 0;
     private $room_id = 0;
     private $participants = [];
+    private $relay_id = 0;
 
     public function __construct($user, $room_id)
     {
@@ -97,8 +98,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
@@ -138,14 +139,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 {
@@ -173,30 +182,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)
+                {
+
+                    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)
                 {
-                    $html .=  "<div class=\"weui-flex__item member-detail\" data-member-id={$member['userid']} data-last='true'>
+                    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;
     }
 
@@ -469,7 +501,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\">
@@ -485,7 +518,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>";
             }
@@ -505,12 +538,12 @@ class tpl_group_home
 //        $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();
+//        $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\">
@@ -520,9 +553,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>

+ 2 - 1
helper/url_helper.php

@@ -166,7 +166,8 @@ class author_url
         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}";
+        $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;
     }
 }

+ 14 - 0
mobile/templates/default/talk/homepage_room.php

@@ -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 () {
 
@@ -772,6 +774,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>