Authored by xuqi

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

... ... @@ -18,9 +18,9 @@ class Yohobuy
{
/* 正式环境 */
// const API_URL = 'http://api2.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL = 'http://api2.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// /* 测试环境 */
const API_URL = 'http://test2.open.yohobuy.com/';
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 购物车的数据模型
*
* @name CartData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-09 13:58:27)
* @author Gtskk <tttt6399998@126.com>
*/
class CartData
{
/**
* 购物车数据
*
* @return array 购物车接口返回的数据
*/
public static function cartData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.cart';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 个人中心的数据模型
*
* @name UserData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-09 16:30:27)
* @author Gtskk <tttt6399998@126.com>
*/
class UserData
{
/**
* 个人详情数据
*
* @param int $uid 用户ID
* @return array 个人详情接口返回的数据
*/
public static function userData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.profile';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 订单数据
*
* @param int $uid 用户ID
* @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 订单接口返回的数据
*/
public static function orderData($uid, $type, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.get';
$param['uid'] = $uid;
$param['type'] = $type;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 收藏的商品数据
*
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 收藏的商品接口返回的数据
*/
public static function favoriteProductData($uid, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.product';
$param['uid'] = $uid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 收藏的品牌数据
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 收藏的品牌接口返回的数据
*/
public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.brand';
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* YOHO币数据
*
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array YOHO币接口返回的数据
*/
public static function yohoCoinData($uid, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.lists';
$param['uid'] = $uid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 优惠券数据
*
* @param int $uid 用户ID
* @param int $status 优惠券状态,0表示未使用,1表示已使用
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 优惠券接口返回的数据
*/
public static function couponData($uid, $status, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.lists';
$param['uid'] = $uid;
$param['status'] = $status;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 地址数据
*
* @param int $uid 用户ID
* @return array 地址接口返回的数据
*/
public static function addressData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.address.get';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 意见反馈数据
*
* @param string $udid 客户端唯一标识
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 意见反馈接口返回的数据
*/
public static function suggestData($udid, $page = 1, $limit = 30)
{
$param = Yohobuy::param();
$param['udid'] = $udid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/getList', $param);
}
/**
* 提交意见反馈接口
*
* @param int $uid 用户ID
* @param string $content 意见内容
* @param int $suggest_type 意见类型
* @return array 意见反馈接口返回的数据
*/
public static function savesuggestData($uid, $content, $suggest_type, $limit = 30)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['content'] = $content;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
}
}
... ...
... ... @@ -45,9 +45,6 @@ class NewsaleData
*/
public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
{
// 构建url地址列表
$urlList = array();
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
... ... @@ -82,7 +79,6 @@ class NewsaleData
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
... ... @@ -182,4 +178,30 @@ class NewsaleData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取热销排行榜商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string|null $sort 品类ID查询参数
* @param integer|null $tab_id Tab的ID
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 新品到着商品数据
*/
public static function getTopProducts($gender, $sort = null, $tab_id = null, $limit = 50, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.top';
$param['gender'] = $gender;
!empty($sort) && $param['sort'] = $sort;
!empty($tab_id) && $param['tab_id'] = $tab_id;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -43,7 +43,7 @@ $fixTitleBar.css({
top: brandSwipe
}).hide();
minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + $('.banner-top').outerHeight();
$('.brand-list').last().append($fixTitleBar);
$brandList.last().append($fixTitleBar);
$(window).scroll(function() {
var scrTop = $(window).scrollTop();
... ... @@ -64,6 +64,19 @@ $(window).scroll(function() {
});
});
function changeBackground() {
var $brandList = $('.brand-list').find('p');
$brandList.on('touchstart', function() {
$brandList.css('background', '#fff');
$(this).css('background', '#eee');
}).on('touchend touchcancel', function() {
$(this).css('background', '#fff');
});
}
changeBackground();
function searchResult() {
var keyword = ($keyword.val() + '').toLowerCase();
var result = {},
... ... @@ -113,6 +126,7 @@ function searchResult() {
// 插入 dom,绑定事件
$('.search-result').html(html);
changeBackground();
}
if ($('.brand-search-page').length) {
... ...
... ... @@ -11,7 +11,8 @@ var $nav = $('.category-nav'),
$categoryContainer = $('.category-container'),
$contents = $categoryContainer.children('.content');
var $curContent = $contents.not('.hide');
var $curContent = $contents.not('.hide'),
$curClickSubLevel;
var navHammer, ccHammer;
... ... @@ -68,4 +69,15 @@ ccHammer.on('tap', function(e) {
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
}
});
$('.sub-level').bind('touchend', function(e) {
var $cur = $(e.target);
$cur.addClass('a-highlight');
if ($curClickSubLevel) {
$curClickSubLevel.removeClass('a-highlight');
}
$curClickSubLevel = $cur;
});
\ No newline at end of file
... ...
... ... @@ -94,6 +94,20 @@ $subNav.each(function () {
}
});
$sideNav.children('ul').children('li').on('touchstart', function() {
$sideNav.children('ul').children('li').css('background', '#fff');
$(this).css('background', '#eee');
}).on('touchend touchcancel', function() {
$(this).css('background', '#fff');
});
// $sideNav.children('ul').children('li').each(function() {
// var liHammer = new Hammer($(this)[0]);
// liHammer.on('', function() {
// });
// });
//头部banner轮播
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
... ...
... ... @@ -8,7 +8,8 @@ var $ = require('jquery');
var $searchBox = $('.search-box'),
$box = $('.box'),
$indexSearch = $('.index-search'),
$indexLogo = $('.index-logo');
$indexLogo = $('.index-logo'),
$channelLink = $('.index-channel a');
var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $box.children('.no-search'),
... ... @@ -42,6 +43,25 @@ $searchBox.children('.search-icon').on('touchstart', function() {
$indexSearch.submit();
});
$('.index-channel img').on('load', function() {
window.rePosFooter();
$channelLink.on('touchstart', function() {
$channelLink.css({
background: '#000',
color: '#fff',
borderColor: '#fff'
});
$(this).css({
background: 'rgba(255, 255, 255, 0.5)',
color: '#000',
borderColor: '#000'
});
}).on('touchend touchcancel', function() {
$(this).css({
background: '#000',
color: '#fff',
borderColor: '#fff'
});
});
$('.index-channel img').on('load error', function() {
window.rePosFooter && window.rePosFooter();
});
... ...
... ... @@ -99,7 +99,6 @@
background: #fff;
width: 60%;
height: 100%;
overflow: auto;
}
.sub-level {
... ... @@ -126,4 +125,8 @@
color: #000;
}
}
.a-highlight {
text-decoration: underline;
}
}
\ No newline at end of file
... ...
... ... @@ -10,13 +10,11 @@
line-height: 96rem / $pxConvertRem;
.index-logo {
display: table-cell;
float: left;
font-size: 50rem / $pxConvertRem;
width: 216rem / $pxConvertRem;
height: 96rem / $pxConvertRem;
color: #343434;
vertical-align: middle;
background: url(../img/yohologo.png) left center no-repeat;
background-size: 104px 25px;
opacity: 1;
transition: all 400ms;
... ...
.mine-page {
.user-info {
padding: 0 30rem / $pxConvertRem;
color: #fff;
background: #ccc;
font-size: 34rem / $pxConvertRem;
line-height: 164rem / $pxConvertRem;
height: 164rem / $pxConvertRem;
.user-avatar {
display: inline;
}
}
}
\ No newline at end of file
... ...
@import "vip-grade";
\ No newline at end of file
@import "home", "vip-grade";
\ No newline at end of file
... ...
{{> layout/header}}
<div class="mine-page yoho-page">
<div class="mine-header">
<div class="user-info">
<img class="user-avatar" src="{{head_ico}}">
<span class="username">{{profile_name}}</span>
{{#user_info}}
<span class="user-level user-level-{{cur_level}}"></span>
{{/user_info}}
</div>
<div class="iconfont more-icon">2</div>
</div>
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,6 @@
<div class="index-container">
<div class="index-header clearfix">
<div class="index-logo">
<img src="http://static.dev.yohobuy.com/img/yohologo.png">
</div>
<div class="box">
<a href="javascript:void(0);" class="no-search">取消</a>
... ...
<?php
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 个人中心相关的控制器
... ... @@ -18,8 +19,125 @@ class HomeController extends AbstractAction
*/
public function indexAction()
{
// 目前跳到老站
// $this->go(OLD_MAIN . '/home');
// $uid = $uid = $this->getUid();
$uid = 967016;
$data = \Index\UserModel::getUserProfileData($uid);
// print_r($data);
$data['homeHeader'] = array('searchUrl' => Helpers::url('/search', null, 'search'));
$data['pageFooter'] = true;
// 设置网站标题
$this->setTitle('男生首页');
$this->_view->display('index', $data);
}
/**
* 用户订单
*/
public function ordersAction()
{
$uid = $this->getUid();
$type = $this->get('type', 1);
$orders = \Index\UserModel::getUserOrderData(967016, $type);
print_r($orders);
}
/**
* 用户收藏的商品
*/
public function favoriteAction()
{
$uid = $this->getUid();
$favProducts = \Index\UserModel::getFavProductData($uid);
print_r($favProducts);
}
/**
* 用户收藏的品牌
*/
public function favoritebrandAction()
{
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
print_r($favBrands);
}
/**
* YOHO币
*/
public function currencyAction()
{
$uid = $this->getUid();
$favBrands = \Index\UserModel::getYohoCoinData($uid);
print_r($favBrands);
}
/**
* 优惠券
*/
public function couponsAction()
{
$uid = $this->getUid();
$status = $this->get('status', 0);
$coupons = \Index\UserModel::getCouponData($uid, $status);
print_r($coupons);
}
/**
* 地址管理
*/
public function addressAction()
{
$uid = $this->getUid();
$address = \Index\UserModel::getAddressData($uid);
print_r($address);
}
/**
* 意见反馈
*/
public function suggestAction()
{
$udid = $this->getUdid();
$page = $this->get('page', 1);
$limit = $this->get('limit', 30);
$suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);
print_r($suggest);
}
/**
* 异步保存意见反馈数据
*/
public function savesuggestAction()
{
if($this->isAjax()) {
$uid = $this->getUid();
$content = $this->post('content', '');
$suggest_type = $this->get('suggest_type', 2);
$result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type);
$this->echoJson($result);
}
}
}
... ...
... ... @@ -9,80 +9,17 @@ class ShoppingCartController extends AbstractAction
{
public function indexAction()
{
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$uid = $this->getUid();
$data = array(
'cartNav' => true,
'commonGoodsCount' => 2,
'presellGoodsCount' => 2,
'showLoginInfo' => true,
'commonCart' => array(
'goods' => array(
array(
'id' => 1,
'name' => '黄伟文Wyman X y yohood 联名商品YYYOHOOD圆领卫衣',
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
'color' => '黄色',
'size' => 'F',
'appearDate' => '12月',
'price' => 399.00,
'count' => 8,
'lowStocks' => true
),
array(
'id' => 2,
'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'color' => '黄色',
'size' => 'F',
'price' => 553.00,
'count' => 1,
'soldOut' => true
)
),
'freebieOrAdvanceBuy' => true,
'freebie' => array(
'url' => '',
'count' => 2
),
'advanceBuy' => array(
'url' => '',
'count' => 3
),
'price' => 3192,
'activityPrice' => 0,
'count' => 8,
'sumPrice' => 3192
),
'preSellCart' => array(
'goods' => array(
array(
'id' => 2,
'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'color' => '黄色',
'size' => 'F',
'price' => 553.00,
'count' => 1,
'soldOut' => true
)
),
'freebieOrAdvanceBuy' => true,
'freebie' => array(
'url' => '',
'count' => 2
),
'advanceBuy' => array(
'url' => '',
'count' => 3
),
'price' => 553,
'activityPrice' => 0,
'count' => 1,
'sumPrice' => 553
)
'shoppingCartPage' => true,
'shoppingCart' => \Index\CartModel::getCartData($uid)
);
// 渲染模板
$this->_view->display('index', array('shoppingCartPage' => true, 'pageHeader' => array(
'navBack' => 'http://m.yohobuy.com', 'navTitle' => '购物车'), 'shoppingCart' => $data));
$this->_view->display('index', $data);
}
public function giftAdvanceAction()
... ...
<?php
namespace Index;
use LibModels\Wap\Home\CartData;
use Plugin\Images;
/**
*
* @name CartModel
* @package models/Index
* @copyright yoho.inc
* @version 1.0 (2015-11-09 14:05:09)
* @author Gtskk (tttt6399998@126.com)
*/
class CartModel
{
/**
* @param integer $uid 用户ID
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid)
{
$result = array(
'cartNav' => true,
'showLoginInfo' => true
);
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data)
{
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_id'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
return $result;
}
}
... ...
<?php
namespace Index;
use LibModels\Wap\Home\UserData;
use Plugin\Images;
/**
*
* @name UserModel
* @package models/Index
* @copyright yoho.inc
* @version 1.0 (2015-11-09 14:05:09)
* @author Gtskk (tttt6399998@126.com)
*/
class UserModel
{
/**
* 处理用户个人详情数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的个人详情数据
*/
public static function getUserProfileData($uid)
{
$result = array();
// 调用接口获取个人详情
$userData = UserData::userData($uid);
// 处理个人详情数据
if (isset($userData['data']) && !empty($userData['data'])) {
$result = $userData['data'];
$result['head_ico'] = Images::getImageUrl($result['head_ico'], 150, 150);
}
return $result;
}
/**
* 处理用户订单数据
*
* @param int $uid 用户ID
* @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
* @return array|mixed 处理之后的个人详情数据
*/
public static function getUserOrderData($uid, $type)
{
$result = array();
// 调用接口获取用户订单数据
$orderData = UserData::orderData($uid, $type);
// 处理用户订单数据
if (isset($orderData['data']) && !empty($orderData['data'])) {
$result = $orderData['data'];
}
return $result;
}
/**
* 处理用户收藏的商品数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的收藏的商品数据
*/
public static function getFavProductData($uid)
{
$result = array();
// 调用接口获取用户收藏的商品数据
$favProduct = UserData::favoriteProductData($uid);
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && !empty($favProduct['data'])) {
$result = $favProduct['data'];
}
return $result;
}
/**
* 处理用户收藏的品牌数据
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @return array|mixed 处理之后的收藏的品牌数据
*/
public static function getFavBrandData($uid, $gender)
{
$result = array();
// 调用接口获取户收藏的品牌数据
$favBrand = UserData::favoriteBrandData($uid, $gender);
// 处理用户收藏的品牌数据
if (isset($favBrand['data']) && !empty($favBrand['data'])) {
$result = $favBrand['data'];
}
return $result;
}
/**
* 处理YOHO币数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的YOHO币数据
*/
public static function getYohoCoinData($uid)
{
$result = array();
// 调用接口获取YOHO币
$yohoCoin = UserData::yohoCoinData($uid);
// 处理YOHO币数据
if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) {
$result = $yohoCoin['data'];
}
return $result;
}
/**
* 处理优惠券数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的优惠券数据
*/
public static function getCouponData($uid, $status)
{
$result = array();
// 调用接口获取优惠券数据
$coupons = UserData::couponData($uid, $status);
// 处理优惠券数据
if (isset($coupons['data']) && !empty($coupons['data'])) {
$result = $coupons['data'];
}
return $result;
}
/**
* 处理地址数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的地址数据
*/
public static function getAddressData($uid)
{
$result = array();
// 调用接口获取地址数据
$address = UserData::addressData($uid);
// 处理地址数据
if (isset($address['data']) && !empty($address['data'])) {
$result = $address['data'];
}
return $result;
}
/**
* 处理意见反馈数据
*
* @param string $udid 客户端唯一标识
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array|mixed 处理之后的意见反馈数据
*/
public static function getSuggestData($udid, $page, $limit)
{
$result = array();
// 调用接口获取地址数据
$suggest = UserData::suggestData($udid, $page, $limit);
print_r($suggest);
// 处理意见反馈数据
if (isset($suggest['data']) && !empty($suggest['data'])) {
$result = $suggest['data'];
}
return $result;
}
/**
* 保存意见反馈数据
*
* @param int $uid 用户ID
* @param string $content 意见内容
* @param int $suggest_type 意见类型
* @return array|mixed 保存意见反馈数据之后的返回
*/
public static function saveSuggestData($uid, $content, $suggest_type)
{
$result = array();
// 调用接口保存意见反馈数据
return UserData::savesuggestData($uid, $content, $suggest_type);
}
}
... ...
... ... @@ -226,6 +226,24 @@ class NewsaleModel
return $result;
}
/**
* 筛选出来的热销排行榜商品数据处理
*
* @param array $data 筛选出来的原数据
* @return array 处理之后的数据
*/
public static function selectTopData($data)
{
$result = array();
if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list'])) {
$result = NewSaleProcess::newSaleData($data['data']);
unset($result['filter']);
}
return $result;
}
/**
* 获取筛选数据
... ...
... ... @@ -79,23 +79,48 @@ class NewsaleController extends AbstractAction
$this->setTitle('热销排行榜');
$this->setNavHeader('热销排行榜');
$channel = Helpers::getChannelByCookie();
// 设置一些默认参数
$data = array(
'discountPage' => true,
'headerBanner' => \Product\NewsaleModel::getNewFocus($channel),
'showDownloadApp' => true,
'pageFooter' => true,
'brand' => '0',
'sort' => '0',
'gender' => Helpers::getGenderByCookie(),
'price' => '0',
'size' => '0',
'discount' => '0.1,0.9',
'cartUrl' => Helpers::url('/cart/index/index', null),
);
$this->_view->display('hotrank', $data);
}
/**
* Ajax方式获取热销排行榜商品
*
* @return array 根据指定条件筛选之后的商品
*/
public function selectHotrankAction()
{
$result = array();
if ($this->isAjax()) {
$sort = $this->get('sort', null);
$tab_id = $this->get('tab_id', null);
$limit = $this->get('limit', 50);
$page = $this->get('page', 1);
// 获取性别
$gender = Helpers::getGenderByCookie();
$data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page);
$result = \Product\NewsaleModel::selectTopData($data);
}
if (empty($result)) {
echo ' ';
} else {
$this->_view->display('product', $result);
}
}
/**
* Ajax方式筛选新品到着、折扣专区商品
*
... ...