• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
车车大人
博客园    首页    新随笔    联系   管理     

jquery+tp3实现账号是否被禁用的即点即改

html页面

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>管理员列表</title>
    <style>
        .gre{
            margin-left: 10px;
            background: lightgreen;
            border-radius: 5px;
            color: white;
            text-decoration: none;
        }

        .danger{
            margin-left: 10px;
            background: red;
            border-radius: 5px;
            color: white;
            text-decoration: none;
        }
    </style>
</head>
<body>
<table>
    <tr>
        <th>ID</th>
        <th>账号</th>
        <th>班级</th>
        <th>角色</th>
        <th>权限</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
<foreach name="list" item="v">
    <tr id="{$v.id}">
        <td>{$v.id}</td>
        <td>{$v.uname}</td>
        <td>{$v.class_name}</td>
        <td>{$v.rname}</td>
        <td>
            <foreach name="v.nname" item="vo">
                <a href="#" style="margin-left: 10px; background: #66c9f3; border-radius: 5px;color: white;text-decoration: none;">{$vo}</a>
            </foreach>
        </td>
        <td>
            <if condition="$v.is_clock eq 1"><a href="javascript:void(0);" class="gre clock">正常</a>
                <else /> <a href="javascript:void(0);" class="danger clock">被禁</a>
            </if>
        </td>
        <td>
            <a>删除</a>
        </td>
    </tr>
</foreach>

    <script src="__PUBLIC__/js/jquery.js"></script>
    <script>
            $('.clock').on('click',function () {
                var is_clock = $(this).text();
                var id = $(this).parents("td").parents().attr('id');
                if(is_clock=='正常'){
                    var is_c = 2;
                    $(this).html("被禁");
                    $(this).removeClass('gre');
                    $(this).addClass('danger');
                }else{
                    var is_c = 1;
                    $(this).html("正常");
                    $(this).removeClass('danger');
                    $(this).addClass('gre');
                }

                //请求
                $.get("__URL__/update_clock?is_c="+is_c+"&id="+id,function (data) {
                    // alert(data);
                });

            });
    </script>
</table>
</body>
</html>

 

 

php页面

//修改状态
    public function update_clock(){
        $id = I('get.id');
        $data['is_clock'] = I('get.is_c');
        M("user")->where("uid=".$id)->save($data);
    }

 

 

效果:

 

通往牛逼的路上,在意的只有远方!
posted @ 2018-07-13 21:09  车车大人  阅读(285)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3