Authored by zhangxiaoru

favorite

... ... @@ -8,10 +8,10 @@
const favoriteModel = require('../models/favorite');
const favorite = (req, res, next) => {
const favorite = (req, res) => {
// favoriteModel.getfavoriteData(uid, page, limit).then((result) => {
// }).catch(next);
res.render('favorite', {
module: 'home',
... ... @@ -20,7 +20,7 @@ const favorite = (req, res, next) => {
productUrl: 'm.yohobuy.com',
brandUrl: 'm.yohobuy.com'
}
})
});
};
let favProduct = (req, res, next) => {
... ... @@ -32,7 +32,7 @@ let favProduct = (req, res, next) => {
res.render('favorite/favorite-product', {
layout: false,
hasFavProduct: result
})
});
}).catch(next);
};
... ... @@ -45,7 +45,7 @@ let favfavBrand = (req, res, next) => {
res.render('favorite/favorite-brand', {
layout: false,
hasFavBrand: result
})
});
}).catch(next);
};
... ... @@ -64,4 +64,4 @@ module.exports = {
favProduct,
favfavBrand,
favoriteDelete
}
\ No newline at end of file
};
... ...
... ... @@ -8,7 +8,8 @@
const logger = global.yoho.logger;
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
// const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const config = global.yoho.config;
... ... @@ -28,7 +29,7 @@ const favProduct = (uid, page, limit) => {
};
if (result && result.code === 200) {
let list = camelCase(result);
if (page > 1 && list === []) {
... ... @@ -37,22 +38,22 @@ const favProduct = (uid, page, limit) => {
}
if (page <= list.data.pageTotal) {
let hasFavProduct = [];
_.forEach(list.data.productList, function(val) {
let obj = {};
// if (empty(val.productSkn)) {
// continue;
// }
if (val.goodsId && val.cnAlphabet) {
obj =_.assign (obj, {
obj = _.assign(obj, {
link: config.siteUrl + '/product/list/pro_' +
val.productId + '_' + val.goodsId + '/' +
val.cnAlphabet + '.html'
});
} else {
obj =_.assign (obj, {
obj = _.assign(obj, {
link: ''
});
}
... ... @@ -97,14 +98,14 @@ const favProduct = (uid, page, limit) => {
});
resu.hasFavProduct.push(obj);
});
});
} else {
resu.push({
end: true
end: true
});
}
return resu.hasFavProduct;
} else {
logger.error('收藏商品 cood 不是 200');
... ... @@ -126,32 +127,33 @@ const favfavBrand = (uid, page, limit) => {
let list = camelCase(result);
if (page > 1 && list === []) {
resu.end = true;
hasFavBrand.push({
end: true
});
return;
}
if (page <= list.data.pageTotal) {
let brand = [];
_.forEach(list.data.brandList, function(val) {
let obj = {
productList: []
productList: []
};
let brandPro = [];
// if (empty(val.productSkn)) {
// continue;
// }
if (val.brandOrShopType === 'brandOrShopType') {
obj = _.assign(obj, {
link: helpers.urlFormat('/product/index/brand', {
shop_id: val.shopId
shop_id: val.shopId
})
})
});
} else {
obj = _.assign(obj, {
link: helpers.urlFormat('', {}, val.brandDomain)
})
});
}
obj = _.assign(obj, {
... ... @@ -164,34 +166,35 @@ const favfavBrand = (uid, page, limit) => {
_.forEach(val.newProduct, function(data) {
obj.productList.push({
link: '/product/pro_' + data.productId + '_' + data.goods[0].id + '/' + data.cnAlphabet + '.html',
link: '/product/pro_' + data.productId + '_' +
data.goods[0].id + '/' + data.cnAlphabet + '.html',
imgUrl: data.defaultImages,
price: '¥' + data.marketPrice
})
});
if (data.marketPrice > data.salesPrice) {
obj.productList.push({
discount: '¥' + data.salesPrice
})
});
}
})
});
hasFavBrand.push(obj);
});
console.log(hasFavBrand)
// console.log(hasFavBrand);
return hasFavBrand;
} else {
hasFavBrand.push({
end: true
end: true
});
}
} else {
logger.error('收藏品牌 cood 不是 200');
}
});
}
};
const favoriteDelete = (uid, type, favId) => {
... ... @@ -200,11 +203,11 @@ const favoriteDelete = (uid, type, favId) => {
uid: uid,
type: type,
fav_id: favId
})
}
});
};
module.exports = {
favProduct,
favfavBrand,
favoriteDelete
favProduct,
favfavBrand,
favoriteDelete
};
... ...
... ... @@ -15,16 +15,16 @@ const favorite = require(`${cRoot}/favorite`);
// 查看二维码
router.get('/QRcode/:id', personalController.QRcode);
//我的收藏
// 我的收藏
router.get('/favorite', favorite.favorite);
//收藏的商品
// 收藏的商品
router.get('/favProduct', favorite.favProduct);
//收藏的品牌
// 收藏的品牌
router.get('/favBrand', favorite.favfavBrand);
//取消收藏
// 取消收藏
router.post('/favoriteDel', favorite.favoriteDelete);
module.exports = router;
... ...
... ... @@ -23,10 +23,10 @@ var $navLi = $('#fav-tab > li'),
$favProductList = $('.fav-product-list'),
$favBrandList = $('.fav-brand-swiper-wrapper'),
pageId = 1,
brandPageId = 1, //收藏品牌的当前页数
brandPageId = 1, // 收藏品牌的当前页数
lockId = true,
brandLockId = true, //收藏品牌是否可下拉加载更多
brandTab = false; //当前是否停留在收藏品牌页
brandLockId = true, // 收藏品牌是否可下拉加载更多
brandTab = false; // 当前是否停留在收藏品牌页
require('../common');
... ... @@ -38,7 +38,7 @@ function showFavTab(index) {
$favContainer.eq(index).addClass('show');
}
//初始化swiper
// 初始化swiper
function initSwiper(data) {
var i,
idStrReg = /container-(\d+)['"]{1}/gi,
... ... @@ -47,10 +47,10 @@ function initSwiper(data) {
idArrLen = idArr.length,
containerId;
//$swiperList = $('.swiper-container');
// $swiperList = $('.swiper-container');
for (i = 0; i < idArrLen; i++) {
/*id = $swiperList.eq(i).attr('data-id');
/* id = $swiperList.eq(i).attr('data-id');
if (!!swiperObj[id]) {
swiperObj[id].destroy(true, true);
... ... @@ -97,11 +97,11 @@ function loadData($parent, url, page) {
window.rePosFooter();
} else if (data === 'end') {
//处理data等于end时如果loadingMask存在且没有hide样式的情况
// 处理data等于end时如果loadingMask存在且没有hide样式的情况
if ($loadingMask && !$loadingMask.hasClass('hide')) {
$loadingMask.addClass('hide');
//$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
// $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
}
$parent.closest('.fav-type').find('.fav-load-background')
... ... @@ -113,14 +113,14 @@ function loadData($parent, url, page) {
} else if (data.length > 10) {
$parent.append(data);
//如果有数据loadingMask会被remove掉
// 如果有数据loadingMask会被remove掉
$loadingMask.remove();
if (url === 'favBrand') {
initSwiper(data);//如果是收藏品牌需要初始化swiper
initSwiper(data);// 如果是收藏品牌需要初始化swiper
brandLockId = false;//请求成功后解锁品牌收藏page++
brandLockId = false;// 请求成功后解锁品牌收藏page++
} else {
lockId = false;//请求成功后解锁商品收藏page++
lockId = false;// 请求成功后解锁商品收藏page++
}
}
window.rePosFooter();
... ... @@ -170,7 +170,7 @@ favTabHammer.on('tap', function(e) {
});
//删除收藏的商品
// 删除收藏的商品
favContentHammer = new Hammer(document.getElementById('fav-content'));
favContentHammer.on('tap', function(e) {
... ... @@ -218,7 +218,7 @@ favContentHammer.on('tap', function(e) {
}
}).fail(function() {
//TODO
// TODO
diaLog.showDialog({
autoHide: true,
... ... @@ -230,7 +230,7 @@ favContentHammer.on('tap', function(e) {
function scrollHandler() {
//距离底部未1/4列表高度+底部高度的时候加载更多
// 距离底部未1/4列表高度+底部高度的时候加载更多
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $favBrandList.height() - footerH) {
if (brandTab) {
$brandLoadMore.filter('.hide').removeClass('hide');
... ... @@ -252,7 +252,7 @@ function scrollHandler() {
}
}
//srcoll to load more
// srcoll to load more
$(window).scroll(scrollHandler);
$(document).on('touchend', '.swiper-header', function() {
... ...
... ... @@ -59,9 +59,9 @@
display: block;
width: 188px;
height: 171px;
/*background: resolve("me/fav/fav-null.png");*/
background: resolve("me/fav/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px auto;
margin: 0 auto 45px;
}
}
... ... @@ -69,265 +69,263 @@
width: 472px;
height: 88px;
line-height: 88px;
margin: 80px auto 0 auto;
margin: 80px auto 0;
background: #444;
text-align: center;
color: #fff;
display: block;
font-size: 26px;
border-radius:.2rem;
border-radius: 0.2rem;
}
}
.fav-product-list {
list-style: none;
margin-left: 30px;
li {
height: auto;
overflow: hidden;
margin-top: 20px;
}
.fav-product-list {
list-style: none;
margin-left: 30px;
.fav-img-box {
width: 90px;
height: 120px;
float: left;
margin-right: 24px;
li {
height: auto;
img {
display: block;
overflow: hidden;
margin-top: 20px;
width: 100%;
height: 100%;
}
}
.fav-img-box {
width: 90px;
height: 120px;
float: left;
margin-right: 24px;
.fav-info-list {
color: #444;
font-size: 24px;
border-bottom: 1px solid #e0e0e0;
padding-bottom: 20px;
height: 120px;
overflow: hidden;
position: relative;
img {
display: block;
overflow: hidden;
width: 100%;
height: 100%;
}
h2 {
width: 430px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.fav-info-list {
color: #444;
font-size: 24px;
border-bottom: 1px solid #e0e0e0;
padding-bottom: 20px;
height: 120px;
overflow: hidden;
position: relative;
.new-price {
color: #d1021c;
}
.price-underline {
text-decoration: line-through;
margin-left: 15px;
color: #b0b0b0;
}
.save-price {
position: absolute;
bottom: 20px;
left: 0;
width: 100%;
min-height: 24px;
h2 {
width: 430px;
/*white-space: nowrap;
overflow: hidden;*/
text-overflow: ellipsis;
.del-fav {
text-indent: 0;
margin-left: 0;
}
.fav-price {
span {
color: #d1021c;
}
.new-price {
color: #d1021c;
}
.sell-out {
padding: 5px 18px;
color: #fffefe;
border-radius: 20px;
background: #7f7f7f;
font-size: 22px;
}
.price-underline {
text-decoration: line-through;
margin-left: 15px;
color: #b0b0b0;
}
.del-fav {
width: 2rem;
height: 1.5rem;
line-height: 1.5rem;
position: absolute;
top: 50%;
margin-top: -0.75rem;
right: 0;
color: #999;
padding-right: 0.75rem;
text-align: right;
}
}
.save-price {
.save-price-number {
text-indent: 42px;
color: #b0b0b0;
padding-top: 3px;
&:before {
content: '';
display: block;
background: url("/me/fav/save-price.png");
width: 32px;
height: 32px;
position: absolute;
bottom: 20px;
top: 50%;
left: 0;
width: 100%;
min-height: 24px;
&.save-price-number {
text-indent: 42px;
color: #b0b0b0;
padding-top: 3px;
&:before {
content: '';
display: block;
/*background: url("/me/fav/save-price.png");*/
width: 32px;
height: 32px;
position: absolute;
top: 50%;
left: 0;
margin-top: -16px;
}
span {
margin-left: 15px;
}
.del-fav {
text-indent: 0;
margin-left: 0;
}
}
span {
color: #d1021c;
&.sell-out {
padding: 5px 18px;
color: #fffefe;
border-radius: 20px;
background: #7f7f7f;
font-size: 22px;
}
&.del-fav {
width: 2rem;
height: 1.5rem;
line-height: 1.5rem;
position: absolute;
top: 50%;
margin-top: -0.75rem;
right: 0;
color: #999;
padding-right: 0.75rem;
text-align: right;
}
}
margin-top: -16px;
}
span {
margin-left: 15px;
}
}
}
/*品牌收藏*/
.fav-brand-swiper {
}
.fav-brand-swiper {
border-top: 1px solid #e0e0e0;
border-bottom: 28px solid #f0f0f0;
position: relative;
&:nth-of-type(1) {
border-top: 0;
}
&:after {
content: '';
position: absolute;
left: 0;
bottom: -2px;
border-top: 1px solid #e0e0e0;
border-bottom: 28px solid #f0f0f0;
display: block;
width: 100%;
height: 1px;
}
.swiper-header {
height: 100px;
padding: 20px 30px;
display: inline-block;
position: relative;
width: 100%;
box-sizing: border-box;
.fav-more {
width: 2.5rem;
height: 2.5rem;
position: absolute;
top: 0;
right: 0;
&:nth-of-type(1) {
border-top: 0;
&:after {
width: 18px;
height: 29px;
background: url("/me/fav/fav-more.png");
position: absolute;
top: 50%;
right: 30px;
margin-top: -15px;
content: '';
}
}
}
&:after {
content: '';
position: absolute;
left: 0;
bottom: -2px;
border-top: 1px solid #e0e0e0;
display: block;
width: 100%;
height: 1px;
.brand-info {
float: left;
.brand-name {
font-size: 28px;
b {
color: #b0b0b0;
font-weight: normal;
}
}
.swiper-header {
height: 100px;
padding: 20px 30px;
display: inline-block;
position: relative;
width: 100%;
box-sizing: border-box;
.swiper-logo {
height: 100%;
display: inline-block;
float: left;
margin-right: 45px;
> img {
max-height: 100%;
vertical-align: middle;
}
.brand-update {
font-size: 22px;
b {
color: #b0b0b0;
font-weight: normal;
}
.brand-info {
float: left;
.brand-name {
font-size: 28px;
b {
color: #b0b0b0;
font-weight: normal;
}
}
.brand-update {
font-size: 22px;
b {
color: #b0b0b0;
font-weight: normal;
}
.brand-new {
color: #86bf4a;
margin-right: 24px;
}
.brand-discount {
color: #d1021c;
}
}
.brand-new {
color: #86bf4a;
margin-right: 24px;
}
.fav-more {
width: 2.5rem;
height: 2.5rem;
position: absolute;
top: 0;
right: 0;
.brand-discount {
color: #d1021c;
}
}
}
.swiper-logo {
height: 100%;
display: block;
float: left;
margin-right: 45px;
> img {
max-height: 100%;
vertical-align: middle;
}
}
.swiper-container {
height: 365px;
margin: 0 30px;
.swiper-slide {
width: 225px;
height: 100%;
float: left;
padding-right: 30px;
&:after {
width: 18px;
height: 29px;
background: url("/me/fav/fav-more.png");
position: absolute;
top: 50%;
right: 30px;
margin-top: -15px;
content: '';
}
&:nth-last-of-type(1) {
padding-right: 0;
}
img {
display: block;
width: 100%;
height: 300px;
overflow: hidden;
}
.brand-product {
height: 65px;
line-height: 65px;
text-align: center;
font-size: 22px;
}
}
.swiper-container {
height: 365px;
margin: 0 30px;
.swiper-slide {
width: 225px;
height: 100%;
float: left;
padding-right: 30px;
&:nth-last-of-type(1) {
padding-right: 0;
}
img {
display: block;
width: 100%;
height: 300px;
overflow: hidden;
}
.brand-product {
height: 65px;
line-height: 65px;
text-align: center;
font-size: 22px;
.price-discount {
span {
color: #d1021c
}
b {
color: #b0b0b0;
text-decoration: line-through;
font-weight: normal;
margin-left: 13px;
}
}
}
.price-discount {
span {
color: #d1021c;
}
b {
color: #b0b0b0;
text-decoration: line-through;
font-weight: normal;
margin-left: 13px;
}
}
}
}
.fav-load-more,.fav-brand-load-more {
.fav-load-more,
.fav-brand-load-more {
width: 100%;
height: 2rem;
line-height: 2rem;
... ... @@ -335,16 +333,15 @@
color: #444;
&.load-background {
/*background: resolve('loading.gif') center center no-repeat;*/
background: resolve('loading.gif') center center no-repeat;
background-size: auto 40%;
}
}
.fav-content-loading {
width: 100%;
height: 2rem;
/*background: resolve('loading.gif') center center no-repeat;*/
background: resolve('loading.gif') center center no-repeat;
background-size: auto 40%;
position: absolute;
top: 50%;
left: 0;
... ...