Authored by Rock Zhang

完成个人中心部分功能

... ... @@ -34,6 +34,38 @@ class UserData
}
/**
* 个人中心页面优惠券,收藏的商品等的数目数据
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
public static function infoNum($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.home.getInfoNum';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 个人中心页面优选新品数据
*
* @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
* @return array 接口返回的数据
*/
public static function preference($yh_channel)
{
$param = Yohobuy::param();
$param['method'] = 'app.home.preference';
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 订单数据
*
* @param int $uid 用户ID
... ... @@ -192,4 +224,37 @@ class UserData
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
}
/**
* 我的消息接口
*
* @param int $uid 用户ID
* @param int $page 获取第一页,默认是0
* @param int $size 获取数目,默认是10
* @return array 消息接口返回的数据
*/
public static function messageData($uid, $page = 0, $size = 10)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['size'] = $size;
$param['page'] = $page;
$param['method'] = 'app.inbox.getlist';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 在线客服接口
*
* @return array 消息接口返回的数据
*/
public static function onlineServiceData()
{
$param = Yohobuy::param();
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v1/help/getCategory', $param);
}
}
... ...
... ... @@ -12,15 +12,15 @@
</div>
<div class="my-link clearfix">
<a class="link-item" href="/home">
15
{{product_favorite_total}}
<p>收藏的商品</p>
</a>
<a class="link-item" href="/home">
6
{{brand_favorite_total}}
<p>收藏的品牌</p>
</a>
<a class="link-item" href="/home">
8
{{product_browse}}
<p>浏览记录</p>
</a>
</div>
... ... @@ -57,19 +57,19 @@
<div class="list-item">
<span class="iconfont icon">&#xe620;</span>
优惠券
<span class="iconfont num">6 &#xe604;</span>
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</div>
<div class="list-item">
<span class="iconfont icon">&#xe620;</span>
YOHO
<span class="iconfont num">8 &#xe604;</span>
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
</div>
</div>
<div class="group-list">
<div class="list-item">
<span class="iconfont icon">&#xe620;</span>
消息
<span class="iconfont num">3 &#xe604;</span>
<span class="iconfont num">{{inbox_total}} &#xe604;</span>
</div>
</div>
<div class="group-list">
... ...
... ... @@ -22,18 +22,24 @@ class HomeController extends AbstractAction
{
// 设置网站标题
$this->setTitle('个人中心');
$this->setNavHeader('个人中心', true, SITE_MAIN);
// $uid = $this->getUid();
$uid = 967016;
$data = \Index\UserModel::getUserProfileData($uid);
$data += \Index\UserModel::getInfoNumData($uid);
// 优选新品数据
$channel = Helpers::getChannelByCookie();
$data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
// print_r($data);
// print_r($data);
$data['homeHeader'] = array(
'myHomePage' => true,
'searchUrl' => Helpers::url('/search', null, 'search')
);
$data['recommendForYou'] = array(
/*$data['recommendForYou'] = array(
'recommendList' => array(
array(
'img' => '',
... ... @@ -81,7 +87,7 @@ class HomeController extends AbstractAction
'oldPrice' => '876.44'
)
)
);
);*/
$data['myIndexPage'] = true;
$data['pageFooter'] = true;
... ... @@ -180,13 +186,12 @@ class HomeController extends AbstractAction
public function currencyAction()
{
// $uid = $this->getUid();
$this->setNavHeader('YOHO币', true, false);
$uid = 967016;
$favBrands = \Index\UserModel::getYohoCoinData($uid);
$currency = \Index\UserModel::getYohoCoinData($uid);
print_r($favBrands);
$this->_view->display('currency', array('yohoCoin' => array('coinNum' => 0)));
$this->_view->display('currency', $currency);
}
/**
... ... @@ -207,6 +212,22 @@ class HomeController extends AbstractAction
}
/**
* 我的消息
*/
public function messageAction()
{
// $uid = $this->getUid();
$page = $this->get('page', 0);
$size = $this->get('size', 10);
$uid = 967016;
$messages = \Index\UserModel::getMessageData($uid, $page, $size);
print_r($messages);
}
/**
* 地址管理
*/
public function addressAction()
... ... @@ -219,6 +240,16 @@ class HomeController extends AbstractAction
}
/**
* 在线客服
*/
public function onlineServiceAction()
{
$service = \Index\UserModel::getOnlineServiceData();
print_r($service);
}
/**
* 我的逛
*/
public function myGuangAction()
... ...
... ... @@ -3,6 +3,7 @@
namespace Index;
use LibModels\Wap\Home\UserData;
use Plugin\Helpers;
use Plugin\Images;
/**
... ... @@ -32,8 +33,55 @@ class UserModel
// 处理个人详情数据
if (isset($userData['data']) && !empty($userData['data'])) {
$result = $userData['data'];
$result['head_ico'] = Images::getImageUrl($result['head_ico'], 128, 128);
}
$result['head_ico'] = Images::getImageUrl($result['head_ico'], 150, 150);
return $result;
}
/**
* 处理个人中心页面优惠券,收藏的商品等的数目数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的个人中心页面优惠券,收藏的商品等的数目数据
*/
public static function getInfoNumData($uid)
{
$result = array();
// 调用接口获取个人中心页面优惠券,收藏的商品等的数目数据
$infoNumData = UserData::infoNum($uid);
// 处理个人中心页面优惠券,收藏的商品等的数目数据
if (isset($infoNumData['data']) && !empty($infoNumData['data'])) {
// 把没有数据的条目设置为0
foreach ($infoNumData['data'] as &$val) {
empty($val) && $val = 0;
}
$result = $infoNumData['data'];
}
return $result;
}
/**
* 处理个人中心页面优选新品数据
*
* @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
* @return array|mixed 处理之后的个人中心页面优选新品数据
*/
public static function getPreferenceData($yh_channel)
{
$result = array();
// 调用接口获取个人中心页面优选新品数据
$preferenceData = UserData::preference($yh_channel);
// 处理个人中心页面优选新品数据
if (isset($preferenceData['data']) && !empty($preferenceData['data'])) {
foreach ($preferenceData['data'] as $val) {
$result['recommendList'][] = Helpers::formatProduct($val, false);
}
}
return $result;
... ... @@ -56,8 +104,38 @@ class UserModel
// 处理用户订单数据
if (isset($orderData['data']) && !empty($orderData['data'])) {
$result = $orderData['data'];
$oneOrder = array();
foreach ($orderData['data']['order_list'] as $val) {
$oneOrder = array();
$oneOrder['orderNum'] = $val['order_code'];
$oneOrder['tradingStatus'] = $val['status_str'];
$oneOrder['count'] = count($val['order_goods']);
$oneOrder['sumCost'] = $val['amount'];
$oneOrder['unpaid'] = !$val['payment'];
// 处理订单商品
$oneGoods = array();
foreach ($val['order_goods'] as $goods) {
$oneGoods = array();
$oneGoods['id'] = 1;
$oneGoods['thumb'] = Helpers::getImageUrl($goods['goods_image'], 60, 80);
$oneGoods['name'] = $val['product_name'];
$oneGoods['color'] = $val['color_name'];
$oneGoods['size'] = $val['size_name'];
$oneGoods['size_name'] = $val['size_name'];
$oneGoods['price'] = $val['goods_price'];
$oneGoods['count'] = $val['buy_number'];
$result['goods'][] = $oneGoods;
}
$result['orders'][] = $oneOrder;
}
}
print_r($result);
return $result;
}
... ... @@ -119,7 +197,7 @@ class UserModel
// 处理YOHO币数据
if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) {
$result = $yohoCoin['data'];
$result['yohoCoin']['coinNum'] = $yohoCoin['data']['total'];
}
return $result;
... ... @@ -201,10 +279,49 @@ class UserModel
*/
public static function saveSuggestData($uid, $content, $suggest_type)
{
$result = array();
// 调用接口保存意见反馈数据
return UserData::savesuggestData($uid, $content, $suggest_type);
}
/**
* 处理我的消息数据
*
* @param int $uid 用户ID
* @param int $page 获取第一页,默认是0
* @param int $size 获取数目,默认是10
* @return array|mixed 处理之后的返回
*/
public static function getMessageData($uid, $page, $size)
{
$result = array();
$messageData = UserData::messageData($uid, $page, $size);
// 处理我的消息数据
if (isset($messageData['data']) && !empty($messageData['data'])) {
$result = $messageData['data'];
}
return $result;
}
/**
* 处理在线客服数据
*
* @return array|mixed 处理之后的返回
*/
public static function getOnlineServiceData()
{
$result = array();
$serviceData = UserData::onlineServiceData();
// 处理在线客服数据
if (isset($serviceData['data']) && !empty($serviceData['data'])) {
$result = $serviceData['data'];
}
return $result;
}
}
... ...