IndexController.php 2.7 KB

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