User.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\controller\Backend;
  4. /**
  5. * 会员管理
  6. *
  7. * @icon fa fa-user
  8. */
  9. class User extends Backend
  10. {
  11. protected $searchFields = 'id,username,nickname';
  12. protected $selectpageFields = 'id,username,nickname,mobile';
  13. protected $multiFields = 'is_tuijian';
  14. /**
  15. * User模型对象
  16. * @var \app\admin\model\User
  17. */
  18. protected $model = null;
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. $this->model = new \app\admin\model\User;
  23. $this->view->assign("genderList", $this->model->getGenderList());
  24. $this->view->assign("idcardStatusList", $this->model->getIdcardStatusList());
  25. $this->view->assign("statusList", $this->model->getStatusList());
  26. $this->view->assign("hideIsFinishinfoList", $this->model->getHideIsFinishinfoList());
  27. $this->view->assign("isActiveList", $this->model->getIsActiveList());
  28. $this->view->assign("isTuijianList", $this->model->getIsTuijianList());
  29. $this->view->assign("jinyantypeList", $this->model->getJinyantypeList());
  30. }
  31. public function import()
  32. {
  33. parent::import();
  34. }
  35. /**
  36. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  37. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  38. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  39. */
  40. /**
  41. * 查看
  42. */
  43. public function index()
  44. {
  45. //当前是否为关联查询
  46. $this->relationSearch = true;
  47. //设置过滤方法
  48. $this->request->filter(['strip_tags', 'trim']);
  49. if ($this->request->isAjax()) {
  50. //如果发送的来源是Selectpage,则转发到Selectpage
  51. if ($this->request->request('keyField')) {
  52. return $this->selectpage();
  53. }
  54. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  55. $list = $this->model
  56. ->with(['userwallet'])
  57. ->where($where)
  58. ->order($sort, $order)
  59. ->paginate($limit);
  60. foreach ($list as $row) {
  61. $row->getRelation('userwallet')->visible(['money','gold','vip_endtime']);
  62. }
  63. $result = array("total" => $list->total(), "rows" => $list->items());
  64. return json($result);
  65. }
  66. return $this->view->fetch();
  67. }
  68. }