IndexController.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\portal\controller;
  12. use app\admin\model\SlideItemModel;
  13. use app\love\controller\LoveBaseController;
  14. use app\love\model\UserFriendModel;
  15. use app\love\model\UserInviteModel;
  16. use app\portal\model\UserModel;
  17. class IndexController extends LoveBaseController
  18. {
  19. public function index()
  20. {
  21. //男会员
  22. $man_list = UserModel::where('user_type', 2)
  23. ->where('check_status',2)
  24. ->where('is_complete', 1)
  25. ->where('is_public', 1)
  26. ->where('sex', 1)
  27. ->where('id', '<>', cmf_get_current_user_id())
  28. ->order('star desc')
  29. ->limit(6)
  30. ->select();
  31. foreach ($man_list as $v) {
  32. $v['age'] = empty($v['birthday']) ? '未知' : date('Y') - date('Y', $v['birthday']);
  33. }
  34. $this->assign('man_list', json_encode($man_list));
  35. //女会员
  36. $woman_list = UserModel::where('user_type', 2)
  37. ->where('check_status',2)
  38. ->where('is_complete', 1)
  39. ->where('is_public', 1)
  40. ->where('sex', 2)
  41. ->where('id', '<>', cmf_get_current_user_id())
  42. ->order('star desc')
  43. ->limit(6)
  44. ->select();
  45. foreach ($woman_list as $v) {
  46. $v['age'] = empty($v['birthday']) ? '未知' : date('Y') - date('Y', $v['birthday']);
  47. }
  48. $this->assign('woman_list', json_encode($woman_list));
  49. //幻灯片
  50. $images = SlideItemModel::where('slide_id', 1)->select();
  51. foreach ($images as $image) {
  52. $image['image'] = cmf_get_image_url($image['image']);
  53. }
  54. $this->assign('images', json_encode($images));
  55. //未读消息数
  56. $unread_num = UserFriendModel::where('user_id', cmf_get_current_user_id())->sum('unread_num');
  57. $invite_num = UserInviteModel::where('to_id', cmf_get_current_user_id())
  58. ->where('status', 1)
  59. ->count();
  60. $this->assign('unread_num', $unread_num + $invite_num);
  61. return $this->fetch(':index');
  62. }
  63. public function demo()
  64. {
  65. return $this->fetch(':demo');
  66. }
  67. }