From 8de9ab764e7e19212132d5268f8d524524712322 Mon Sep 17 00:00:00 2001
From: pengda <10266652509@qq.com>
Date: Tue, 25 Mar 2025 10:16:34 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 config/define.php                   |   9 ++
 control/callback.php                |  15 +++
 control/index.php                   |  70 +++++++++--
 data/dUser.php                      |  10 +-
 model/mManage.php                   |  67 +++++++++--
 model/mUser.php                     |  87 ++++++--------
 view/css/common.css                 |  77 +++++++++++-
 view/css/index.css                  |  75 ------------
 view/css/subCount.css               |   3 +-
 view/js/subCount.js                 | 223 +++++++++++++++++++----------------
 view/templates/include/header.html  |   2 +-
 view/templates/index/login.html     |   7 +-
 view/templates/index/subCount.html  | 113 ------------------
 view/templates/index/user_list.html | 229 +++++++++++++++---------------------
 14 files changed, 472 insertions(+), 515 deletions(-)
 delete mode 100644 view/templates/index/subCount.html

diff --git a/config/define.php b/config/define.php
index 92e4191..bca9956 100644
--- a/config/define.php
+++ b/config/define.php
@@ -20,6 +20,15 @@
     define('JWT_KEY', 'a59d36be11e345a8fcb246c259e55baf'); // md5('kuaile_knowledge')
 
     define('CALLBACK_KNOWLEDGE_LOGIN', 'knowledge_login');
+    define('CALLBACK_KNOWLEDGE_BIND', 'knowledge_bind');
+    define('CALLBACK_KNOWLEDGE_LOGIN_REDIRECT', "http://www.yizherenxin.cn/callback/wxlogin");
+    define('_RC_KNOWLEDGE_BIND_USER_INFO', "bind_user_info_%s_%s");
+
+    define('ADMIN_USER_NOT_SUPER', 0);
+    define('ADMIN_USER_IS_SUPER', 1);
+
+    define('ADMIN_USER_OPEN', 1);
+    define('ADMIN_USER_CLOSE', 2);
 
     define('WEIXIN_OPEN_APPID','wx68a1060c4ec4722f');
     define('WEIXIN_OPEN_APPSCRET','9f8a1dd8352e1150a40ebf3262429f69');
diff --git a/control/callback.php b/control/callback.php
index cd25f47..27fbfa5 100644
--- a/control/callback.php
+++ b/control/callback.php
@@ -11,6 +11,8 @@ class callback extends publicBase {
         if (empty($this->get('code'))) $this->show_message('登录失败,请重新登录', 'goback');
 
         $state = explode('-', $this->get('state'));
+
+        //知识库登陆
         if ($state[0] == CALLBACK_KNOWLEDGE_LOGIN) {
             $obj = new mManage();
             $res = $obj->weixinLogin($this->get('code'), $this->get('state'));
@@ -25,6 +27,19 @@ class callback extends publicBase {
             header('Location:' . urldecode($state[1]));
             exit;
         }
+
+        //知识库绑定
+        if ($state[0] == CALLBACK_KNOWLEDGE_BIND) {
+            $obj = new mManage();
+            $sub_user_id = $obj->weixinBind($this->get('code'), $this->get('state'));
+            if (!$sub_user_id) $this->show_message($obj->getError(), 'goback');
+
+            $obj = new mUser();
+            $rdobj = $obj->initRedis();
+            $rdobj->setex(sprintf(_RC_KNOWLEDGE_BIND_USER_INFO, $state[1], $state[2]), 6*60*60, $sub_user_id);
+            //header('Location:http://zhishiku.yizherenxin.cn/index/bind_user?pageid='.$state[2]);
+            exit;
+        }
         exit;
     }
 }
diff --git a/control/index.php b/control/index.php
index ce00d26..ba84d1d 100644
--- a/control/index.php
+++ b/control/index.php
@@ -11,7 +11,11 @@ class index extends publicBase {
         $this->login();
     }
 
-    public function login() {}
+    public function login() {
+        $this->view['appid'] = WEIXIN_OPEN_APPID;
+        $this->view['redirect_uri'] = urlencode(CALLBACK_KNOWLEDGE_LOGIN_REDIRECT);
+        $this->view['state'] = CALLBACK_KNOWLEDGE_LOGIN . "-" . $this->get('url');
+    }
 
     public function loginout() {
         session_start();
@@ -24,32 +28,74 @@ class index extends publicBase {
 
     public function user_list() {
         $user_info = $this->get_user_info();
-        if (!$user_info['is_super_admin']) $this->show_message('您没有权限', 'goback');
+        if (!$user_info['is_super_admin']) $this->show_message(false, '您还有此权限');
+
+        $obj = new mUser();
+        $pageid = $obj->genPasswd(16);
+
+        $this->view['pageid'] = $pageid;
+        $this->view['appid'] = WEIXIN_OPEN_APPID;
+        $this->view['redirect_uri'] = urlencode(CALLBACK_KNOWLEDGE_LOGIN_REDIRECT);
+        $this->view['state'] = CALLBACK_KNOWLEDGE_BIND . "-" . $user_info['aid'] . "-" . $pageid;
+    }
+
+    public function ajax_user_list() {
+        $user_info = $this->get_user_info();
+        if (!$user_info['is_super_admin']) $this->ajax_json(false, '您还有此权限');
+
+        $condition = array('is_super_admin' => ADMIN_USER_NOT_SUPER);
+        $cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1;
+        $page_size = $this->post('pageSize') ? $this->post('pageSize') : 20;
 
         $uobj = new mUser();
-        $this->view['user_list'] = $uobj->getAdminUserList();
-        $this->view['login_list'] = $uobj->getLoginUserList();
+        $total = $uobj->getAdminUserTotal($condition);
+        $user_list = $uobj->getAdminUserList($condition, $cur_page, $page_size);
+
+        $rdata = array(
+            'total' => $total,
+            'per_page' => $page_size,
+            'last_page' => ceil($total / $page_size),
+            'cur_page' => $cur_page,
+            'list' => $user_list,
+        );
+
+        $this->ajax_json(true, '获取成功', $rdata);
     }
 
-    public function ajax_change_user_status() {
+    public function ajax_change_user() {
+        $user_info = $this->get_user_info();
+        if (!$user_info['is_super_admin']) $this->ajax_json(false, '您还有此权限');
+
         $id = $this->post('id') + 0;
         $status = $this->post('status') + 0;
+        $realname = trim($this->post('realname'));
+
+        $data = array();
+        if ($status > 0) $data['status'] = $status;
+        if (!empty($realname)) $data['realname'] = $realname;
 
         $uobj = new mUser();
-        $res = $uobj->updateAdminUser($id, array('status' => $status));
+        $res = $uobj->updateAdminUser($id, $data);
         if (!$res) $this->ajax_json(false, '设置失败');
 
         $this->ajax_json(true, '设置成功');
     }
 
-    public function ajax_pass_user() {
-        $id = $this->post('id') + 0;
-        $aid = 1; //当前默认aid为1
+    public function ajax_get_user_login() {
+        $user_info = $this->get_user_info();
+        if (!$user_info['is_super_admin']) $this->ajax_json(false, '您还有此权限');
+
+        $pageid = trim($this->post('pageid'));
 
         $uobj = new mUser();
-        $res = $uobj->passLoginUser($id, $aid);
-        if (!$res) $this->ajax_json(false, $uobj->getError());
+        $rdobj = $uobj->initRedis();
+        $sub_user_id = $rdobj->get(sprintf(_RC_KNOWLEDGE_BIND_USER_INFO, $user_info['aid'], $pageid));
+        $sub_user_id = 70;
+        if (!$sub_user_id) $this->ajax_json(false, '还未扫码');
 
-        $this->ajax_json(true, '设置成功');
+        $bind_user_info = $uobj->getAdminUserById($sub_user_id);
+        if (!$bind_user_info) $this->ajax_json(false, '未知错误');
+
+        $this->ajax_json(true, '扫码成功', $bind_user_info);
     }
 }
diff --git a/data/dUser.php b/data/dUser.php
index 0ec63ef..8b074d7 100644
--- a/data/dUser.php
+++ b/data/dUser.php
@@ -7,16 +7,9 @@ include_once SERVER_ROOT . '/data/dBase.php';
 class
 dUser extends dBase {
     protected $fieldlist = array(
-        'login_user_list' => array(
-            'id',
-            'nickname',
-            'openid',
-            'addtime',
-        ),
         'admin_user_list' => array(
             'id',
             'aid',
-            'uid',
             'nickname',
             'realname',
             'openid',
@@ -27,8 +20,7 @@ dUser extends dBase {
     );
 
     protected $primary_keys = array(
-        'login_user_list' => 'id',
-        'admin_user_list' => 'uid',
+        'admin_user_list' => 'id',
     );
 }
 
diff --git a/model/mManage.php b/model/mManage.php
index d883120..fb02930 100644
--- a/model/mManage.php
+++ b/model/mManage.php
@@ -42,15 +42,7 @@ class mManage extends mBase {
         $uobj = new mUser();
         $agent_login_info = $uobj->getAdminUserByOpenid($res['openid']);
         if (empty($agent_login_info)) {
-            $login_user_info = $uobj->getLoginUserByOpenid($res['openid']);
-            if (empty($login_user_info)) $login_user_info = $uobj->addLoginUser(array('openid' => $userinfo['openid'], 'nickname' => $userinfo['nickname']));
-
-            if (empty($login_user_info)) {
-                $this->setError("注册失败");
-                return false;
-            }
-
-            $this->setError("请联系管理员开启账号");
+            $this->setError("账号不存在");
             return false;
         }
 
@@ -83,4 +75,61 @@ class mManage extends mBase {
         }
         return $jwttoken;
     }
+
+    public function weixinBind($code, $state) {
+        if (empty($code)) {
+            $this->setError("缺少回调参数code");
+            return false;
+        }
+
+        if (empty($state)) {
+            $this->setError("缺少回调参数state");
+            return false;
+        }
+
+        // 获取access token
+        $wxopenobj = new mWeixinOpen();
+        $res = $wxopenobj->getAccessToken($code);
+        if (!$res) {
+            $this->setError($wxopenobj->getError());
+            return false;
+        }
+
+        // 获取扫码登录用户信息
+        $userinfo = $wxopenobj->getUserInfo($res['access_token'], $res['openid']);
+        if (!$userinfo) {
+            $this->setError($wxopenobj->getError());
+            return false;
+        }
+
+        $aid = explode('-', $state)[1];
+
+        $uobj = new mUser();
+        $admin_user_info = $uobj->getAdminUserByOpenid($res['openid']);
+        if (!empty($admin_user_info) && $admin_user_info['aid'] == $aid) {
+            $this->setError("账号已存在");
+            return false;
+        }
+
+        if (!empty($admin_user_info)) {
+            $uobj->updateAdminUser($admin_user_info['id'], array('aid' => $aid));
+            return true;
+        }
+
+        $data = array(
+            'aid' => $aid,
+            'nickname' => $userinfo['nickname'],
+            'openid' => $userinfo['openid'],
+            'is_super_admin' => ADMIN_USER_NOT_SUPER,
+            'status' => ADMIN_USER_OPEN,
+        );
+
+        $id = $uobj->addAdminUser($data);
+        if (!$id) {
+            $this->setError("绑定失败");
+            return false;
+        }
+
+        return $id;
+    }
 }
\ No newline at end of file
diff --git a/model/mUser.php b/model/mUser.php
index ae459d5..40fca34 100644
--- a/model/mUser.php
+++ b/model/mUser.php
@@ -9,74 +9,59 @@ class mUser extends mBase {
 
     private $obj;
     private $tbl;
-    private $login_tbl;
 
     public function __construct() {
         $this->obj = new dUser();
         $this->tbl = 'admin_user_list';
-        $this->login_tbl = 'login_user_list';
     }
 
-    public function getAdminUserByOpenid($openid) {
-        return $this->obj->select($this->tbl, array('sql' => '`openid`=?', 'vals' => array($openid)));
+    public function getAdminUserById($id) {
+        return $this->obj->select($this->tbl, array('sql' => '`id`=?', 'vals' => array($id)));
     }
 
-    public function getAdminUserList() {
-        return $this->obj->selectAll($this->tbl, array(), 'id desc ');
+    public function getAdminUserByOpenid($openid) {
+        return $this->obj->select($this->tbl, array('sql' => '`openid`=?', 'vals' => array($openid)));
     }
 
-    public function updateAdminUser($id, $data) {
-        return $this->obj->update($this->tbl, $data, array('sql' => '`id`=?', 'vals' => array($id)));
-    }
+    public function getAdminUserList($condition, $page_num, $page_size) {
+        $offset = ($page_num - 1) * $page_size;
+
+        $where = "1=1 ";
+        if (!empty($condition)) {
+            foreach ($condition as $key => $val) {
+                if (is_array($val)) {
+                    $val = implode(',', $val);
+                    $where .= " and {$key} in ({$val})";
+                } else {
+                    $where .= " and {$key}={$val}";
+                }
+            }
+        }
 
-    public function getLoginUserByOpenid($openid) {
-        return $this->obj->select($this->login_tbl, array('sql' => '`openid`=?', 'vals' => array($openid)));
+        return $this->obj->selectAll($this->tbl, array('sql' => $where, 'vals' => array()), 'id desc', array($offset, $page_size));
     }
 
-    public function getLoginUserById($id) {
-        return $this->obj->select($this->login_tbl, array('sql' => '`id`=?', 'vals' => array($id)));
-    }
+    public function getAdminUserTotal($condition) {
+        $where = "1=1 ";
+        if (!empty($condition)) {
+            foreach ($condition as $key => $val) {
+                if (is_array($val)) {
+                    $val = implode(',', $val);
+                    $where .= " and {$key} in ({$val})";
+                } else {
+                    $where .= " and {$key}={$val}";
+                }
+            }
+        }
 
-    public function addLoginUser($data) {
-        return $this->obj->insert($this->login_tbl, $data);
+        return $this->obj->count($this->tbl, array('sql' => $where, 'vals' => array()));
     }
 
-    public function getLoginUserList() {
-        return $this->obj->selectAll($this->login_tbl, array(), 'id desc ', array(0, 10));
+    public function updateAdminUser($id, $data) {
+        return $this->obj->update($this->tbl, $data, array('sql' => '`id`=?', 'vals' => array($id)));
     }
 
-    public function passLoginUser($id, $aid) {
-        $login_user = $this->getLoginUserById($id);
-        if (empty($login_user)) {
-            $this->setError('用户不存在');
-            return false;
-        }
-
-        $admin_user = $this->getAdminUserByOpenid($login_user['openid']);
-        if (!empty($admin_user)) {
-            $this->setError('审核员已存在');
-            return false;
-        }
-
-        $data = array(
-            'aid' => $aid,
-            'nickname' => $login_user['nickname'],
-            'openid' => $login_user['openid'],
-            'status' => 1,
-        );
-
-        $res = $this->obj->insert($this->tbl, $data);
-        if (!$res) {
-            $this->setError('添加失败');
-            return false;
-        }
-
-        $res = $this->obj->delete($this->login_tbl, array('sql' => 'id=?', 'vals' => array($id)));
-        if (!$res) {
-            $this->setError('删除申请失败');
-            return false;
-        }
-
-        return true;
+    public function addAdminUser($data) {
+        return $this->obj->insert($this->tbl, $data);
     }
 }
\ No newline at end of file
diff --git a/view/css/common.css b/view/css/common.css
index 8950fe5..da86bd0 100644
--- a/view/css/common.css
+++ b/view/css/common.css
@@ -38,6 +38,81 @@ p{
     justify-content: center;
 }
 
+/* 头部 */
+.home-page {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+}
+
+.header-wrap {
+    /* position: absolute;
+            left: 0px;
+            top: 0px; */
+    width: calc(100% - 64px);
+    height: 46px;
+    /* 自动布局 */
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+    padding: 8px 32px;
+    display: flex;
+    justify-content: space-between;
+    background: linear-gradient(270deg, #4EA4F3 0%, #3D85EA 100%);
+}
+
+.home-logo {
+    width: 168px;
+}
+
+/* Dropdown 容器 */
+.dropdown {
+    position: relative;
+    display: inline-block;
+}
+
+/* Dropdown 按钮 */
+.dropdown-toggle {
+    background-color: transparent;
+    padding: 10px 20px;
+    border: none;
+    cursor: pointer;
+    display: flex;
+    align-items: center;
+    gap: 8px;
+    color: #fff;
+}
+
+/* Dropdown 面板 */
+.dropdown-panel {
+    display: none;
+    position: absolute;
+    right: 20px;
+    padding: 12px;
+    background-color: #fff;
+    min-width: 160px;
+    border-radius: 4px;
+    box-shadow: 0px 3px 8px 0px rgba(0, 0, 0, 0.16);
+    z-index: 1;
+}
+
+/* Dropdown 面板中的链接 */
+.dropdown-panel a {
+    color: black;
+    border-radius: 2px;
+    padding: 7px 10px;
+    background: #F6F7FA;
+    text-decoration: none;
+    display: block;
+}
+
+/* Dropdown 面板中的链接悬停效果 */
+.dropdown-panel a:hover {
+    background-color: #f1f1f1;
+}
+
 /* 底部 */
 .leftSideFooterNew{
     display: flex;
@@ -173,4 +248,4 @@ button:hover {
     background: #cc0303;
     color: #FFFFFF;
     border: none;
-}
+}
\ No newline at end of file
diff --git a/view/css/index.css b/view/css/index.css
index f45a6e5..d77a14a 100644
--- a/view/css/index.css
+++ b/view/css/index.css
@@ -116,81 +116,6 @@
     border-radius: 4px;
 }
 
-
-.home-page {
-    width: 100%;
-    height: 100%;
-    display: flex;
-    flex-direction: column;
-}
-
-.header-wrap {
-    /* position: absolute;
-            left: 0px;
-            top: 0px; */
-    width: calc(100% - 64px);
-    height: 46px;
-    /* 自动布局 */
-    display: flex;
-    flex-direction: row;
-    justify-content: space-between;
-    align-items: center;
-    padding: 8px 32px;
-    display: flex;
-    justify-content: space-between;
-    background: linear-gradient(270deg, #4EA4F3 0%, #3D85EA 100%);
-}
-
-.home-logo {
-    width: 168px;
-}
-
-/* Dropdown 容器 */
-.dropdown {
-    position: relative;
-    display: inline-block;
-}
-
-/* Dropdown 按钮 */
-.dropdown-toggle {
-    background-color: transparent;
-    padding: 10px 20px;
-    border: none;
-    cursor: pointer;
-    display: flex;
-    align-items: center;
-    gap: 8px;
-    color: #fff;
-}
-
-/* Dropdown 面板 */
-.dropdown-panel {
-    display: none;
-    position: absolute;
-    right: 20px;
-    padding: 12px;
-    background-color: #fff;
-    min-width: 160px;
-    border-radius: 4px;
-    box-shadow: 0px 3px 8px 0px rgba(0, 0, 0, 0.16);
-    z-index: 1;
-}
-
-/* Dropdown 面板中的链接 */
-.dropdown-panel a {
-    color: black;
-    border-radius: 2px;
-    padding: 7px 10px;
-    background: #F6F7FA;
-    text-decoration: none;
-    display: block;
-}
-
-/* Dropdown 面板中的链接悬停效果 */
-.dropdown-panel a:hover {
-    background-color: #f1f1f1;
-}
-
 /* 图标旋转效果 */
 .icon {
     transition: transform 0.3s ease;
diff --git a/view/css/subCount.css b/view/css/subCount.css
index 9712c32..1734dca 100644
--- a/view/css/subCount.css
+++ b/view/css/subCount.css
@@ -223,7 +223,7 @@ input:checked+.slider:before {
     width: calc(544px - 156px);
     padding: 32px 78px;
     max-height: 650px;
-    overflow-y: auto;
+    /*overflow-y: auto;*/
     background: #fff;
     border-radius: 6px;
     opacity: 1;
@@ -243,6 +243,7 @@ input:checked+.slider:before {
 }
 .temImg{
     width: 220px;
+    height: 220px;
     margin: 24px auto 12px;
     display: flex;
     justify-content: center;
diff --git a/view/js/subCount.js b/view/js/subCount.js
index 78aff5c..4022c53 100644
--- a/view/js/subCount.js
+++ b/view/js/subCount.js
@@ -1,65 +1,9 @@
 $(document).ready(function () {
     var status = 0;
     var currentPage = 1; // 定义变量,用于存储当前的页码
-    var pageSize = 1; // 定义变量,用于存储当前页条数
-    var totalPages = 9;
-    var pageData = [
-       
-        {
-            alias:'哈哈1',
-            name:'qq哎111',
-            date:'2025-03-04 05:59:59',
-            status:1
-        },
-        {
-            alias:'哈哈2',
-            name:'qq哎222',
-            date:'2025-03-04 05:59:59',
-            status:1
-        },
-        {
-            alias:'哈哈3',
-            name:'qq哎333',
-            date:'2025-03-04 05:59:59',
-            status:0
-        },
-        {
-            alias:'哈哈4',
-            name:'qq哎',
-            date:'2025-03-04 05:59:59',
-            status:0
-        },
-        {
-            alias:'哈哈5',
-            name:'qq哎',
-            date:'2025-03-04 05:59:59',
-            status:1
-        },
-        {
-            alias:'哈哈6',
-            name:'qq哎',
-            date:'2025-03-04 05:59:59',
-            status:0
-        },
-        {
-            alias:'哈哈7',
-            name:'qq哎',
-            date:'2025-03-04 05:59:59',
-            status:1
-        },
-        {
-            alias:'哈哈8',
-            name:'qq哎',
-            date:'2025-03-04 05:59:59',
-            status:0
-        },
-        {
-            alias:'哈哈9',
-            name:'qq哎999',
-            date:'2025-03-04 05:59:59',
-            status:1
-        },
-    ]
+    var pageSize = 20; // 定义变量,用于存储当前页条数
+    var totalPages = 0;
+    var pageData = []
     // 渲染分页按钮
     function renderPagination() {
         const pageNumbers = $('#page-numbers');
@@ -118,42 +62,38 @@ $(document).ready(function () {
     getRenderData();
 
     function getRenderData(){
-        // $.ajax({
-        //     type: "post",
-        //     dataType: 'json',
-        //     url: 'http://zhishiku.yizherenxin.cn/weibo/ajax_weibo_list',
-        //     data: {
-        //         status,
-        //         currentPage,
-        //         pageSize
-        //     },
-        //     success: function (res) {
-        //         if(!res.status){
-        //             alert(`请求失败`);
-        //         }
-
-        //         renderData(res.data)
-        //     }
-        // })
-        var data = JSON.parse(JSON.stringify(pageData))
-        renderData(data.slice(currentPage-1,currentPage+1 ))
+        $.ajax({
+            type: "post",
+            dataType: 'json',
+            url: '/index/ajax_user_list',
+            data: {
+                currentPage,
+                pageSize
+            },
+            success: function (res) {
+                if(!res.status){
+                    alert(`请求失败`);
+                }
+
+                renderData(res.data)
+            }
+        })
     }
-    function renderData(pageData){
-        console.log(pageData,'====data');
+    function renderData(data){
+        totalPages = data.last_page;
+        var pageData = data.list
         $('#tbody-wrap').empty()
         renderList()
 
         var html = '';
-        pageData.forEach((item,index)=>{
-            html += ` <tr data-id="${index}">
-                            <td>${item.alias}</td>
-                            <td>${item.name} <img class="action-icon" src="../../images/edit.svg" alt=""></td>
-                            <td>
-                            ${item.date}
-                            </td>
+        pageData.forEach((item)=>{
+            html += ` <tr data-id="${item.id}">
+                            <td>${item.nickname}</td>
+                            <td>${item.realname} <img class="action-icon" src="../../images/edit.svg" alt=""></td>
+                            <td>${item.addtime}</td>
                             <td>
                                 <label class="switch">
-                                    <input type="checkbox" ${item.status >0 ? 'checked' : ''}>
+                                    <input type="checkbox" ${item.status == 1 ? 'checked' : ''}>
                                     <span class="slider"></span>
                                 </label>
                             </td>
@@ -313,8 +253,25 @@ function renderList() {
       $('#confirmBtn').click(function () {
         const newValue = $('#editInput').val();
         if (newValue && currentRow) {
-          currentRow.find('td').eq(0).text(newValue);
-          $('#editPopover').hide();
+          const id = currentRow.data('id');
+          const realname = newValue;
+          $.ajax({
+            type: "post",
+            dataType: 'json',
+            url: '/index/ajax_change_user',
+            data: {
+              id,
+              realname
+            },
+            success: function (res) {
+              if(!res.status){
+                alert(`请求失败`);
+              }
+
+              currentRow.find('td').eq(1).text(newValue);
+              $('#editPopover').hide();
+            }
+          })
         }
       });
 
@@ -323,24 +280,86 @@ function renderList() {
         $('#editPopover').hide();
       });
 
-      // Switch 开关切换
-      $('.switch input').change(function () {
-        const row = $(this).closest('tr');
-        const isChecked = $(this).is(':checked');
-        const status = isChecked ? 'Active' : 'Inactive';
-        row.find('td').eq(2).text(status); // 更新状态列
-      });
+    //Switch 开关切换
+    $('#tbody-wrap').on('change','.switch input',function () {
+        // row.find('td').eq(2).text(status); // 更新状态列
+        const that = $(this);
+        const row = that.closest('tr');
+        const isChecked = that.is(':checked');
 
-      $('.addNewBtn').click(function () {
+        const id = row.data('id');
+        const status =  isChecked ? '1' : '2';
+        $.ajax({
+            type: "post",
+            dataType: 'json',
+            url: '/index/ajax_change_user',
+            data: {
+                id,
+                status
+            },
+            success: function (res) {
+                if(!res.status){
+                    alert(res.info);
+                    if(isChecked){
+                        that.prop('checked', false)
+                    }else{
+                        that.prop('checked', true)
+                    }
+                }
+            }
+        })
+    });
+
+
+    function listenLogin() {
+        const pageid = $('#pageid').val();
+        $.ajax({
+            type: "post",
+            dataType: 'json',
+            url: '/index/ajax_get_user_login',
+            data: {
+                pageid
+            },
+            success: function (res) {
+                if(res.status){
+                   $('#bind_id').val(res.data.id);
+                   $('.scanSuccessText').html(res.data.nickname + ',扫码成功');
+                   $('.scanSuccess').removeClass('hide');
+                }else{
+                    setTimeout(listenLogin,3000)
+                }
+            }
+        })
+    }
+
+    $('.addNewBtn').click(function () {
         $('.addChildNumWrap, .modal-overlay').fadeIn();
-        // setTimeout(()=>{
-        //     $('.addChildNumWrap, .modal-overlay').fadeOut();
-        // },3000)
+        setTimeout(listenLogin,3000)
     });
     $('.cancelBtn').click(function(){
         $('.addChildNumWrap, .modal-overlay').fadeOut();
+        if(!$('.scanSuccess').hasClass('hide')){
+            setTimeout(function (){ window.location.reload();},1000)
+        }
     })
     $('.confirmBtn').click(function(){
-        $('.addChildNumWrap, .modal-overlay').fadeOut();
+        const id = $('#bind_id').val();
+        const realname = $('#bind_realname').val();
+        $.ajax({
+            type: "post",
+            dataType: 'json',
+            url: '/index/ajax_change_user',
+            data: {
+                id,
+                realname
+            },
+            success: function (res) {
+                if(!res.status){
+                    alert(res.info);
+                }
+                $('.addChildNumWrap, .modal-overlay').fadeOut();
+                setTimeout(function (){ window.location.reload();},1000)
+            }
+        })
     })
 })
\ No newline at end of file
diff --git a/view/templates/include/header.html b/view/templates/include/header.html
index 67666ce..d913ad6 100644
--- a/view/templates/include/header.html
+++ b/view/templates/include/header.html
@@ -9,7 +9,7 @@
             </button>
             <div class="dropdown-panel">
                 {if $_user_info.is_super_admin}
-                <a href="/index/user_list">管理员列表</a>
+                <a href="/index/user_list">子账号管理</a>
                 {/if}
                 <a href="/loginout">退出</a>
             </div>
diff --git a/view/templates/index/login.html b/view/templates/index/login.html
index 17ae798..3a92093 100644
--- a/view/templates/index/login.html
+++ b/view/templates/index/login.html
@@ -93,16 +93,15 @@
                     <img src="{$smarty.const.CSS_URL}/images/login_top.svg" alt="">
                     <span>私有云知识库</span>
                 </div>
-                <div id="get_url" class="hide">{$smarty.get.url}</div>
                 <div id="login_container" class="qrcode">
                     {literal}
                     <script>
                         var obj = new WxLogin({
                             id: "login_container",
-                            appid: {/literal}"{$smarty.const.WEIXIN_OPEN_APPID}"{literal},
+                            appid: "{/literal}{$appid}{literal}",
                             scope: "snsapi_login",
-                            redirect_uri: encodeURIComponent("http://www.yizherenxin.cn/callback/wxlogin"),
-                            state: "knowledge_login"+'-'+encodeURIComponent($('#get_url').html()),
+                            redirect_uri: "{/literal}{$redirect_uri}{literal}",
+                            state: "{/literal}{$state}{literal}",
                             style: "black",
                             href:'data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDE4OHB4O2JvcmRlcjpub25lO21hcmdpbi10b3A6MHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAxODhweDtkaXNwbGF5Om5vbmU7fQouc3RhdHVzX2ljb24ge2Rpc3BsYXk6IG5vbmV9Ci5pbXBvd2VyQm94IC5zdGF0dXMge3RleHQtYWxpZ246IGNlbnRlcjt9IAo='
                         });
diff --git a/view/templates/index/subCount.html b/view/templates/index/subCount.html
deleted file mode 100644
index 5bc508c..0000000
--- a/view/templates/index/subCount.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>知识库</title>
-    <link rel="stylesheet" href="../../css/common.css?v={$smarty.const.CSS_JS_VERSION}">
-    <link rel="stylesheet" href="../../css/subCount.css?v={$smarty.const.CSS_JS_VERSION}">
-    <script src="https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
-    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
-    <script src="../../js/jquery-3.6.0.min.js"></script>
-
-</head>
-
-<body>
-    <div class="subCount-page">
-        {include file="include/header.html"}
-        <div class="subCount-main-content">
-            <div class="subCount-main">
-                <div class="tab-list flex">
-                    <b>子账号管理</b>
-                    <button class="addNewBtn">
-                        <img src="../../images/add.svg" alt="">新增自子账号
-                    </button>
-                </div>
-                <table id="dataTable">
-                    <thead>
-                        <tr>
-                            <th>账号昵称</th>
-                            <th>姓名</th>
-                            <th>添加时间</th>
-                            <th>启用状态</th>
-                        </tr>
-                    </thead>
-                    <tbody id="tbody-wrap">
-                    </tbody>
-                </table>
-
-                <div id="editPopover" class="popover">
-                    <div>
-                        <span>备注</span>
-                        <input type="text" id="editInput" placeholder="Enter new value">
-                    </div>
-                    <div class="flex" style="justify-content: flex-end;">
-                        <button id="cancelBtn">取消</button>
-                        <button id="confirmBtn">确定</button>
-                    </div>
-                    <!-- <img src="../../images/appendIcon.png" alt=""> -->
-                </div>
-
-
-                <!-- 分页控件 -->
-                <div class="pagination hide">
-                    <img id="prev-page" src="../../images/prev.svg" alt="">
-                    <ul id="page-numbers"></ul>
-                    <img id="next-page" src="../../images/next.svg" alt="">
-                    <div class="input-page">
-                        <span>前往</span>
-                        <input type="number" id="jump-to-page" min="1" placeholder="页码">
-                        <span>页</span>
-                    </div>
-                    <button id="go-to-page">跳转</button>
-                </div>
-            </div>
-        </div>
-        <div class="modal-overlay"></div>
-
-        <div class="addChildNumWrap">
-            <h3>新增子账号</h3>
-            <div id="get_url" class="hide">{$smarty.get.url}</div>
-                <!-- <div id="login_container" class="qrcode">
-                    {literal}
-                    <script>
-                        var obj = new WxLogin({
-                            id: "login_container",
-                            appid: {/literal}"{$smarty.const.WEIXIN_OPEN_APPID}"{literal},
-                            scope: "snsapi_login",
-                            redirect_uri: encodeURIComponent("http://www.yizherenxin.cn/callback/wxlogin"),
-                            state: "knowledge_login"+'-'+encodeURIComponent($('#get_url').html()),
-                            style: "black",
-                            href:'data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDE4OHB4O2JvcmRlcjpub25lO21hcmdpbi10b3A6MHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAxODhweDtkaXNwbGF5Om5vbmU7fQouc3RhdHVzX2ljb24ge2Rpc3BsYXk6IG5vbmV9Ci5pbXBvd2VyQm94IC5zdGF0dXMge3RleHQtYWxpZ246IGNlbnRlcjt9IAo='
-                        });
-                    </script>
-                    {/literal}
-                </div> -->
-                <img class="temImg" src="../../images/userTem.png" alt="">
-                <div class="code-filter column hide">
-                    <img src="../../images/step_success.png" alt="">
-                    <span>{$_user_info.nickname},扫码成功</span>
-                </div>
-                <p class="flex" style="text-align: center;">
-                <img src="../../images/weixin.svg" alt="">
-                微信扫码,绑定子账号
-            </p>
-            <div class="name column hide">
-                <div class="name-top">
-                    <img src="../../images/user.svg" alt="">
-                    姓名
-                </div>
-                <input class="name-input" type="text" placeholder="可备注真实姓名">
-            </div>
-            <div class="btnGroups flex">
-               <button class="button button-normal cancelBtn">取消</button>
-               <button class="button button-primary confirmBtn hide">确定</button>
-            </div>
-        </div>
-        <!-- {include file="include/footer.html"} -->
-    </div>
-</body>
-<script src="../../js/subCount.js?v={$smarty.const.CSS_JS_VERSION}"></script>
-
-</html>
\ No newline at end of file
diff --git a/view/templates/index/user_list.html b/view/templates/index/user_list.html
index d114313..295296a 100644
--- a/view/templates/index/user_list.html
+++ b/view/templates/index/user_list.html
@@ -6,152 +6,107 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>知识库</title>
     <link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/common.css?v={$smarty.const.CSS_JS_VERSION}">
-    <link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/index.css?v={$smarty.const.CSS_JS_VERSION}">
+    <link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/subCount.css?v={$smarty.const.CSS_JS_VERSION}">
+    <script src="https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
     <script src="{$smarty.const.CSS_URL}/js/jquery-3.6.0.min.js"></script>
+
 </head>
-{literal}
-<style>
-    table {
-        width: 100%;
-        border-collapse: collapse;
-        background-color: #fff;
-        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
-        margin-bottom: 50px;
-    }
-    caption {
-        font-size: 18px;
-        font-weight: bold;
-        padding: 10px;
-        color: #333;
-    }
-    th, td {
-        padding: 12px;
-        text-align: left;
-        border-bottom: 1px solid #ddd;
-    }
-    th {
-        background-color: #4CAF50;
-        color: white;
-    }
-    tr:hover {
-        background-color: #f1f1f1;
-    }
-    /* 响应式表格 */
-    @media (max-width: 600px) {
-        table {
-            width: 100%;
-        }
-        th, td {
-            display: block;
-            text-align: right;
-            padding: 10px;
-        }
-        th {
-            text-align: left;
-            background-color: #3b8c40;
-        }
-    }
-</style>
-{/literal}
+
 <body>
-    <div class="home-page">
+    <div class="subCount-page">
         {include file="include/header.html"}
+        <div class="subCount-main-content">
+            <div class="subCount-main">
+                <div class="tab-list flex">
+                    <b>子账号管理</b>
+                    <button class="addNewBtn">
+                        <img src="{$smarty.const.CSS_URL}/images/add.svg" alt="">新增自子账号
+                    </button>
+                </div>
+                <table id="dataTable">
+                    <thead>
+                        <tr>
+                            <th>账号昵称</th>
+                            <th>姓名</th>
+                            <th>添加时间</th>
+                            <th>启用状态</th>
+                        </tr>
+                    </thead>
+                    <tbody id="tbody-wrap">
+                    </tbody>
+                </table>
+
+                <div id="editPopover" class="popover">
+                    <div>
+                        <span>备注</span>
+                        <input type="text" id="editInput" placeholder="Enter new value">
+                    </div>
+                    <div class="flex" style="justify-content: flex-end;">
+                        <button id="cancelBtn">取消</button>
+                        <button id="confirmBtn">确定</button>
+                    </div>
+                    <!-- <img src="{$smarty.const.CSS_URL}/images/appendIcon.png" alt=""> -->
+                </div>
 
-        <div class="home-main-content">
-            <table>
-                <caption>审核员列表</caption>
-                <tr>
-                    <td>ID</td>
-                    <td>昵称</td>
-                    <td>真实姓名</td>
-                    <td>操作</td>
-                </tr>
-                {foreach from=$user_list key=key item=item}
-                <tr>
-                    <td>{$item.id}</td>
-                    <td>{$item.nickname}</td>
-                    <td>{$item.real_name}</td>
-                    <td>
-                        {if $item.is_super_admin == 0}
-                        <button data-id="{$item.id}" class="change-status button {if $item.status==0}button-primary{else}button-danger{/if}">{if $item.status==0}启用{else}禁用{/if}</button>
-                        {/if}
-                    </td>
-                </tr>
-                {/foreach}
-            </table>
 
-            {if $login_list}
-            <table>
-                <caption>申请列表</caption>
-                <tr>
-                    <td>ID</td>
-                    <td>昵称</td>
-                    <td>登陆时间</td>
-                    <td>操作</td>
-                </tr>
-                {foreach from=$login_list key=key item=item}
-                <tr>
-                    <td>{$item.id}</td>
-                    <td>{$item.nickname}</td>
-                    <td>{$item.addtime}</td>
-                    <td>
-                        <button data-id="{$item.id}" class="button button-primary passBtn">审核通过</button>
-                    </td>
-                </tr>
-                {/foreach}
-            </table>
-            {/if}
+                <!-- 分页控件 -->
+                <div class="pagination hide">
+                    <img id="prev-page" src="{$smarty.const.CSS_URL}/images/prev.svg" alt="">
+                    <ul id="page-numbers"></ul>
+                    <img id="next-page" src="{$smarty.const.CSS_URL}/images/next.svg" alt="">
+                    <div class="input-page">
+                        <span>前往</span>
+                        <input type="number" id="jump-to-page" min="1" placeholder="页码">
+                        <span>页</span>
+                    </div>
+                    <button id="go-to-page">跳转</button>
+                </div>
+            </div>
         </div>
+        <div class="modal-overlay"></div>
 
-        {include file="include/footer.html"}
+        <div class="addChildNumWrap">
+            <h3>新增子账号</h3>
+            <div id="login_container" class="temImg">
+                {literal}
+                <script>
+                    var obj = new WxLogin({
+                        id: "login_container",
+                        appid: "{/literal}{$appid}{literal}",
+                        scope: "snsapi_login",
+                        redirect_uri: "{/literal}{$redirect_uri}{literal}",
+                        state: "{/literal}{$state}{literal}",
+                        style: "black",
+                        href:'data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIyMHB4O2JvcmRlcjpub25lO21hcmdpbi10b3A6MHB4O30KLmltcG93ZXJCb3ggLnRpdGxlIHtkaXNwbGF5OiBub25lO30KLmltcG93ZXJCb3ggLmluZm8ge3dpZHRoOiAyMjBweDtkaXNwbGF5Om5vbmU7fQouc3RhdHVzX2ljb24ge2Rpc3BsYXk6IG5vbmV9Ci5pbXBvd2VyQm94IC5zdGF0dXMge3RleHQtYWxpZ246IGNlbnRlcjt9'
+                    });
+                </script>
+                {/literal}
+            </div>
+            <div class="scanSuccess code-filter column {if !$bind_user_info}hide{/if}">
+                <img src="{$smarty.const.CSS_URL}/images/step_success.png" alt="">
+                <span class="scanSuccessText">{$bind_user_info.nickname},扫码成功</span>
+            </div>
+            <p class="flex" style="text-align: center;">
+                <img src="{$smarty.const.CSS_URL}/images/weixin.svg" alt="">
+                微信扫码,绑定子账号
+            </p>
+            <div class="scanSuccess name column {if !$bind_user_info}hide{/if}">
+                <div class="name-top">
+                    <img src="{$smarty.const.CSS_URL}/images/user.svg" alt="">
+                    姓名
+                </div>
+                <input id="bind_realname" class="name-input" type="text" placeholder="可备注真实姓名">
+                <input id="bind_id" type="hidden" value="{$bind_user_info.id}">
+            </div>
+            <div class="btnGroups flex">
+               <button class="button button-normal cancelBtn">取消</button>
+               <button class="scanSuccess button button-primary confirmBtn {if !$bind_user_info}hide{/if}">确定</button>
+            </div>
+        </div>
+         {include file="include/footer.html"}
     </div>
 </body>
-{literal}
-<script>
-    $('.change-status').click(function (){
-        var id = $(this).data('id');
-        var status = $(this).hasClass('button-danger') ? 0 :  1;
-        var that = $(this);
-        $.ajax({
-            type: "post",
-            dataType: 'json',
-            url: '/index/ajax_change_user_status',
-            data: {
-                id,
-                status
-            },
-            success: function (res) {
-                alert(res.info)
-                if(res.status){
-                    if(status==1){
-                        that.html('禁用').removeClass('button-primary').addClass('button-danger');
-                    }else{
-                        that.html('启用').addClass('button-primary').removeClass('button-danger');
-                    }
-                }
-            }
-        })
-    })
-
-    $('.passBtn').click(function (){
-        var id = $(this).data('id');
-        $.ajax({
-            type: "post",
-            dataType: 'json',
-            url: '/index/ajax_pass_user',
-            data: {
-                id,
-                status
-            },
-            success: function (res) {
-                alert(res.info)
-                if(res.status){
-                    window.location.reload();
-                }
-            }
-        })
-    })
-</script>
-{/literal}
+<script src="{$smarty.const.CSS_URL}/js/subCount.js?v={$smarty.const.CSS_JS_VERSION}"></script>
 
 </html>
\ No newline at end of file