Authored by Lynnic

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 我的逛数据模型
*
* @name GuangData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-13)
* @author xiaowei
*/
class GuangData
{
const GUANG_URI = 'guang/api/v1/favorite/';
//我的guang
public static function getGuangInfo($uid, $page, $yh_channel = 1, $gender = '1,3', $limit = 10)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['page'] = $page;
$param['gender'] = $gender;
$param['limit'] = $limit;
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
// return Yohobuy::post(Yohobuy::API_URL, $param);
return Yohobuy::post(Yohobuy::SERVICE_URL . self::GUANG_URI . 'getUserFavArticleList', $param);
}
}
... ...
... ... @@ -2,7 +2,6 @@
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
... ... @@ -18,16 +17,23 @@ class OnlineData
{
const ONLINE_URI = 'operations/api/v1/help/';
//获取帮助列表(分类)
/*
* 获取帮助列表(分类),缓存1h
* clientType客户端
*/
public static function getOnlineServiceInfo($clientType='iphone')
{
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType));
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType),3600);
}
//获取问题详情
/*
* 获取问题详情,缓存1h
* cateId问题分类ID
* clientType客户端
*/
public static function getOnlineServiceDetail($cateId, $clientType = 'iphone')
{
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType));
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType),3600);
}
}
... ...
... ... @@ -15,7 +15,7 @@
{{product_favorite_total}}
<p>收藏的商品</p>
</a>
<a class="link-item" href="/home/favoritebrand">
<a class="link-item" href="/home/favorite?tab=brand">
{{brand_favorite_total}}
<p>收藏的品牌</p>
</a>
... ...
... ... @@ -68,20 +68,26 @@ class HomeController extends AbstractAction
$this->setTitle('我的收藏');
$this->setNavHeader('我的收藏', true, SITE_MAIN);
$tab = $this->get('tab', '');
$uid = $this->getUid();
$uid = 8826435;
$gender = Helpers::getGenderByCookie();
$favProducts = \Index\UserModel::getFavProductData($uid);
$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
$this->_view->display('favorite', array(
'favPage' => true, //加载js
'pageFooter' => true,
'favorite' => true,
'hasFavProduct' => $favProducts,
'hasFavBrand' => $favBrands
));
$data = array(
'favPage' => true, //加载js
'pageFooter' => true,
'favorite' => true,
'hasFavProduct' => $favProducts,
'hasFavBrand' => $favBrands
);
// 判断时候为品牌页
if ($tab === 'brand') {
$data['brandTab'] = true;
}
$this->_view->display('favorite', $data);
}
/**
... ... @@ -106,19 +112,6 @@ class HomeController extends AbstractAction
}
/**
* 用户收藏的品牌
*/
public function favoritebrandAction()
{
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
print_r($favBrands);
}
/**
* 个人信息
*/
public function personalDetailsAction()
... ... @@ -314,7 +307,14 @@ class HomeController extends AbstractAction
*/
public function myGuangAction()
{
echo 'My Guang';
$page = $this->get('page', 1);
$limit = $this->get('limit', 10);
$uid = $this->getUid();
$yh_channel = Helpers::getChannelByCookie();
$uid=5687179;
$gender = Helpers::getGenderByCookie();
$guangInfo = \home\GuangModel::getMyGuang($uid, $page,$yh_channel,$gender, $limit);
$this->_view->display('my-guang', array('myGuang'=>$guangInfo));
}
/**
... ...
<?php
namespace Home;
use LibModels\Wap\Home\GuangData;
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 我的逛数据处理
*/
class GuangModel
{
//获取我的逛列表
public static function getMyGuang($uid, $page,$yh_channel=1, $gender = '1,3', $limit = 10)
{
$result = array();
//调用接口获取数据
$res = GuangData::getGuangInfo($uid, $page, $yh_channel,$gender, $limit);
$guangInfo = $res['data']['data'];
if ($guangInfo)
{
foreach ($guangInfo as $k => $v)
{
$result[$k]['id'] = $v['id'];
$result[$k]['author'] = $v['author'];
$tag = self::getTag(TRUE, intval($v['category_id']));
$result[$k]['url'] = $v['url'];
$result[$k]['img'] = $v['src'];
$result[$k]['title'] = $v['title'];
$result[$k]['text'] = $v['intro'];
$result[$k]['pageView'] = $v['views_num'];
$result[$k]['publish_time'] = $v['publish_time'];
$like = ($v['isPraise'] == "Y") ? true : false;
$collect = ($v['isFavor'] == "Y") ? true : false;
$result[$k]['like'] = array('isLiked' => $like, 'count' => $v['praise_num']);
$result[$k]['collect'] = array('isCollected' => $collect, 'url' => $v['url']);
$result[$k] += $tag;
$result[$k]['share'] = $v['url'];
}
}
return $result;
}
//【标签】isTip-小贴士;isCollocation-搭配 isFashionMan-潮人 isFashionGood-潮品 isTopic-话题
private static function getTag($isShow, $tagId)
{
$ret['showTags'] = $isShow;
$ret['isTopic'] = false;
$ret['isCollocation'] = false;
$ret['isFashionMan'] = false;
$ret['isFashionGood'] = false;
$ret['isTip'] = false;
switch ($tagId)
{
case 1:
$ret['isTopic'] = true;
break;
case 2:
$ret['isCollocation'] = true;
break;
case 3:
$ret['isFashionMan'] = true;
break;
case 4:
$ret['isFashionGood'] = true;
break;
case 5:
$ret['isTip'] = true;
break;
default:
$ret['showTags'] = FALSE;
break;
}
return $ret;
}
}
... ...
... ... @@ -162,7 +162,7 @@ class UserModel
$product['price'] = '¥'.$val['market_price'];
$product['discountPrice'] = '¥'.$val['sales_price'];
$product['savePrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.($val['market_price'] - $val['sales_price']) : false;
$product['sellOut'] = boolval($val['price_down']);
$product['sellOut'] = (bool)($val['price_down']);
$result[] = $product;
}
... ... @@ -432,7 +432,7 @@ class UserModel
$one['imgUrl'] = Helpers::getImageUrl($val['cover_image'], 640, 240);
$one['title'] = $val['filter_content'];
$one['content'] = $val['reply_content'];
$one['good'] = boolval($val['is_reliable']);
$one['good'] = (bool)($val['is_reliable']);
$one['bad'] = !$one['good'];
$result[] = $one;
... ...
... ... @@ -11,7 +11,10 @@ use Plugin\Helpers;
class OnlineModel
{
//获取在线帮助分类
/*
* 获取在线帮助分类
* $clientType客户端类型
*/
public static function getOnlineServiceInfo($clientType = 'iphone')
{
//调用接口获取数据
... ... @@ -19,10 +22,13 @@ class OnlineModel
$cateInfo = $res['data'];
$question = array();
$tab = array();
if ($cateInfo) {
foreach ($cateInfo as $key => $value) {
if ($cateInfo)
{
foreach ($cateInfo as $key => $value)
{
//强制截成3个tab
if ($key > 2) {
if ($key > 2)
{
break;
}
$tab[$key]['tabid'] = 'tab' . $value['id'];
... ... @@ -33,10 +39,12 @@ class OnlineModel
$question[$key]['current'] = (!$key) ? TRUE : FALSE;
$sub = $value['sub'];
$qTmp = array();
if ($sub) {
foreach ($sub as $sk => $sv) {
if ($sub)
{
foreach ($sub as $sk => $sv)
{
$qTmp[$sk]['title'] = $sv['category_name'];
$qTmp[$sk]['link'] = '/home/onlineservicedetail?cateId=' . $sv['id'] . '&cateName=' . $sv['category_name'];
$qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail',array('cateId'=>$sv['id'],'cateName'=>$sv['category_name']));
}
}
$question[$key]['list'] = $qTmp;
... ... @@ -54,19 +62,27 @@ class OnlineModel
return $result;
}
//加载分类下的问题和解决方法
/*
* 加载分类下的问题和解决方法
* cateId问题分类ID
* clientType客户端
*/
public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone')
{
$result = array();
if (!$cateId) {
if (!$cateId)
{
return $result;
}
$res = OnlineData::getOnlineServiceDetail($cateId, $clinetType);
$questionInfo = $res['data'];
if ($questionInfo) {
if ($questionInfo)
{
$list = array();
if ($questionInfo) {
foreach ($questionInfo as $qk => $qv) {
if ($questionInfo)
{
foreach ($questionInfo as $qk => $qv)
{
$list[$qk]['q'] = $qv['title'];
$list[$qk]['a'] = $qv['content'];
}
... ...