public function get_account_list() { $page = $_POST['page']; $size = $_POST['number']; $start = ($page - 1) * $size; $WebChatModel = new \Home\Model\AccountBlanceModel(); $userinfo = $_COOKIE['userinfo']; $userinfoArr = unserialize($userinfo); $username = $userinfoArr['username']; $userinfoOb = M("userinfo"); $userArr = $userinfoOb->where("username='******'")->find(); $uid = $userArr['userid']; $num = $WebChatModel->my_account_count($uid); //得到列表总条数 $limit = "{$start},{$size}"; //每页的数据数和内容$limit $result = $WebChatModel->my_account_list($uid, $limit); if (empty($result)) { $result = array(); } $data = array('count' => $num, 'result' => $result); echo json_encode($data); }
public function my_account() { //如果为登陆,跳转到login页面,否则查出uid和username字段 $userinfo = $_COOKIE['userinfo']; if (empty($userinfo)) { setcookie("gourl", "/Home/Webchat/my_account"); header("location:/Home/Webchatlogin/login"); die; } else { setcookie("gourl", ""); $userinfoArr = unserialize($userinfo); $username = $userinfoArr['username']; $userinfoOb = M("userinfo"); $userArr = $userinfoOb->where("username='******'")->find(); $uid = $userArr['userid']; } // if (empty($_SESSION['username'])) { // //将当前页面地址放进存入session // setcookie("gourl", "/Home/Webchat/my_account"); // header("location:/Home/Webchatlogin/login"); // die; // } else { // setcookie("gourl", ""); // $username = $_SESSION['username']; // $userinfoOb = M("userinfo"); // $userArr = $userinfoOb->where("username='******'")->find(); // $uid = $userArr['userid']; // //$uid = $_SESSION['userid']; // } import("Think.Page"); //Page类的引入 $WebChatModel = new \Home\Model\AccountBlanceModel(); $num = $WebChatModel->my_account_count($uid); //得到列表总条数 $page = new \Think\Page($num, 20); $limit = $page->firstRow . ',' . $page->listRows; //每页的数据数和内容$limit $result = $WebChatModel->my_account_list($uid, $limit); $pageStr = $page->show(); $this->assign("empty", '<div class="resultjobs clearfix" style="font-size:17px;text-align:center;line-height:50px;">暂时没有数据</div>'); $this->assign("username", $username); $this->assign("pageStr", $pageStr); $this->assign("result", $result); $this->display("./Webchat/my_account"); }