IndexController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <thinkcmf@126.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\matchmaker\controller;
  12. use app\common\Constant;
  13. use app\common\Fun;
  14. use app\matchmaker\model\MatchmakerUserModel;
  15. class IndexController extends MatchmakerBaseController
  16. {
  17. public function index()
  18. {
  19. $status = $this->request->get('status', 0);
  20. return $this->fetch('', ['status' => $status]);
  21. }
  22. public function listUser()
  23. {
  24. $param = $this->request->post();
  25. $where = [
  26. ['matchmaker_id', '=', $this->matchmaker['id']],
  27. ];
  28. if (!empty($param['status'])) {
  29. $where[] = ['status', '=', $param['status']];
  30. }
  31. if (!empty($param['keyword'])) {
  32. $where[] = ['realname|mobile|id', 'like', "%{$param['keyword']}%"];
  33. }
  34. $list = MatchmakerUserModel::where($where)
  35. ->order('id desc')
  36. ->append(['status_text'])
  37. ->limit(6)
  38. ->page($param['page'])
  39. ->select();
  40. foreach ($list as $v) {
  41. $v['age'] = Fun::getAgeByBirth($v['birthday']);
  42. $v['sex_text'] = Constant::SEX[$v['sex']];
  43. }
  44. $this->result($list, 1);
  45. }
  46. }