public function get_feed_img()
{
$html = '<dl class="weiboPic clearfix">';
$type = intval($_POST['type']);
$max_id = intval($_POST['max_id']);
$map['a.uid'] = intval($_POST['uid']);
$map['a.attach_type'] = 'feed_image';
$map['a.is_del'] = 0;
$map['f.is_del'] = 0;
$dao = M()->table(C('DB_PREFIX') . 'attach as a left join ' . C('DB_PREFIX') . 'feed as f on a.row_id=f.feed_id');
$res['count'] = intval(M()->table(C('DB_PREFIX') . 'attach as a left join ' . C('DB_PREFIX') . 'feed as f on a.row_id=f.feed_id')->where($map)->count());
$order = 'a.attach_id desc';
if ($max_id > 0) {
if ($type == 0) {
$map['attach_id'] = array('lt', $max_id);
} else {
$map['attach_id'] = array('gt', $max_id);
$order = 'attach_id asc';
}
}
$lists = M()->table(C('DB_PREFIX') . 'attach as a left join ' . C('DB_PREFIX') . 'feed as f on a.row_id=f.feed_id')->where($map)->order($order)->limit(5)->findAll();
// lastsql ();
// dump ( $lists );
if ($type == 1) {
// 倒序
$count = count($lists);
for ($i = 0; $i < $count; $i++) {
$arr[] = $lists[$count - 1 - $i];
}
$lists = $arr;
}
foreach ($lists as $k => &$v) {
$ids[] = intval($v['attach_id']);
if ($k == 0) {
$html .= '<dt class="left"><a href="' . U('public/Profile/feed', array('feed_id' => $v['row_id'], 'uid' => $v['uid'])) . '"><img src="' . getImageUrl($v['save_path'] . $v['save_name'], 260, 260, true) . '" /></a></dt>';
} else {
$html .= '<dd><a href="' . U('public/Profile/feed', array('feed_id' => $v['row_id'], 'uid' => $v['uid'])) . '"><img src="' . getImageUrl($v['save_path'] . $v['save_name'], 120, 120, true) . '" /></a></dd>';
}
}
$html .= '</dl>';
$max_id2 = max($ids);
$map['attach_id'] = array('gt', $max_id2);
if ($max_id > 0 && M()->table(C('DB_PREFIX') . 'attach as a left join ' . C('DB_PREFIX') . 'feed as f on a.row_id=f.feed_id')->where($map)->getField('attach_id')) {
$html .= '<a class="next-page mt20 left" onClick="get_feed_img(1)"><i class="arrow-left"></i>上一页</a>';
}
$max_id = $max_id2;
$min_id = min($ids);
$map['attach_id'] = array('lt', $min_id);
if (M()->table(C('DB_PREFIX') . 'attach as a left join ' . C('DB_PREFIX') . 'feed as f on a.row_id=f.feed_id')->where($map)->getField('attach_id')) {
$html .= '<a class="next-page mt20 right" onClick="get_feed_img(0)">下一页<i class="arrow-right"></i></a>';
}
$res['html'] = $html;
$res['max_id'] = intval($max_id);
$res['min_id'] = intval($min_id);
echo json_encode($res);
}