/** * 类别列表 */ public function category() { $cateid = I('get.cid'); if (empty($cateid)) { $this->_empty(); } $where['cateid'] = $cateid; $where['status'] = true; $count = M('Works')->where($where)->count(); $page = $this->Pages($count, 10); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/category/' . $cateid . '/' . $pageurl; $this->pagecount = $page->totalRows / $page->listRows; $list = D('Home/Works')->relation(array('User', 'Category'))->where($where)->order('iftj DESC,workid DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign('catename', $list[0]['catename']); $this->assign('list', $list); $this->assign("Page", $page->show()); $this->assign('midad', parent::getAdvert(3, 1, 0, 1)); //右上角广告 $this->assign('righttopad', parent::getAdvert(3, 3, 0, 1)); //热门活动 $this->assign('activitytj', D('Home/Activity')->activitytj(2)); //焙友动态 $this->userDynamicData = D('Home/User')->userDynamic(5); //分享达人 $this->assign('sharedaren', D('Home/User')->sharedaren(5, $this->userid)); $this->display(); }
protected function _initialize() { parent::_initialize(); $this->openuid = I('get.openuid'); if (getUidByOpenuid($this->openuid)) { $this->uid = getUidByOpenuid($this->openuid); } else { $this->error('您无权访问当前页面!'); } $this->assign('openuid', $this->openuid); //会员信息 $this->memberDetail = D('Home/User')->find($this->uid); //烘焙作品数 $this->hbworksnum = getCount('Works', array('userid' => $this->uid, 'type' => 1)); //随拍作品 $this->spworksnum = getCount('Copy', array('userid' => $this->uid)); //关注数 $this->attentionnum = getCount('UserFans', array('myid' => $this->uid)); //被关注数 $this->fansnum = getCount('UserFans', array('userid' => $this->uid)); //是否关注 $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $this->uid, 'status' => true)); //中间广告 $this->midad = parent::getAdvert(9, 1, 0, 1); }
protected function _initialize() { parent::_initialize(); //中间图片 $this->midad = $this->getAdvert(5, 1, 0, 1); //右侧广告 $this->rightad = parent::getAdvert(5, 3, 0, 1); }
public function index() { //推荐产品 $filed = array('tryid', 'title', 'image', 'requestnum', 'price', 'trynum', 'end_time'); $this->tjtry = M('TryItems')->field($filed)->where(array('status' => true, 'iftj' => true, 'iffinish' => false))->order('sort DESC,tryid DESC')->limit(1)->find(); $this->hottry = M('TryItems')->field($filed)->where(array('status' => true, 'ifhot' => true, 'iffinish' => false))->limit(10)->select(); $this->newesttry = M('TryItems')->field($filed)->where(array('status' => true, 'iftj' => true, 'iffinish' => false))->order('sort DESC,tryid DESC')->limit(0, 6)->select(); $this->tryreport = M('TryReport')->field('tryid,image,id')->where(array('status' => true))->limit(6)->select(); //中间广告位 $this->assign('midad', parent::getAdvert(6, 1, 0, 1)); $this->display(); }
public function index() { $get = I('get.'); $type = I('get.t'); $keyword = \Input::getVar(I('get.keyword')); if (empty($type)) { $this->_empty(); } if (empty($keyword)) { $this->error('亲爱的,你似乎没有输入需要搜索的关键词...'); } $url = '&keyword=' . $keyword . '&t=' . $type; if ($type == 1) { //中间广告位 $this->assign('midad', parent::getAdvert(2, 1, 0, 1)); $worksModel = M('Works'); $where['status'] = array('EQ', true); $where['title'] = array("LIKE", "%{$keyword}%"); $count = $worksModel->where($where)->count(); $page = $this->Pages($count, 30); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/search/' . $pageurl . $url; $Model = new Model(); $list = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where("W.userid=U.userid and W.status=true and W.title like '%" . $keyword . "%'")->field('W.title,W.type,W.content,W.goodnum,W.msgnum,W.workid,W.create_time,W.image,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,U.ifrz')->order('msgnum DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($list as $key => $value) { $list[$key]['dignum'] = M('Dig')->where(array('status' => true, 'infoid' => $value['workid'], 'userid' => $this->userid))->count(); } $this->assign('keywords', $keyword); $this->assign("list", $list); $this->assign("Page", $page->show()); $this->display('works'); } else { $userModel = M('User'); $where['status'] = array('EQ', true); $where['nickname'] = array("LIKE", "%{$keyword}%"); $count = $userModel->where($where)->count(); $page = $this->Pages($count, 40); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/search/' . $pageurl . $url; $list = $userModel->where($where)->field('userid,uavatar,openuid,nickname,worksnum,spnum,fansnum')->order('worksnum DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($list as $key => $value) { $list[$key]['worknums'] = $value['worksnum'] + $value['spnum']; if (M('UserFans')->where(array('userid' => $value['userid'], 'myid' => $this->userid, 'status' => true))->count() > 0) { $list[$key]['isfans'] = true; } } $this->assign("list", $list); $this->assign("Page", $page->show()); $this->display('user'); } }
public function index() { //中间广告位 $this->assign('midad', parent::getAdvert(3, 1, 0, 1)); //类别每日一荐 $this->assign('catetj', D('Home/Works')->cateonework()); //右上角广告 $this->assign('righttopad', parent::getAdvert(3, 3, 0, 1)); //焙友动态 $this->userDynamicData = D('Home/User')->userDynamic(5); //热门活动 $this->assign('activitytj', D('Home/Activity')->activitytj(2)); //右边广告 $this->assign('rightmidad', parent::getAdvert(3, 3, 1, 4)); //分享达人 $this->assign('sharedaren', D('Home/User')->sharedaren(5, $this->userid)); $this->display(); }
public function workslist($type, $url) { //中间广告位 $this->assign('midad', parent::getAdvert(2, 1, 0, 1)); $worksModel = M('Works'); $where['status'] = array('EQ', true); $where['type'] = array('EQ', 1); $count = $worksModel->where($where)->count(); $page = $this->Pages($count, 15); $pageurl = '?page=' . urlencode('[PAGE]'); $page->url = __APP__ . '/dongtai/' . $url . '/' . $pageurl; $Model = new Model(); $list = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where('W.userid=U.userid and W.status=true and W.type=1')->field('W.title,W.content,W.goodnum,W.msgnum,W.workid,W.create_time,W.image,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,U.ifrz')->order('' . $type . ' DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($list as $key => $value) { $list[$key]['dignum'] = M('Dig')->where(array('status' => true, 'infoid' => $value['workid'], 'userid' => $this->userid))->count(); } $this->pagecount = $page->totalRows / $page->listRows; $this->assign("list", $list); $this->assign("Page", $page->show()); }
/** * 作品详情展示 */ public function detail() { $workid = I('get.workid'); if (empty($workid)) { $this->error('您访问的页面不存在'); } //增加点击数 M('Works')->where(array('workid' => $workid))->setInc('clicknum'); $detail = D('Works')->relation(true)->find($workid); if (!$detail) { $this->error('您访问的作品不存在'); } //start yf $yf_thumb = array(); $yf_pic = array(); if (!empty($detail['all_pic'])) { $yf_arr = json_decode($detail['all_pic'], true); $yf_temp = array(); foreach ($yf_arr as $k => $v) { $yf_thumb[] = $v; $yf_ex = explode("/", $v); $yf_ex[count($yf_ex) - 1] = str_replace("yf_", "", $yf_ex[count($yf_ex) - 1]); $yf_pic[] = implode("/", $yf_ex); } } else { $yf_arr = array(); $yf_thumb[] = $yf_pic[] = $detail['image']; } $detail['pic_num'] = count($yf_thumb); $detail['thumb'] = implode(",", $yf_thumb); $detail['pic'] = implode(",", $yf_pic); $detail['WorksMaterials_count'] = count($detail['WorksMaterials']); //end $this->assign('data', $detail); //点赞总数 $this->digallnum = $detail['goodnum'] + $detail['badnum']; //综合评价 if ($detail['goodnum'] == 0 && $detail['badnum'] == 0) { $dig['digavg'] = 0; $dig['goodprecent'] = 50; $dig['badprecent'] = 50; } else { $digavg = round($detail['goodnum'] / ($detail['goodnum'] + $detail['badnum']), 2); $dig['digavg'] = $digavg * 10; $dig['goodprecent'] = $digavg * 100; $dig['badprecent'] = (1 - $digavg) * 100; } $this->dig = $dig; //点赞判断 $this->digtype = M('Dig')->field('digtype,id')->where(array('userid' => $this->userid, 'status' => true, 'infoid' => $workid))->find(); //收藏判断 $this->favoritenum = getCount('UserFavorite', array('userid' => $this->userid, 'status' => true, 'infoid' => $workid)); //右侧广告 $this->rightad = parent::getAdvert(8, 3, 0, 2); //点赞人员列表 $diguser = new Model(); $diguerlist = $diguser->table(array(C('DB_PREFIX') . 'dig' => 'D', C('DB_PREFIX') . 'user' => 'U'))->where('D.userid=U.userid and D.status=true and D.digtype=1 and D.infoid=' . $workid . '')->field('U.uavatar,U.openuid')->select(); $this->assign('diglist', $diguerlist); //评论 $where['infoid'] = $workid; $where['type'] = 1; $where['parent_id'] = 0; $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $Model = new Model(); $message = $Model->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=1 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid,U.ifrz')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $Model->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 1; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); } //参照做出的作品 $copylist = $Model->table(array(C('DB_PREFIX') . 'works' => 'W', C('DB_PREFIX') . 'user' => 'U'))->where('W.userid=U.userid and W.status=true and W.type=2 and W.copyid=' . $workid)->field('U.openuid,U.nickname,U.uavatar,W.title,W.image,W.workid,W.create_time,W.title')->order('W.workid DESC')->limit(2)->select(); $this->copylist = $copylist; $this->display(); }
/** * 随拍作品详情 */ public function detail() { $workid = I('get.workid'); if (empty($workid)) { $this->error('您访问的页面不存在'); } //增加点击数 $model = M('Suipai'); $model->where(array('id' => $workid))->setInc('clicknum'); $detail = $model->find($workid); $unionModel = new Model(); $detail = $unionModel->table(array(C('DB_PREFIX') . 'user' => 'U', C('DB_PREFIX') . 'suipai' => 'S'))->where('U.userid=S.userid and S.id=' . $workid)->field('U.nickname,U.uavatar,U.openuid,U.userid,U.ifrz,S.id,S.title,S.image,S.all_pic,S.content,S.clicknum,S.msgnum')->find(); if (!$detail) { $this->error('您访问的作品不存在'); } //start yf $yf_thumb = array(); $yf_pic = array(); if (!empty($detail['all_pic'])) { $yf_arr = json_decode($detail['all_pic'], true); $yf_temp = array(); foreach ($yf_arr as $k => $v) { $yf_thumb[] = $v; $yf_ex = explode("/", $v); $yf_ex[count($yf_ex) - 1] = str_replace("yf_", "", $yf_ex[count($yf_ex) - 1]); $yf_pic[] = implode("/", $yf_ex); } } else { $yf_arr = array(); $yf_thumb[] = $yf_pic[] = $detail['image']; } $detail['pic_num'] = count($yf_thumb); $detail['thumb'] = implode(",", $yf_thumb); $detail['pic'] = implode(",", $yf_pic); //end $this->assign('data', $detail); //关注数 $this->fansnum = getCount('UserFans', array('userid' => $detail['userid'], 'status' => true)); //右侧广告 $this->rightad = parent::getAdvert(4, 3, 0, 1); //评论 $where['infoid'] = $workid; $where['type'] = 4; $where['parent_id'] = 0; //yf 0915 $count = M('UserMessage')->where($where)->count(); // $limitRows = 5; // 设置每页记录数 $limitRows = C('YF_PAGE'); $page = $this->ajaxpage($count, $limitRows, '#msg', 'ajax_div', 'ajax_page_div'); $message = $unionModel->table(array(C('DB_PREFIX') . 'user_message' => 'M', C('DB_PREFIX') . 'user' => 'U'))->where('M.userid=U.userid and M.status=true and M.infoid=' . $workid . ' and M.type=4 and M.parent_id=0')->field('M.create_time,M.content,U.nickname,U.uavatar,U.openuid,U.uprovince,U.ucity,U.userid,M.id,M.touserid')->order('M.create_time DESC')->limit($page->firstRow . ',' . $page->listRows)->select(); // foreach($message as $k=>$v){ // $message[$k]['touser']=M('User')->field('openuid,nickname')->where(array('userid'=>$v['touserid']))->find(); // } foreach ($message as $k => $v) { $child_temp = array(); $child_temp = $unionModel->table(C('DB_PREFIX') . 'user_message')->field('*')->where(array('parent_id' => $v['id']))->order('create_time ASC')->select(); $message[$k]['childlist'] = array(); if ($child_temp) { foreach ($child_temp as $yk => $yv) { if ($yv['userid'] == 0) { $child_temp[$yk]['nickname'] = "烘焙圈"; $child_temp[$yk]['openuid'] = 0; } else { $yf_user = array(); $yf_user = M('User')->field('openuid, nickname, uprovince, ucity, uavatar, ifrz')->where(array('userid' => $yv['userid']))->find(); $child_temp[$yk]['nickname'] = $yf_user['nickname']; $child_temp[$yk]['openuid'] = $yf_user['openuid']; $child_temp[$yk]['uprovince'] = $yf_user['uprovince']; $child_temp[$yk]['ucity'] = $yf_user['ucity']; $child_temp[$yk]['uavatar'] = $yf_user['uavatar']; $child_temp[$yk]['ifrz'] = $yf_user['ifrz']; } if ($yv['touserid'] != 0) { $child_temp[$yk]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $yv['touserid']))->find(); } else { $child_temp[$yk]['touser']['nickname'] = "烘焙圈"; $child_temp[$yk]['touser']['openuid'] = 0; } } $message[$k]['childlist'] = $child_temp; } $message[$k]['tempname'] = hy_substr($v['nickname'], 4, true); //$message[$k]['tempname'] = $v['nickname']; $message[$k]['touser'] = array(); if (!empty($v['touserid'])) { $message[$k]['touser'] = M('User')->field('openuid,nickname')->where(array('userid' => $v['touserid']))->find(); } } unset($where['parent_id']); $this->msgcount = M('UserMessage')->where($where)->count(); $this->msgtype = 4; $this->assign('msglist', $message); $this->assign('page', $page->show()); if (IS_AJAX) { exit($this->fetch('msglist')); //list为list.html模版 } //获取会员烘焙作品数 $this->hbworksnum = getCount('Works', array('status' => true, 'type' => 1, 'userid' => $detail['userid'])); //获取会员随拍作品数 $this->spworksnum = getCount('Suipai', array('status' => true, 'userid' => $detail['userid'])); //是否关注 $this->isfans = getCount('UserFans', array('myid' => $this->userid, 'userid' => $detail['userid'], 'status' => true)); //更多随拍作品 $map['status'] = array('EQ', true); $map['userid'] = array('EQ', $detail['userid']); $map['id'] = array('NEQ', $workid); $this->moresp = M('Suipai')->field('image,id')->where($map)->limit(6)->select(); $this->display(); }