Authored by Lynnic

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

... ... @@ -5,7 +5,8 @@
*/
var $ = require('jquery'),
tip = require('../plugin/tip');
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
var $action = $('.action'),
$addressForm = $('.edit-address'),
... ... @@ -18,28 +19,32 @@ var $action = $('.action'),
$confim = $('.confim-mask'),
$pageWrap = $('.page-wrap'),
$backBtn = $('.nav-back'),
$addressItem = $('.address-item'),
$navTitle = $('.nav-title'),
isSubmiting,
deleteId,
currentPage = 'address',
newArea = [];
// 清除原有链接
// 清除返回按钮原有链接
$backBtn.attr('href', 'javascript:void(0);');
window.rePosFooter();
// 自定义事件
// 自定义返回按钮事件
$backBtn.on('touchend', function(e) {
if (currentPage === 'edit') {
$pageWrap.hide();
$pageWrap.first().show();
e.preventDefault();
currentPage = 'address';
$navTitle.html('地址管理');
} else if (currentPage === 'list') {
$pageWrap.hide();
$editAddressPage.show();
e.preventDefault();
currentPage = 'edit';
$navTitle.html('修改地址');
} else {
window.history.go(-1);
}
... ... @@ -64,6 +69,7 @@ $confim.on('touchend', '.cancel', function() {
deleteId = null;
$confim.hide();
}).on('touchend', '.confim', function() {
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/home/deladdress',
... ... @@ -84,17 +90,24 @@ $confim.on('touchend', '.cancel', function() {
}).always(function() {
deleteId = null;
$confim.hide();
loading.hideLoadingMask();
});
});
// 添加地址
$addAddress.on('touchend', function() {
if ($addressItem.length >= 5) {
tip.show('您最多添加5个收货地址');
return false;
}
editAddress();
$navTitle.html('添加新地址');
});
// 编辑或删除
$action.on('touchend', '.edit', function() {
editAddress($(this).data());
$navTitle.html('修改地址');
}).on('touchend', '.del', function() {
deleteId = $(this).data('id');
$confim.show();
... ... @@ -132,6 +145,7 @@ $addressForm.on('submit', function() {
}
isSubmiting = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/home/saveaddress',
... ... @@ -149,6 +163,7 @@ $addressForm.on('submit', function() {
tip.show('网络出了点问题~');
}).always(function() {
isSubmiting = false;
loading.hideLoadingMask();
});
return false;
});
... ... @@ -177,6 +192,7 @@ $addressListPage.on('touchend', '.address', function() {
$editAddressPage.show();
currentPage = 'edit';
$navTitle.html('修改地址');
// 恢复默认的三级选择
$addressListPage.hide();
... ...
... ... @@ -8,6 +8,6 @@ $('.employ span').each(function(index) {
employ.on('tap', function(e) {
$('.employ-list').addClass('none').eq(index).removeClass('none');
$('.employ span').removeClass('active').eq(index).addClass('active');
window.rePosFooter();
window.rePosFooter();
});
});
\ No newline at end of file
... ...
... ... @@ -12,44 +12,117 @@ var diaLog = require('./dialog');
var $navLi = $('#fav-tab > li'),
$favContainer = $('.fav-content > .fav-type'),
$swiperList = $('.swiper-container'),
$swiperList = '',
swiperObj = {},
favTabHammer,
favContentHammer;
favContentHammer,
footerH = $('#yoho-footer').height(),
$loadMore = $('.fav-load-more'),
$brandLoadMore = $('.fav-brand-load-more'),
winH = $(window).height(),
$favProductList = $('.fav-product-list'),
$favBrandList = $('.fav-brand-swiper'),
pageId = 1,
brandPageId = 1, //收藏品牌的当前页数
lockId = true,
brandLockId = true, //收藏品牌是否可下拉加载更多
brandTab = false; //当前是否停留在收藏品牌页
function showFavTab(index) {
var i,
id;
$navLi.filter('.active').removeClass('active');
$navLi.eq(index).addClass('active');
$favContainer.filter('.show').removeClass('show');
$favContainer.eq(index).addClass('show');
}
if (index === 1) {
//导航
for (i = 0; i < $swiperList.length; i++) {
id = $swiperList.eq(i).attr('data-id');
swiperObj[id] = new Swiper('#swiper-container-' + id, {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'li',
wrapperClass: 'swiper-wrapper-' + id,
lazyLoading: true,
watchSlidesVisibility: true
});
//初始化swiper
function initSwiper() {
var i,
id;
$swiperList = $('.swiper-container');
for (i = 0; i < $swiperList.length; i++) {
id = $swiperList.eq(i).attr('data-id');
console.log(id);
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
}
swiperObj[id] = new Swiper('#swiper-container-' + id, {
slidesPerView: 'auto',
grabCursor: true,
slideElement: 'li',
wrapperClass: 'swiper-wrapper-' + id,
lazyLoading: true,
watchSlidesVisibility: true
});
}
}
// 上拉加载更多
function loadData($parent, url, page) {
if (url === 'favBrand') {
brandLockId = true;
} else {
lockId = true;
}
$.ajax({
method: 'post',
url: '/home/' + url,
data: {
page: page
},
success: function(data) {
//setTimeout(function() { //模拟延时
if (url === 'favBrand') {
$brandLoadMore.addClass('hide');
} else {
$loadMore.addClass('hide');
}
if (data === ' ') {
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
} else if (data === 'end') {
$parent.closest('.fav-type').find('.fav-load-background')
.removeClass('fav-load-background').html('没有更多了');
} else if (data.length > 10) {
$parent.append(data);
if (url === 'favBrand') {
initSwiper();//如果是收藏品牌需要初始化swiper
brandLockId = false;//请求成功后解锁品牌收藏page++
} else {
lockId = false;//请求成功后解锁商品收藏page++
}
window.rePosFooter();
} else {
return;
}
window.rePosFooter();
//},1000);
}
});
}
// 如果从品牌收藏入口进入
if ($('#fav-tab').hasClass('brand-tab')) {
showFavTab(1);
loadData($favBrandList, 'favBrand', 1);
brandTab = true;
window.rePosFooter();
} else {
showFavTab(0);
loadData($favProductList, 'favProduct', 1);
brandTab = false;
window.rePosFooter();
}
favTabHammer = new Hammer(document.getElementById('fav-tab'));
... ... @@ -62,7 +135,20 @@ favTabHammer.on('tap', function(e) {
}
index = $cur.index();
if (index === 0) {
if ($favProductList.find('li').length === 0 &&
$favProductList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favProductList, 'favProduct', 1);
}
} else {
if ($favBrandList.find('div').length === 0 &&
$favBrandList.closest('.fav-type').find('.fav-null-box').hasClass('hide')) {
loadData($favBrandList, 'favBrand', 1);
}
}
showFavTab(index);
window.rePosFooter();
});
... ... @@ -117,4 +203,31 @@ favContentHammer.on('tap', function(e) {
//TODO
});
});
});
// 上拉加载更多
$(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - footerH) {
if (brandTab) {
$brandLoadMore.filter('.hide').removeClass('hide');
if (!brandLockId) {
brandPageId++;
}
} else {
$loadMore.filter('.hide').removeClass('hide');
if (!lockId) {
console.log(222);
pageId++;
loadData($favProductList, 'favProduct', pageId);
}
}
}
});
\ No newline at end of file
... ...
... ... @@ -18,3 +18,10 @@ $questionTab.on('touchend', function() {
$('.question-list').removeClass('current');
$(clickTab).addClass('current');
});
$('.yoho-page').on('touchstart', '.connect-item, .question-item', function() {
$(this).siblings().removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', '.connect-item, .question-item', function() {
$(this).removeClass('highlight');
});
... ...
... ... @@ -26,6 +26,8 @@ var inAjax = false;
var loading = require('../plugin/loading');
var dialog = require('./dialog');
var orderHammer;
//加载订单
... ... @@ -110,36 +112,52 @@ orderHammer.on('tap', function(e) {
if ($cur.closest('.del').length > 0) {
//Order delete
$.ajax({
type: 'GET',
url: '/home/delOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//删除订单页面刷新
location.href = location.href;
}
dialog.showDialog({
dialogText: '确定删除订单吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
type: 'GET',
url: '/home/delOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//删除订单页面刷新
location.href = location.href;
}
}
});
});
} else if ($cur.closest('.cancel').length > 0) {
//Order cancel
$.ajax({
type: 'GET',
url: '/home/cancelOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//取消订单页面刷新
location.href = location.href;
}
dialog.showDialog({
dialogText: '确定取消订单吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
type: 'GET',
url: '/home/cancelOrder',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
//取消订单页面刷新
location.href = location.href;
}
}
});
});
} else {
... ...
... ... @@ -7,6 +7,7 @@
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
lazyLoad = require('yoho.lazyload'),
Handlebars = require('yoho.handlebars');
var diaLog = require('./dialog');
... ... @@ -53,6 +54,8 @@ $('#upload-img').uploadifive({
}
});
lazyLoad();
headerNavHammer = new Hammer(document.getElementById('yoho-header'));
headerNavHammer.on('tap', function(e) {
... ... @@ -99,6 +102,7 @@ if (document.getElementById('img-form') !== null) {
// 点赞与取消点赞
$likeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
... ... @@ -110,13 +114,8 @@ $likeBtn.bind('click', function() {
}
}).then(function(data) {
if (data.code === 200) {
if ($that.hasClass('active')) {
$that.closest('.suggest-type').removeClass('active')
.prev('.suggest-type').addClass('active');
} else {
$that.closest('.suggest-type').addClass('active')
.next('.suggest-type').removeClass('active');
}
$that.closest('.suggest-type').removeClass('show');
$('.suggest-good').addClass('show');
}
}).fail(function(data) {
... ... @@ -125,6 +124,7 @@ $likeBtn.bind('click', function() {
});
$disLikeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
... ... @@ -136,7 +136,8 @@ $disLikeBtn.bind('click', function() {
}
}).then(function(data) {
if (data.code === 200) {
$that.toggleClass('active');
$that.closest('.suggest-type').removeClass('show');
$('.suggest-bad').addClass('show');
}
}).fail(function(data) {
... ...
... ... @@ -7,18 +7,24 @@ var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../../plugin/tip');
var likeHammer = new Hammer(document.getElementById('likeBtn'));
var likeHammer = new Hammer(document.getElementById('likeBtn')),
addToCartHammer = new Hammer(document.getElementById('addtoCart'));
var productId = $('#productId').val();
likeHammer.on('tap', function(e) {
var productId = $('#productId').val(),
opt;
var opt,
favorite;
var $this = $(this);
if ($this.hasClass('liked')) {
opt = 'cancel';
favorite = 0;
} else {
opt = 'ok';
favorite = 1;
}
$.ajax({
... ... @@ -36,6 +42,14 @@ likeHammer.on('tap', function(e) {
} else {
tip.show(data.message);
}
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
});
}
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -44,6 +58,15 @@ likeHammer.on('tap', function(e) {
});
// $('#likeBtn').on('click', function(e) {
// return false;
// });
\ No newline at end of file
addToCartHammer.on('tap', function(e) {
// 统计代码:用于统计用户加入购物车的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
by: 1
});
}
});
... ...
... ... @@ -442,3 +442,8 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
// 用于统计点击了商品列表的第几个商品,序号从1开始计算。
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.1', 'yohobuy_m', window._ozuid, '#goods-container >div >div .good-thumb >img');
}
\ No newline at end of file
... ...
... ... @@ -137,6 +137,7 @@
bottom: pxToRem(20px);
left: 0;
width: 100%;
min-height: pxToRem(24px);
&.save-price-number {
text-indent: $width + pxToRem(10px);
... ... @@ -276,4 +277,18 @@
}
}
}
//上拉加载更多
.fav-load-more,.fav-brand-load-more {
width: 100%;
height: 2rem;
line-height: 2rem;
text-align: center;
color: #444;
&.load-background {
background: image_url('loading.gif') center center no-repeat;
@include background-size(auto 40%);
}
}
}
\ No newline at end of file
... ...
... ... @@ -31,6 +31,7 @@
margin: 0 rem(32);
border-left: 1px solid #b0b0b0;
}
}
.question-list {
... ... @@ -43,15 +44,15 @@
}
li {
margin-left: rem(30);
width: rem(610);
font-size: rem(28);
line-height: rem(90);
border-bottom: 1px solid #ccc;
a {
display: block;
color: #444;
width: rem(610);
margin-left: rem(30);
border-bottom: 1px solid #ccc;
}
.iconfont {
... ... @@ -64,6 +65,10 @@
&:last-child {
border-bottom: none;
}
&.highlight {
background: #eee;
}
}
}
... ... @@ -112,6 +117,9 @@
content: none;
}
}
&.highlight {
background: #eee;
}
}
.icon {
display: inline-block;
... ... @@ -132,6 +140,7 @@
border-bottom: 1px solid #c8c7cc;
color: #444;
background: #fff;
&:last-child {
margin-bottom: 0;
}
... ... @@ -146,6 +155,7 @@
.question {
@extend %qa;
position: relative;
color: #000;
&:after {
content: '';
position: absolute;
... ...
... ... @@ -28,7 +28,6 @@
>span{
&:first-of-type{
color: #444;
line-height:100rem / $pxConvertRem;
}
width: 42%;
height: 100%;
... ...
... ... @@ -66,22 +66,47 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
color: #b0b0b0;
font-size: pxToRem(26px);
display: none;
text-align: center;
&.suggest-active {
> div {
width: 50%;
float: left;
text-align: left;
padding-left: pxToRem(128px);
@include box-sizing();
&:nth-last-of-type(1) {
padding-left: pxToRem(0);
padding-right: pxToRem(128px);
text-align: right;
float: right;
> span {
display: inline-block;
height: 100%;
overflow: hidden;
&:nth-of-type(1) {
@include rotate(180deg);
}
}
}
}
}
> div {
width: 50%;
float: left;
text-align: left;
padding-left: pxToRem(128px);
@include box-sizing();
> .active {
color: #444;
}
&:nth-last-of-type(1) {
padding-left: pxToRem(0);
padding-right: pxToRem(128px);
text-align: right;
float: right;
&.show {
display: block;
}
&.suggest-bad {
> div {
> span {
display: inline-block;
height: 100%;
overflow: hidden;
... ... @@ -91,18 +116,6 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
}
}
}
&.active {
color: #444;
}
}
&.active {
text-align: center;
color: #444;
}
&.show {
display: block;
}
}
}
... ... @@ -110,8 +123,8 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
//发表意见
.create-new-suggest {
display: inline-block;
color: #444;
display: block;
width: 100%;
height: pxToRem(88px);
line-height: pxToRem(88px);
... ... @@ -120,6 +133,11 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
a {
color: #444;
display: block;
}
> span {
color: #b0b0b0;
font-size: pxToRem(26px);
... ...
... ... @@ -41,15 +41,9 @@
.price {
position: relative;
margin-top: pxToRem(20px);
font-size: pxToRem(20px);
font-size: pxToRem(12px);
line-height: 1;
span {
display: inline-block;
// chrome 最小支持12px, 设计图是 10px ,用CSS3变换
@include transform(scale(0.875));
}
.sale-price {
color: #d9134f;
margin-right: pxToRem(8px);
... ...
... ... @@ -19,7 +19,7 @@
<div class="confim-mask hide">
<div class="confim-box">
<div class="content">
你确定要删除地址吗
您确定要删除地址
</div>
<div class="action">
<span class="cancel">
... ...
... ... @@ -15,7 +15,7 @@
{{^ used}}
<div class="null">
<i></i>
<p>您还没有未使用的优惠券</p>
<p>您还没有优惠券!</p>
<a href="{{topURL}}">随便逛逛</a>
</div>
{{/ used}}
... ... @@ -32,7 +32,7 @@
{{^ unused}}
<div class="null">
<i></i>
<p>您还没有已使用的优惠券</p>
<p>您还没有使用的优惠券!</p>
<a href="{{topURL}}">随便逛逛</a>
</div>
{{/ unused}}
... ...
... ... @@ -7,22 +7,22 @@
</ul>
<div class="fav-content" id="fav-content">
<div class="fav-type">
<ul class="fav-product-list">
{{> home/favorite_product_list}}
</ul>
<ul class="fav-product-list"></ul>
{{^ hasFavProduct}}
<span class="fav-null">您暂无收藏任何商品</span>
<a class="go-shopping" href="{{productUrl}}">随便逛逛</a>
{{/ hasFavProduct}}
<div class="fav-null-box hide">
<span class="fav-null">您暂无收藏任何商品</span>
<a class="go-shopping" href="{{productUrl}}">随便逛逛</a>
</div>
<div class="fav-load-more fav-load-background hide"></div>
</div>
<div class="fav-type">
{{> home/favorite_brand_list}}
<div class="fav-brand-swiper"></div>
{{^ hasFavBrand}}
<span class="fav-null">您暂无收藏任何品牌</span>
<a class="go-shopping" href="{{brandUrl}}">随便逛逛</a>
{{/ hasFavBrand}}
<div class="fav-null-box hide">
<span class="fav-null">您暂无收藏任何品牌</span>
<a class="go-shopping" href="{{brandUrl}}">随便逛逛</a>
</div>
<div class="fav-brand-load-more load-background hide"></div>
</div>
</div>
{{/ favorite}}
... ...
... ... @@ -59,26 +59,26 @@
<a class="list-item" href="/home/address">
<span class="iconfont icon">&#xe637;</span>
地址管理
<span class="iconfont num">{{#if address_num}}{{address_num}}{{/if}} &#xe604;</span>
<span class="iconfont num">{{address_num}} &#xe604;</span>
</a>
</div>
<div class="group-list">
<a class="list-item" href="/home/coupons">
<span class="iconfont icon">&#xe63a;</span>
优惠券
<span class="iconfont num">{{#if coupon_num}}{{coupon_num}}{{/if}} &#xe604;</span>
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</a>
<a class="list-item" href="/home/currency">
<span class="iconfont icon">&#xe635;</span>
YOHO
<span class="iconfont num">{{#if yoho_coin_num}}{{yoho_coin_num}}{{/if}} &#xe604;</span>
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
</a>
</div>
<div class="group-list">
<a class="list-item" href="/home/message">
<span class="iconfont icon">&#xe636;</span>
消息
<span class="iconfont num">{{#if inbox_total}}{{inbox_total}}{{/if}} &#xe604;</span>
<span class="iconfont num">{{inbox_total}} &#xe604;</span>
</a>
</div>
<div class="group-list">
... ...
... ... @@ -9,31 +9,46 @@
<div class="suggest-content" id="suggest-content">
{{# suggestContent}}
<div class="suggest-item" data-id="{{suggest_id}}">
<img src="{{imgUrl}}" alt=""/>
{{# imgUrl}}
<img class="lazy" data-original="{{.}}" alt=""/>
{{/ imgUrl}}
<h2>{{title}}</h2>
<p>{{content}}</p>
<div class="suggest-type {{^ good}}show{{/ good}}">
<div class="suggest-type suggest-good">
<div class="active">
<span class="iconfont">&#xe601;</span>
<span>靠谱,谢谢您的反馈</span>
</div>
</div>
<div class="suggest-type suggest-bad">
<div class="active">
<span class="iconfont">&#xe601;</span>
<span>不靠谱,谢谢您的反馈</span>
</div>
</div>
{{# none}}
<div class="suggest-type suggest-active show">
<div class="like-btn">
<span class="iconfont">&#xe601;</span>
<span>靠谱</span>
</div>
<div class="dislike-btn {{# bad}}active{{/ bad}}">
<div class="dislike-btn">
<span class="iconfont">&#xe601;</span>
<span>不靠谱</span>
</div>
</div>
<div class="like-btn active suggest-type {{# good}}show{{/ good}}">
<span class="iconfont">&#xe601;</span>
<span>靠谱,谢谢您的反馈</span>
</div>
{{/ none}}
</div>
{{/ suggestContent}}
</div>
<a class="create-new-suggest" href="./suggestSub">
反馈问题<span>(功能意见,界面意见)</span>
</a>
<div class="create-new-suggest">
<a href="./suggestSub">
反馈问题<span>(功能意见,界面意见)</span>
</a>
</div>
{{/ suggest}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -124,7 +124,7 @@
{{/if}}
<a href="/shoppingCart" class="num-incart iconfont">&#xe62c;</a>
{{#if goodsInstore}}
<a href="/shoppingCart" class="addto-cart ">加入购物车</a>
<a href="/shoppingCart" id="addtoCart" class="addto-cart">加入购物车</a>
{{else}}
<a href="javascript:;" class="sold-out">已售罄</a>
{{/if}}
... ... @@ -132,11 +132,9 @@
<a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
</div>
{{/cartInfo}}
{{#if introUrl}}
<input id="introUrl" type="hidden" value={{introUrl}}>
{{/if}}
{{#if id}}
<input id="productId" type="hidden" value={{id}}>
{{/if}}
... ...
... ... @@ -95,20 +95,13 @@ class HomeController extends AbstractAction
$this->setNavHeader('我的收藏', true, SITE_MAIN);
$tab = $this->get('tab', '');
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favProducts = UserModel::getFavProductData($this->_uid, 1, 10);
$favBrands = UserModel::getFavBrandData($this->_uid, 10, 1, 10);
$data = array(
'favPage' => true, //加载js
'pageFooter' => true,
'favorite' => true,
'hasFavProduct' => $favProducts,
'productUrl' => '/product/new',
'hasFavBrand' => $favBrands,
'brandUrl' => '/product/new'
'brandUrl' => '/product/new',
);
// 判断是否为品牌收藏页
if ($tab === 'brand') {
... ... @@ -132,6 +125,8 @@ class HomeController extends AbstractAction
if (empty($result)) {
echo ' ';
} else if (isset($result['end'])) {
echo 'end';
} else {
$this->_view->display('favorite_product', $result);
}
... ... @@ -145,12 +140,15 @@ class HomeController extends AbstractAction
if ($this->isAjax()) {
$page = $this->post('page', 1);
$gender = Helpers::getGenderByCookie();
$result = UserModel::getFavBrandData($this->_uid, 10, $page, 10);
$result = UserModel::getFavBrandData($this->_uid, $gender, $page, 10);
}
if (empty($result)) {
echo ' ';
} else if (isset($result['end'])) {
echo 'end';
} else {
$this->_view->display('favorite_brand', $result);
}
... ...
... ... @@ -157,8 +157,16 @@ class UserModel
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && !empty($favProduct['data'])) {
if (isset($favProduct['data']) && !empty($favProduct['data']['product_list'])) {
if ($page > $favProduct['data']['page_total']) {
$result['end'] = true;
return $result;
}
$datas = array();
$product = array();
foreach ($favProduct['data']['product_list'] as $val) {
$product = array();
$product['fav_id'] = $val['product_id'];
... ... @@ -169,9 +177,10 @@ class UserModel
$product['savePrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.($val['market_price'] - $val['sales_price']) . '.00' : false;
$product['sellOut'] = (bool)($val['price_down']);
$result[] = $product;
$datas[] = $product;
}
!empty($datas) && $result['hasFavProduct'] = $datas;
}
return $result;
... ... @@ -182,9 +191,11 @@ class UserModel
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @param int $page 第几页
* @param int $limit 限制读取的数目
* @return array|mixed 处理之后的收藏的品牌数据
*/
public static function getFavBrandData($uid, $gender)
public static function getFavBrandData($uid, $gender, $page, $limit)
{
$result = array();
... ... @@ -192,8 +203,16 @@ class UserModel
$favBrand = UserData::favoriteBrandData($uid, $gender);
// 处理用户收藏的品牌数据
if (isset($favBrand['data']) && !empty($favBrand['data'])) {
$brand = array();
if (isset($favBrand['data']) && !empty($favBrand['data']['brand_list'])) {
if ($page > $favBrand['data']['page_total']) {
$result['end'] = true;
return $result;
}
$datas = array();
$brand = array();
foreach ($favBrand['data']['brand_list'] as $val) {
$brand = array();
$brand['id'] = $val['brand_id'];
... ... @@ -214,8 +233,10 @@ class UserModel
$brand['productList'][] = $product;
}
$result[] = $brand;
$datas[] = $brand;
}
!empty($datas) && $result['hasFavBrand'] = $datas;
}
return $result;
... ...