public function commentlist() { $rep = M("product_comment_replies"); //$product_id = $_GET['id']; $db = M("product_comments"); $product_id = $_GET['id']; $status = $_GET['status']; if ($status == 0) { $count = $db->where("product_id = " . $product_id)->count(); $page = new \Think\HomePage($count, 6); $show = $page->show(); $comm = $db->where("product_id = " . $product_id)->order("comment_time desc")->limit($page->firstRow . ',' . $page->listRows)->select(); } else { if ($status == 1) { $map['product_id'] = array("eq", $product_id); $map['score'] = array("in", "4,5"); $count = $db->where($map)->count(); $page = new \Think\HomePage($count, 6); $show = $page->show(); $comm = $db->where($map)->order("comment_time desc")->limit($page->firstRow . ',' . $page->listRows)->select(); } else { if ($status == 2) { $map['product_id'] = array("eq", $product_id); $map['score'] = array("in", "3,2"); $count = $db->where($map)->count(); $page = new \Think\HomePage($count, 6); $show = $page->show(); $comm = $db->where($map)->order("comment_time desc")->limit($page->firstRow . ',' . $page->listRows)->select(); } else { if ($status == 3) { $map['product_id'] = array("eq", $product_id); $map['score'] = array("eq", "1"); $count = $db->where($map)->count(); $page = new \Think\HomePage($count, 6); $show = $page->show(); $comm = $db->where($map)->order("comment_time desc")->limit($page->firstRow . ',' . $page->listRows)->select(); } } } } foreach ($comm as &$v) { $v['comment_time'] = date("Y-m-d H:i:s", $v['comment_time']); //回复 $replay = $rep->where("comment_id = " . $v['id'])->find(); if ($replay) { $replay['replay_time'] = date("Y-m-d H:i:s", $replay['reply_time']); $v['replay'] = $replay; } //用户头像 $user = M("user_info"); $img = $user->field("thumb")->where("user_id = " . $v['user_id'])->find(); $v['thumb'] = $img['thumb']; //用户名 $users = M("users"); $username = $users->field("uname")->where("id = " . $v['user_id'])->find(); $v['username'] = $username['uname']; } $comm['page'] = $show; $comm = json_encode($comm); exit($comm); }
public function getPageByAjax() { $db = M("support_downloads"); $count = $db->count(); $page = new \Think\HomePage($count, 9); $show = $page->show(); $data = $db->order("ctime desc")->limit($page->firstRow . ',' . $page->listRows)->select(); $str = ""; $str .= '<div class="row download-lists" id="pages">'; foreach ($data as &$v) { $v['ctime'] = date("Y.m.d", $v['ctime']); $str .= '<div class="col-sm-6 col-md-4">'; $str .= '<div class="thumbnail">'; $str .= '<img src="/Public/download/downImage/' . $v['thumbnail'] . '" style="width:210px;height:228px;">'; $str .= '<div class="caption">'; $str .= '<h3>' . $v['title'] . '</h3>'; $str .= '<p>'; $str .= '<span>文件大小:' . $v['filesize'] . '</span>'; $str .= '<span>更新时间:' . $v['ctime'] . '</span>'; $str .= '</p>'; $str .= '<p>'; if ($v['linkurl'] != "") { $str .= '<a href="' . $v[linkurl] . '" class="btn btn-primary" role="button">立即下载</a> '; } else { $str .= '<a href="' . U('Support/fileDown/id/' . $v['id']) . '" class="btn btn-primary" role="button">立即下载</a> '; } $str .= '<a href="' . U('Support/downloaddetail/id/' . $v['id']) . '" class="btn btn-default" role="button">详细</a>'; $str .= '</p>'; $str .= '</div>'; $str .= '</div>'; $str .= '</div>'; } $str .= '</div>'; $str .= '<div class="row page-padding-right">'; $str .= $show; $str .= '</div>'; exit($str); }