| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 | 
							- <?php
 
- namespace app\admin\controller\user;
 
- use app\admin\model\Message;
 
- use app\common\controller\Backend;
 
- use app\common\library\Auth;
 
- /**
 
-  * 会员管理
 
-  *
 
-  * @icon fa fa-user
 
-  */
 
- class User extends Backend
 
- {
 
-     protected $relationSearch = true;
 
-     protected $searchFields = 'u_id,username,nickname';
 
-     /**
 
-      * @var \app\admin\model\User
 
-      */
 
-     protected $model = null;
 
-     public function _initialize()
 
-     {
 
-         parent::_initialize();
 
-         $this->model = model('User');
 
-         $typeList = [
 
-             'isCoolList' => $this->model->getIsCoolList(),
 
-             'isManagerList' => $this->model->getIsManagerList(),
 
-         ];
 
-         $this->view->assign($typeList);
 
-         $this->assignconfig($typeList);
 
-     }
 
-     /**
 
-      * 查看
 
-      */
 
-     public function index()
 
-     {
 
-         $this->relationSearch = true;
 
-         //设置过滤方法
 
-         $this->request->filter(['strip_tags', 'trim']);
 
-         if ($this->request->isAjax()) {
 
-             //如果发送的来源是Selectpage,则转发到Selectpage
 
-             if ($this->request->request('keyField')) {
 
-                 return $this->selectpage();
 
-             }
 
-             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
-             $list = $this->model
 
-                 ->with(['noble','preuser','auth','age'])
 
-                 ->where($where)
 
-                 ->order($sort, $order)
 
-                 ->paginate($limit);
 
-             foreach ($list as $k => $v) {
 
-                 $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
 
-                 $v->hidden(['password', 'salt']);
 
-                 $v->getRelation('age')->visible(['name']);
 
-             }
 
-             $result = array("total" => $list->total(), "rows" => $list->items());
 
-             return json($result);
 
-         }
 
-         return $this->view->fetch();
 
-     }
 
-     /**
 
-      * 添加
 
-      */
 
-     public function add()
 
-     {
 
-         if ($this->request->isPost()) {
 
-             $this->token();
 
-         }
 
-         return parent::add();
 
-     }
 
-     /**
 
-      * 编辑
 
-      */
 
-     public function edit($ids = null)
 
-     {
 
-         if ($this->request->isPost()) {
 
-             $this->token();
 
-         }
 
-         $row = $this->model->get($ids);
 
-         $this->modelValidate = true;
 
-         if (!$row) {
 
-             $this->error(__('No Results were found'));
 
-         }
 
-         return parent::edit($ids);
 
-     }
 
-     /**
 
-      * 删除
 
-      */
 
-     public function del($ids = "")
 
-     {
 
-         if (!$this->request->isPost()) {
 
-             $this->error(__("Invalid parameters"));
 
-         }
 
-         $ids = $ids ? $ids : $this->request->post("ids");
 
-         $row = $this->model->get($ids);
 
-         $this->modelValidate = true;
 
-         if (!$row) {
 
-             $this->error(__('No Results were found'));
 
-         }
 
-         Auth::instance()->delete($row['id']);
 
-         $this->success();
 
-     }
 
-     /**
 
-      * 详情
 
-      * @param null $ids
 
-      * @return string
 
-      * @throws \think\Exception
 
-      * @throws \think\exception\DbException
 
-      */
 
-     public function detail($ids = null)
 
-     {
 
-         /* 判断数据是否存在*/
 
-         $row = $this->model->get($ids);
 
-         if (!$row) {
 
-             $this->error(__('No Results were found'));
 
-         }
 
-         /* 判断是否有权限访问*/
 
-         $adminIds = $this->getDataLimitAdminIds();
 
-         if (is_array($adminIds)) {
 
-             if (!in_array($row[$this->dataLimitField], $adminIds)) {
 
-                 $this->error(__('You have no permission'));
 
-             }
 
-         }
 
-         $this->view->assign("row", $row);
 
-         return $this->view->fetch();
 
-     }
 
-     /**
 
-      * 编辑
 
-      */
 
-     public function infocheck($ids = null)
 
-     {
 
-         $row = $this->model->get($ids);
 
-         if (!$row) {
 
-             $this->error(__('No Results were found'));
 
-         }
 
-         $adminIds = $this->getDataLimitAdminIds();
 
-         if (is_array($adminIds)) {
 
-             if (!in_array($row[$this->dataLimitField], $adminIds)) {
 
-                 $this->error(__('You have no permission'));
 
-             }
 
-         }
 
-         if ($this->request->isPost()) {
 
-             $params = $this->request->post("row/a");
 
-             if (!$params) {
 
-                 $this->error(__('Parameter %s can not be empty', ''));
 
-             }
 
-             $params = $this->preExcludeFields($params);
 
-             $result = false;
 
-             try {
 
-                 //是否采用模型验证
 
-                 if ($this->modelValidate) {
 
-                     $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
 
-                     $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
 
-                     $row->validateFailException(true)->validate($validate);
 
-                 }
 
-                 $nickStatusStr = $statusStr = '';
 
-                 if (isset($params['check_nick_status'])) {
 
-                     if ($params['check_nick_status'] == 1) {//审核通过 更新昵称
 
-                         !empty($params['pre_nickname']) && $params['nickname'] = $params['pre_nickname'];
 
-                         $params['pre_nickname'] = '';
 
-                         $nickStatusStr = '昵称通过';
 
-                     } else {//审核拒绝 清空新昵称
 
-                         $params['pre_nickname'] = '';
 
-                         $nickStatusStr = '昵称拒绝';
 
-                     }
 
-                 }
 
-                 if (isset($params['check_status'])) {
 
-                     if ($params['check_status'] == 1) {//审核通过 更新头像
 
-                         !empty($params['pre_avatar']) && $params['avatar'] = $params['pre_avatar'];
 
-                         $params['pre_avatar'] = '';
 
-                         $statusStr = '头像通过';
 
-                     } else {//审核拒绝 清空新头像
 
-                         $params['pre_avatar'] = '';
 
-                         $statusStr = '头像拒绝';
 
-                     }
 
-                 }
 
-                 $result = $row->allowField(true)->save($params);
 
-             } catch (ValidateException|PDOException|Exception $e) {
 
-                 $this->error($e->getMessage());
 
-             }
 
-             if ($result == false) {
 
-                 $this->error(__('No rows were updated'));
 
-             }
 
-             if (!empty($nickStatusStr) || !empty($statusStr)) {
 
-                 //通过发消息
 
-                 $title = '用户信息变更审核通知';
 
-                 $content = '您申请的'.$nickStatusStr.$statusStr;
 
-                 Message::addMessage($row['id'],$title,$content);
 
-             }
 
-             $this->success();
 
-         }
 
-         $checkStatusList = [1=>'通过', 0=>'拒绝'];
 
-         $showNickname = $showAvatar = 0;
 
-         if (!empty($row['pre_nickname']) && $row['pre_nickname'] != $row['nickname']) {
 
-             $showNickname = 1;
 
-         }
 
-         if (!empty($row['pre_avatar']) && $row['pre_avatar'] != $row['avatar']) {
 
-             $showAvatar = 1;
 
-         }
 
-         $this->view->assign([
 
-             'row' => $row,
 
-             'checkStatusList' => $checkStatusList,
 
-             'showNickname' => $showNickname,
 
-             'showAvatar' => $showAvatar,
 
-         ]);
 
-         return $this->view->fetch();
 
-     }
 
- }
 
 
  |