Authored by 梁志锋

Merge branch 'develop' of http://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();
... ...
... ... @@ -2,10 +2,12 @@ var $ = require('jquery'),
Hammer = require('yoho.hammer');
var employ;
window.rePosFooter();
$('.employ span').each(function(index) {
employ = new Hammer($('.employ span')[index]);
employ.on('tap', function(e) {
$('.employ-list').addClass('none').eq(index).removeClass('none');
$('.employ span').removeClass('active').eq(index).addClass('active');
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
... ...
... ... @@ -99,6 +99,7 @@ if (document.getElementById('img-form') !== null) {
// 点赞与取消点赞
$likeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
... ... @@ -110,13 +111,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 +121,7 @@ $likeBtn.bind('click', function() {
});
$disLikeBtn.bind('click', function() {
var id = $(this).closest('.suggest-item').attr('data-id'),
$that = $(this);
... ... @@ -136,7 +133,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) {
... ...
/**
* 商品详情 --评论和咨询tab
* @author: Lynnic
* @date: 2015/11/18
*/
var $ = require('jquery'),
tip = require('../../plugin/tip');
var commentsNum;
... ...
/**
* 商品详情
* 商品详情 --异步加载页面下半部分
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/11/18
*/
... ...
/**
* 商品详情
* 商品详情 --添加收藏
* @author: Lynnic
* @date: 2015/11/24
*/
... ...
/**
* 商品详情 --滚动页面加载
* @author: Lynnic
* @date: 2015/11/25
*/
var $ = require('jquery'),
loading = require('../../plugin/loading'),
tip = require('../../plugin/tip');
var loadMoreUrl = $('#loadMoreUrl').val(),
$commentsDiv = $('#goods-comments'),
$consultsDiv = $('#goods-consults'),
winH = $(window).height(),
searching = false,
end = false;
var jsonObj;
//插入评论列表底部
function insertCommentsDiv(json) {
var html = '';
var i;
for (i = 0; i < json.length; i++) {
html += '<div class="comment-item">';
html += '<span class="user-name">' + json[i].userName + '</span>';
html += '<span class="goods-spec">' + json[i].desc + '</span>';
html += '<span class="goods-spec">' + json[i].content + '</span>';
html += '<span class="goods-spec">' + json[i].time + '</span>';
}
$commentsDiv.append(html);
}
//插入咨询列表底部
function insertConsultsDiv(json) {
var html = '';
var i;
for (i = 0; i < json.length; i++) {
html += '<div class="consult-item"> ';
html += '<div class="question"> ';
html += '<span class="iconfont">&#xe639;</span> ';
html += '<p> ';
html += json[i].question + '<br> ';
html += '<span class="time">' + json[i].time + '</span> ';
html += '</p> ';
html += '</div> ';
html += '<div class="answer"> ';
html += '<span class="iconfont">&#xe63c;</span> ';
html += '<p>' + json[i].answer + '</p> ';
html += '</div> ';
html += '</div> ';
}
$consultsDiv.append(html);
}
function search() {
if (searching || end) {
return;
}
searching = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: loadMoreUrl,
success: function(data) {
if (data.length > 0) {
jsonObj = JSON.parse(data);
if ($commentsDiv.length > 0) {
insertCommentsDiv(jsonObj);
} else if ($consultsDiv.length > 0) {
insertConsultsDiv(jsonObj);
}
}
searching = false;
end = true;
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
search();
}
}
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
... ...
... ... @@ -34,6 +34,7 @@
background: image-url('me/employ/employ.jpg') top center no-repeat;
background-size: 100% 100%;
color: #fff;
position: relative;
span{
width: 34.482759%;
height: 100%;
... ... @@ -52,16 +53,60 @@
font-size: 60em / $pxConvertRem;
}
}
i{
width: 100%;
height: 100%;
overflow: hidden;
display: block;
position: absolute;
top: 0;
left: 0;
background: image-url('me/employ/employsy.png') right top no-repeat;
background-size:auto 100%;
}
}
.null{
text-align: center;
color: #333;
margin-top: 55%;
font-size:56em / $pxConvertRem;
color: #333;
width: 100%;
height:auto;
overflow: hidden;
position: absolute;
left: 0;
top:50%;
@include transform(translateY(-60%));
i{
width: 100%;
height: 120rem / $pxConvertRem;
overflow: hidden;
display: block;
background: image-url('me/employ/not.png') center top no-repeat;
background-size:auto 100%;
}
p{
width: 100%;
height: auto;
overflow: hidden;
padding:20rem / $pxConvertRem 0 0;
font-size: 48em / $pxConvertRem;
text-align: center;
color: #444;
}
a{
width: 73.75%;
height: 80rem / $pxConvertRem;
overflow: hidden;
font-size: 56em / $pxConvertRem;
line-height: 80rem / $pxConvertRem;
display: block;
background: #444444;
color: #fff;
text-align: center;
margin: 32em / $pxConvertRem auto;
@include border-radius(.2rem);
}
}
}
.none{
display: none;
}
\ No newline at end of file
}
\ 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
... ...
... ... @@ -28,7 +28,6 @@
>span{
&:first-of-type{
color: #444;
line-height:100rem / $pxConvertRem;
}
width: 42%;
height: 100%;
... ... @@ -58,7 +57,7 @@
position: absolute;
right: 40rem / $pxConvertRem;
top:50%;
@include transform(translateY(-50%))
@include transform(translateY(-50%));
}
span{
color: #b0b0b0;
... ...
... ... @@ -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;
}
}
}
... ... @@ -119,6 +132,7 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
font-size: pxToRem(30px);
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
margin-top: -1px;
> span {
color: #b0b0b0;
... ...
... ... @@ -4,32 +4,6 @@ $subFontC:#b0b0b0;
$borderC:#e0e0e0;
$tableCellC:#eee;
$basicBtnC:#eb0313;
.my-swiper-button-prev,
.my-swiper-button-next {
position: absolute;
top: 50%;
width: pxToRem(48px);
height: pxToRem(48px);
margin-top: pxToRem(-44px);
cursor: pointer;
-moz-background-size: pxToRem(48px) pxToRem(48px);
-webkit-background-size: pxToRem(48px) pxToRem(48px);
background-size: pxToRem(48px) pxToRem(48px);
background-position: center;
background-repeat: no-repeat;
}
.next-grey {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23f0f0f0'%2F%3E%3C%2Fsvg%3E");
right: pxToRem(30px);
left: auto;
}
.prev-grey {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23f0f0f0'%2F%3E%3C%2Fsvg%3E");
left: pxToRem(30px);
right: auto;
}
.good-detail-page {
overflow: hidden;
... ... @@ -78,11 +52,38 @@ $basicBtnC:#eb0313;
border-right: none;
}
}
// }
}
}
}
.my-swiper-button-prev,
.my-swiper-button-next {
position: absolute;
top: 50%;
width: pxToRem(48px);
height: pxToRem(48px);
margin-top: pxToRem(-44px);
cursor: pointer;
-moz-background-size: pxToRem(48px) pxToRem(48px);
-webkit-background-size: pxToRem(48px) pxToRem(48px);
background-size: pxToRem(48px) pxToRem(48px);
background-position: center;
background-repeat: no-repeat;
}
.next-grey {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23f0f0f0'%2F%3E%3C%2Fsvg%3E");
right: pxToRem(30px);
left: auto;
}
.prev-grey {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23f0f0f0'%2F%3E%3C%2Fsvg%3E");
left: pxToRem(30px);
right: auto;
}
.tag-container {
position: absolute;
left: pxToRem(108px);
... ... @@ -256,7 +257,7 @@ $basicBtnC:#eb0313;
height: pxToRem(32px);
}
&:nth-child(1) {
text-align: right;
text-align: left;
.vip-img {
background: image-url('product/silver.png') no-repeat;
}
... ... @@ -267,7 +268,7 @@ $basicBtnC:#eb0313;
}
}
&:nth-child(3) {
text-align: left;
text-align: right;
.vip-img {
background: image-url('product/platinum.png') no-repeat;
}
... ...
... ... @@ -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">
... ...
... ... @@ -13,7 +13,11 @@
</div>
{{/ used}}
{{^ used}}
<p class="null">未找到相关相关优惠券</p>
<div class="null">
<i></i>
<p>您还没有优惠券!</p>
<a href="{{topURL}}">随便逛逛</a>
</div>
{{/ used}}
</div>
<div class="employ-list not none">
... ... @@ -22,10 +26,15 @@
<span>{{ money}}</span>
<p>{{ coupon_name}}</p>
<p>{{ couponValidity}}</p>
<i></i>
</div>
{{/ unused}}
{{^ unused}}
<p class="null">未找到相关相关优惠券</p>
<div class="null">
<i></i>
<p>您还没有使用的优惠券!</p>
<a href="{{topURL}}">随便逛逛</a>
</div>
{{/ unused}}
</div>
{{/ couponsUrl}}
... ...
... ... @@ -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">
... ...
... ... @@ -13,22 +13,33 @@
<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">
... ...
... ... @@ -66,20 +66,28 @@
{{# goodsDiscount}}
<div class="goodsDiscount">
{{# list}}
{{# list}}
{{#if @first}}
<h1 class="first-item">{{text}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
{{#if text}}
<h1 class="first-item">{{text}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
{{/if}}
{{/if}}
{{/ list}}
<div class="discount-folder">
{{# list}}
{{#if @first}}
{{else}}
{{#if text}}
<h1 class="folder-item">{{text}}</h1>
{{/if}}
{{/ list}}
</div>
{{/if}}
{{/list}}
</div>
</div>
{{/ goodsDiscount}}
<div class="feedback-list ">
{{# feedbacks}}
<div class="feedback-list ">
{{#if commentsNum}}
{{> product/feedback-tab}}
{{else}}
... ... @@ -92,8 +100,8 @@
</div>
{{/if}}
{{/if}}
{{/ feedbacks}}
</div>
{{/ feedbacks}}
{{# enterStore}}
<div id="enter-store" class="enter-store page-block">
... ...
... ... @@ -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);
}
... ... @@ -243,7 +241,7 @@ class HomeController extends AbstractAction
'couponsUrl' => UserModel::getCouponData($uid),
'couponsPage' => true
);
$coupons['pageFooter'] = true;
$this->_view->display('coupons', $coupons);
}
... ...
... ... @@ -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;
... ...