作者 sgj
1 个管道 的构建 通过 耗费 2 秒

圈子设置

@@ -149,6 +149,7 @@ class GroupController extends AdminBaseController @@ -149,6 +149,7 @@ class GroupController extends AdminBaseController
149 $map['g.group_id']=input('id'); 149 $map['g.group_id']=input('id');
150 $list=db('group_user') 150 $list=db('group_user')
151 ->alias('g') 151 ->alias('g')
  152 + ->field('g.id as gid,u.*')
152 ->where($map) 153 ->where($map)
153 ->join('user u','g.user_id=u.id') 154 ->join('user u','g.user_id=u.id')
154 ->paginate('1'); 155 ->paginate('1');
@@ -163,8 +164,7 @@ class GroupController extends AdminBaseController @@ -163,8 +164,7 @@ class GroupController extends AdminBaseController
163 * 拉黑用户 164 * 拉黑用户
164 */ 165 */
165 public function banUser(){ 166 public function banUser(){
166 - $map['user_id']=input('id');  
167 - $map['group_id']=input('group_id'); 167 + $map['id']=input('id');
168 $result=db('group_user')->where($map)->delete(); 168 $result=db('group_user')->where($map)->delete();
169 if ($result==1){ 169 if ($result==1){
170 $this->success('删除用户!'); 170 $this->success('删除用户!');
@@ -174,8 +174,8 @@ class GroupController extends AdminBaseController @@ -174,8 +174,8 @@ class GroupController extends AdminBaseController
174 } 174 }
175 175
176 public function groupPeopleAdd(){ 176 public function groupPeopleAdd(){
177 -  
178 - 177 + dump(input());
  178 + $this->success();
179 } 179 }
180 180
181 } 181 }
@@ -53,6 +53,45 @@ class CommonController extends AdminBaseController @@ -53,6 +53,45 @@ class CommonController extends AdminBaseController
53 return $this->fetch(); 53 return $this->fetch();
54 } 54 }
55 55
  56 + public function selectUsersMore()
  57 + {
  58 + $param = $this->request->param();
  59 + $ids = $this->request->param('ids');
  60 + $selectedIds = explode(',',$ids);
  61 + if (!is_array($selectedIds)) {
  62 + $selectedIds = [$selectedIds];
  63 + }
  64 +
  65 + $where['user_type'] = ['in','1,2,3'];
  66 + $request = input('request.');
  67 +
  68 + if (!empty($request['uid'])) {
  69 + $where['id'] = intval($request['uid']);
  70 + }
  71 + $keywordComplex = [];
  72 + if (!empty($request['keyword'])) {
  73 + $keyword = $request['keyword'];
  74 +
  75 + $keywordComplex['user_login|user_nickname|mobile'] = ['like', "%$keyword%"];
  76 + }
  77 + $usersQuery = Db::name('user');
  78 + $list = $usersQuery->field('id,user_nickname,user_login,avatar,mobile')
  79 + ->whereOr($keywordComplex)
  80 + ->where($where)
  81 + ->order("create_time DESC")
  82 + ->paginate(50);
  83 + $list->appends($param);
  84 +
  85 + $this->assign('selectedIds', $selectedIds);
  86 + $this->assign('uid', isset($param['uid']) ? $param['uid'] : '');
  87 + $this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
  88 + $this->assign('ids', isset($param['ids']) ? $param['ids'] : '');
  89 + $this->assign('list', $list->items());
  90 + $this->assign('page', $list->render());
  91 +
  92 + return $this->fetch();
  93 + }
  94 +
56 public function selectGroup(){ 95 public function selectGroup(){
57 $param = $this->request->param(); 96 $param = $this->request->param();
58 $ids = $this->request->param('ids'); 97 $ids = $this->request->param('ids');
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a>{$group.name}</a></li>
  7 + </ul>
  8 + <form class="well form-inline margin-top-20 js-ajax-form" method="post" action="{:url('groupPeopleAdd',['group_id'=>$group.id])}">
  9 + 添加用户
  10 + <input class="form-control" type="text" required="" placeholder="请选择用户" onclick="doSelectUsers();" id="js-users-name-input" readonly="" aria-required="true">
  11 + <input class="form-control" type="hidden" name="post[author_id]" value="" name="user_id" id="js-users-id-input"/>
  12 + <input type="submit" class="btn btn-primary js-ajax-submit" value="确定"/>
  13 +
  14 + <a class="btn btn-danger" href="{:url('user/adminIndex/index')}">清空</a>
  15 + </form>
  16 + <form method="post" class="js-ajax-form">
  17 + <table class="table table-hover table-bordered">
  18 + <thead>
  19 + <tr>
  20 + <th>ID</th>
  21 + <th>{:lang('USERNAME')}</th>
  22 + <th>姓名</th>
  23 + <th>头像</th>
  24 + <th>手机</th>
  25 + <th>注册时间</th>
  26 + <th>{:lang('LAST_LOGIN_TIME')}</th>
  27 + <th>{:lang('LAST_LOGIN_IP')}</th>
  28 + <th>{:lang('STATUS')}</th>
  29 + <th>{:lang('ACTIONS')}</th>
  30 + </tr>
  31 + </thead>
  32 + <tbody>
  33 + <php>
  34 + $user_statuses=array("0"=>lang('USER_STATUS_BLOCKED'),"1"=>lang('USER_STATUS_ACTIVATED'),"2"=>lang('USER_STATUS_UNVERIFIED'));
  35 + </php>
  36 + <foreach name="list" item="vo">
  37 + <tr>
  38 + <td>{$vo.gid}</td>
  39 + <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:lang('THIRD_PARTY_USER'))}
  40 + </td>
  41 + <td>{$vo['user_nickname']?$vo['user_nickname']:lang('NOT_FILLED')}</td>
  42 + <td><img width="25" height="25" src="{:url('user/public/avatar',array('id'=>$vo['id']))}"/></td>
  43 + <td>{$vo.mobile}</td>
  44 + <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
  45 + <td>{:date('Y-m-d H:i:s',$vo['last_login_time'])}</td>
  46 + <td>{$vo.last_login_ip}</td>
  47 + <td>{$user_statuses[$vo['user_status']]}</td>
  48 + <td>
  49 + <neq name="vo.id" value="1">
  50 + <empty name="vo.user_status">
  51 + <a href="{:url('adminIndex/cancelban',array('id'=>$vo['id']))}"
  52 + class="js-ajax-dialog-btn"
  53 + data-msg="{:lang('ACTIVATE_USER_CONFIRM_MESSAGE')}">{:lang('ACTIVATE_USER')}</a>
  54 + <else/>
  55 + <a href="{:url('banUser',array('id'=>$vo['gid']))}" class="js-ajax-dialog-btn"
  56 + data-msg="{:lang('BLOCK_USER_CONFIRM_MESSAGE')}">{:lang('BLOCK_USER')}</a>
  57 + </empty>
  58 + <else/>
  59 + <a style="color: #ccc;">{:lang('BLOCK_USER')}</a>
  60 + </neq>
  61 + </td>
  62 + </tr>
  63 + </foreach>
  64 + </tbody>
  65 + </table>
  66 + <div class="pagination">{$page}</div>
  67 + </form>
  68 +</div>
  69 +<script src="__STATIC__/js/admin.js"></script>
  70 +<script type="application/javascript">
  71 + function doSelectUsers() {
  72 + var selectedUsersId = $('#js-users-id-input').val();
  73 + openIframeLayer("{:url('portal/Common/selectUsersMore')}?ids=" + selectedUsersId, '请选择分类', {
  74 + area: ['1200px', '800px'],
  75 + btn: ['确定', '取消'],
  76 + yes: function (index, layero) {
  77 + //do something
  78 +
  79 + var iframeWin = window[layero.find('iframe')[0]['name']];
  80 + var selectedUsers = iframeWin.confirm();
  81 + if (selectedUsers.selectedUsersId.length == 0) {
  82 + layer.msg('请选择分类');
  83 + return;
  84 + }
  85 + $('#js-users-id-input').val(selectedUsers.selectedUsersId.join(','));
  86 + $('#js-users-name-input').val(selectedUsers.selectedUsersName.join(' '));
  87 + //console.log(layer.getFrameIndex(index));
  88 + layer.close(index); //如果设定了yes回调,需进行手工关闭
  89 + }
  90 + });
  91 + }
  92 +</script>
  93 +</body>
  94 +</html>
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap" style="min-width: inherit">
  5 + <form class="well form-inline margin-top-20" method="post" action="">
  6 + 用户ID:
  7 + <input class="form-control" type="text" name="uid" style="width: 200px;" value="{$uid}"
  8 + placeholder="请输入用户ID">
  9 + 关键字:
  10 + <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{$keyword}"
  11 + placeholder="昵称/电话">
  12 + <input type="submit" class="btn btn-primary" value="搜索"/>
  13 + <a class="btn btn-danger" href="">清空</a>
  14 + </form>
  15 + <form method="post" class="js-ajax-form" action="">
  16 + <table class="table table-hover table-bordered table-list">
  17 + <thead>
  18 + <tr>
  19 + <th width="16">
  20 + <label>
  21 + <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
  22 + </label>
  23 + </th>
  24 + <th width="50">ID</th>
  25 + <th>姓名</th>
  26 + <th>头像</th>
  27 + <th>电话</th>
  28 + </tr>
  29 + </thead>
  30 + <tbody id="tb">
  31 + <foreach name="list" item="vo">
  32 + <tr id="check-tr">
  33 + <td >
  34 + <input type="checkbox" id="in{$vo.id}" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
  35 + value="{$vo.id}" data-name="{$vo.user_login}" <if condition="in_array($vo['id'],$selectedIds)"> checked</if> >
  36 + </td>
  37 + <td>{$vo.id}</td>
  38 + <td>{$vo.user_login|default=$vo.user_nickname}</td>
  39 + <td><img width="50px" src="{$vo.avatar}"></td>
  40 + <td>{$vo.mobile}</td>
  41 + </tr>
  42 + </foreach>
  43 + </tbody>
  44 + </table>
  45 + </form>
  46 +</div>
  47 +<script src="__STATIC__/js/admin.js"></script>
  48 +<script>
  49 + // $('.js-check').click(function(e) {
  50 + // var sel_id='in'+e.currentTarget.defaultValue;
  51 + //
  52 + // $( ".js-check" ).each( function(res) {
  53 + // console.log(res)
  54 + // $(".js-check").eq(res).prop("checked",false)
  55 + // $('#'+sel_id).prop("checked",true)
  56 + // } );
  57 + // }
  58 + //
  59 + // )
  60 + $('.data-item-tr').click(function (e) {
  61 +
  62 + console.log(e);
  63 + var $this = $(this);
  64 + if ($(e.target).is('input')) {
  65 + return;
  66 + }
  67 +
  68 + var $input = $this.find('input');
  69 + if ($input.is(':checked')) {
  70 + $input.prop('checked', false);
  71 + } else {
  72 + $input.prop('checked', true);
  73 + }
  74 + });
  75 +
  76 + function confirm() {
  77 + var selectedUsersId = [];
  78 + var selectedUsersName = [];
  79 + var selectedUsers = [];
  80 + $('.js-check:checked').each(function () {
  81 + var $this = $(this);
  82 + selectedUsersId.push($this.val());
  83 + selectedUsersName.push($this.data('name'));
  84 +
  85 + selectedUsers.push({
  86 + id: $this.val(),
  87 + name: $this.data('name')
  88 + });
  89 + });
  90 +
  91 + return {
  92 + selectedUsers: selectedUsers,
  93 + selectedUsersId: selectedUsersId,
  94 + selectedUsersName: selectedUsersName
  95 + };
  96 + }
  97 +</script>
  98 +</body>
  99 +</html>