public function getNews($list) { $news = array(); $count = 0; foreach ($list as $l) { $n = $this->where('id=' . $l)->find(); $des = explode('</br>', $n['description']); $news[$count] = array('Title' => $n['title'], 'Description' => $des[0], 'PicUrl' => getWeChatImageUrl($n['picUrl']), 'Url' => $n['url'] == null ? getWeChatDetailUrl($n['id'], 'news') : $n['url']); $count = $count + 1; } return $news; }
public function getProductNewsOfUser($openId) { $products = $this->getProductOfUser($openId); if ($products !== null) { $product_news = array(); $count = 0; foreach ($products as $p) { $product_news[$count] = array('Title' => $p['id'] . ':' . $p['name'], 'Description' => $p['description'], 'PicUrl' => getWeChatImageUrl($p['picUrl']), 'Url' => $p['url'] == null ? getWeChatDetailUrl($p['id'], 'product') : $p['url']); $count = $count + 1; } return $product_news; } return null; }
public function detail($id = 1, $type = 'product') { switch ($type) { case 'product': $product = M('Product')->find($id); if ($product !== null) { $content['title'] = $product['name']; $content['picUrl'] = getWeChatImageUrl($product['picUrl']); $content['description'] = $product['description']; } break; case 'prize': $prize = M('Prize')->find($id); if ($prize !== null) { $content['title'] = $prize['name']; $content['picUrl'] = getWeChatImageUrl($prize['picUrl']); $content['description'] = $prize['description']; } break; case 'news': $news = M('News')->find($id); if ($news !== null) { $content['title'] = $news['title']; $content['picUrl'] = getWeChatImageUrl($news['picUrl']); $content['description'] = $news['description']; } break; default: break; } $this->assign('content', $content); $this->display(); }