public function follow() { $this->identity(); //加载左侧菜单 $pageNum = self::$pageNum; //每页显示条目 $frag = I('get.frag', 'follow'); if ($frag == "follow") { //首页面跳转 $this->redirect("follow?frag=followfounder"); } if ($frag == 'followfounder') { //关注的合伙人 $rela = "follow.followid=user.id and user.id=founder.uid"; $where['follow.uid'] = session('user.id'); $count = M()->table('user user,follow_man follow,user_founder founder')->where($rela)->where($where)->count(); // 查询满足要求的总记录数 $page = PAGE($count, $pageNum); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('user user,follow_man follow,user_founder founder')->where($rela)->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); for ($i = 0; $i != count($data); $i++) { $data[$i]['agegroup'] = ageGroup($data[$i]['birthday_time']); //年龄转换 调用founder内静态方法 } //dump($data); $this->assign('founder', $data); } elseif ($frag == 'followinvestor') { //关注的投资人 $rela = "follow.followid=user.id and user.id=investor.uid"; $where['follow.uid'] = session('user.id'); $count = M()->table('user user,follow_man follow,user_investor investor')->where($rela)->where($where)->count(); // 查询满足要求的总记录数 $page = PAGE($count, $pageNum); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('user user,follow_man follow,user_investor investor')->where($rela)->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); for ($i = 0; $i != count($data); $i++) { $data[$i]['agegroup'] = ageGroup($data[$i]['birthday_time']); //年龄转换 调用founder内静态方法 } $this->assign('investor', $data); } elseif ($frag == 'followproject') { //关注的项目 $rela = "follow.projectid=project.id"; $where['follow.uid'] = session('user.id'); $count = M()->table('follow_project follow,project project')->where($rela)->where($where)->count(); // 查询满足要求的总记录数 $page = PAGE($count, $pageNum); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('follow_project follow,project project')->where($rela)->where($where)->limit($page->firstRow . ',' . $page->listRows)->select(); for ($i = 0; $i != count($data); $i++) { $arr = explode(" ", $data[$i]['location']); $data[$i]['province'] = $arr[0]; $data[$i]['city'] = $arr[1]; } $this->assign('project', $data); } $frag = 'frag' . $frag; //加前缀 $this->assign('frag', $frag); $this->assign('page', $show); $this->display(); }
public function index() { $uid = session('user.id'); getMsgStatu($uid); $post = I('post.'); $order = "user.last_login_time desc"; //排序方式 if (!empty($post['search'])) { //搜索 $search = '%' . $post['search'] . "%"; //搜索条件1 $where['user.username|founder.intro'] = array('like', $search); //搜索条件2 $count = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->where($where)->count(); // 查询满足要求的总记录数 $page = PAGE($count); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->where($where)->limit($page->firstRow . ',' . $page->listRows)->order($order)->select(); for ($i = 0; $i != count($data); $i++) { //改变搜索结果颜色 $data[$i]['intro'] = str_replace($post['search'], "<span style='color:red'>{$post['search']}</span>", $data[$i]['intro']); } //dump($data); } elseif (!empty($post['type'])) { //筛选 $where = array(); if ($post['type'] !== "不限") { $where['founder.type'] = $post['type']; } if ($post['province'] !== "不限") { $where['user.province'] = $post['province']; } if ($post['city'] !== "不限") { $where['user.city'] = $post['city']; } if ($post['agegroup'] !== "不限") { $date = ageGroupReverse($post['agegroup']); $where['birthday_time'] = array("between", "{$date['start']},{$date['end']}"); } $count = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->where($where)->count(); $page = PAGE($count); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); //dump($data); } else { //全部 $count = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->order($order)->count(); $page = PAGE($count); // 实例化分页类 传入总记录数和每页显示的记录数 $show = $page->show(); // 分页显示输出 $data = M()->table('user user,user_founder founder')->where("user.id = founder.uid")->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); //dump($data); } for ($i = 0; $i != count($data); $i++) { $data[$i]['agegroup'] = ageGroup($data[$i]['birthday_time']); //年龄转换 $data[$i]['reg_time'] = regTime($data[$i]['reg_time']); //注册时间转换 $data[$i]['last_login_time'] = loginTime($data[$i]['last_login_time']); //登录时间转换 if (strlen($data[$i]['username']) >= 12) { // 用户名判断截取 $data[$i]['username'] = substr($data[$i]['username'], 0, 10) . '..'; } } $this->assign('founder', $data); $this->assign('page', $show); // 赋值分页输出 $this->display(); }