Authored by zhangxiaoru

favorite

... ... @@ -8,7 +8,7 @@
const favoriteModel = require('../models/favorite');
const favorite = (req, res, next) => {
const favorite = (req, res) => {
// favoriteModel.getfavoriteData(uid, page, limit).then((result) => {
... ... @@ -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;
... ... @@ -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: ''
});
}
... ... @@ -126,18 +127,19 @@ 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: []
};
let brandPro = [];
// if (empty(val.productSkn)) {
// continue;
// }
... ... @@ -146,12 +148,12 @@ const favfavBrand = (uid, page, limit) => {
link: helpers.urlFormat('/product/index/brand', {
shop_id: val.shopId
})
})
});
} else {
obj = _.assign(obj, {
link: helpers.urlFormat('', {}, val.brandDomain)
})
});
}
obj = _.assign(obj, {
... ... @@ -164,22 +166,23 @@ 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({
... ... @@ -191,7 +194,7 @@ const favfavBrand = (uid, page, limit) => {
logger.error('收藏品牌 cood 不是 200');
}
});
}
};
const favoriteDelete = (uid, type, favId) => {
... ... @@ -200,8 +203,8 @@ const favoriteDelete = (uid, type, favId) => {
uid: uid,
type: type,
fav_id: favId
})
}
});
};
module.exports = {
favProduct,
... ...
... ... @@ -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,13 +69,14 @@
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 {
... ... @@ -113,13 +114,11 @@
h2 {
width: 430px;
/*white-space: nowrap;
overflow: hidden;*/
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.fav-price {
.new-price {
color: #d1021c;
}
... ... @@ -129,47 +128,24 @@
margin-left: 15px;
color: #b0b0b0;
}
}
.save-price {
position: absolute;
bottom: 20px;
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 {
.sell-out {
padding: 5px 18px;
color: #fffefe;
border-radius: 20px;
... ... @@ -177,7 +153,7 @@
font-size: 22px;
}
&.del-fav {
.del-fav {
width: 2rem;
height: 1.5rem;
line-height: 1.5rem;
... ... @@ -186,16 +162,36 @@
margin-top: -0.75rem;
right: 0;
color: #999;
padding-right: 0.75rem;
text-align: right;
}
}
.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;
}
}
}
}
/*品牌收藏*/
.fav-brand-swiper {
border-top: 1px solid #e0e0e0;
border-bottom: 28px solid #f0f0f0;
... ... @@ -224,15 +220,23 @@
width: 100%;
box-sizing: border-box;
.swiper-logo {
height: 100%;
display: inline-block;
float: left;
margin-right: 45px;
.fav-more {
width: 2.5rem;
height: 2.5rem;
position: absolute;
top: 0;
right: 0;
> img {
max-height: 100%;
vertical-align: middle;
&:after {
width: 18px;
height: 29px;
background: url("/me/fav/fav-more.png");
position: absolute;
top: 50%;
right: 30px;
margin-top: -15px;
content: '';
}
}
}
... ... @@ -265,25 +269,19 @@
}
}
}
.fav-more {
width: 2.5rem;
height: 2.5rem;
position: absolute;
top: 0;
right: 0;
&:after {
width: 18px;
height: 29px;
background: url("/me/fav/fav-more.png");
position: absolute;
top: 50%;
right: 30px;
margin-top: -15px;
content: '';
}
.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;
... ... @@ -309,10 +307,12 @@
line-height: 65px;
text-align: center;
font-size: 22px;
}
}
.price-discount {
span {
color: #d1021c
color: #d1021c;
}
b {
color: #b0b0b0;
... ... @@ -323,11 +323,9 @@
}
}
}
}
}
}
.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;
... ...