1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 老猫 <thinkcmf@126.com>
- // +----------------------------------------------------------------------
- namespace app\portal\controller;
- use app\admin\model\SlideItemModel;
- use app\love\controller\LoveBaseController;
- use app\love\model\UserFriendModel;
- use app\love\model\UserInviteModel;
- use app\portal\model\UserModel;
- class IndexController extends LoveBaseController
- {
- public function index()
- {
- //男会员
- $man_list = UserModel::where('user_type', 2)
- ->where('check_status',2)
- ->where('is_complete', 1)
- ->where('is_public', 1)
- ->where('sex', 1)
- ->where('id', '<>', cmf_get_current_user_id())
- ->order('star desc')
- ->limit(6)
- ->select();
- foreach ($man_list as $v) {
- $v['age'] = empty($v['birthday']) ? '未知' : date('Y') - date('Y', $v['birthday']);
- }
- $this->assign('man_list', json_encode($man_list));
- //女会员
- $woman_list = UserModel::where('user_type', 2)
- ->where('check_status',2)
- ->where('is_complete', 1)
- ->where('is_public', 1)
- ->where('sex', 2)
- ->where('id', '<>', cmf_get_current_user_id())
- ->order('star desc')
- ->limit(6)
- ->select();
- foreach ($woman_list as $v) {
- $v['age'] = empty($v['birthday']) ? '未知' : date('Y') - date('Y', $v['birthday']);
- }
- $this->assign('woman_list', json_encode($woman_list));
- //幻灯片
- $images = SlideItemModel::where('slide_id', 1)->select();
- foreach ($images as $image) {
- $image['image'] = cmf_get_image_url($image['image']);
- }
- $this->assign('images', json_encode($images));
- //未读消息数
- $unread_num = UserFriendModel::where('user_id', cmf_get_current_user_id())->sum('unread_num');
- $invite_num = UserInviteModel::where('to_id', cmf_get_current_user_id())
- ->where('status', 1)
- ->count();
- $this->assign('unread_num', $unread_num + $invite_num);
- return $this->fetch(':index');
- }
- public function demo()
- {
- return $this->fetch(':demo');
- }
- }
|