Authored by zhangxiaoru

动态获取收藏状态

... ... @@ -54,8 +54,19 @@ const shopList = (req, res, next) => {
}).catch(next);
};
//获取文章收藏状态
const shopFav = (req, res, next) => {
let uid = req.query.uid || req.user.uid || '';
let shopIds = req.query.shopIds;
shopModel.shopFav(uid, shopIds).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
shopIndex,
shopList,
shopNav
shopNav,
shopFav
};
... ...
... ... @@ -56,8 +56,24 @@ const banner = () => {
});
};
const shopFav = (uid, shopIds) => {
return api.get('', {
method: 'app.shops.promoteFavorite',
shop_ids: shopIds,
uid: uid
}, {
cache: true,
code: 200
}).then((result) => {
if (result.data) {
return result.data;
}
});
};
module.exports = {
shopList,
shopNav,
banner
banner,
shopFav
};
... ...
... ... @@ -95,6 +95,7 @@ router.get('/coin/sendCoin', coin.sendCoin);
router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏
router.get('/shopList', shopCollect.shopList);// 店铺收藏列表
router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航
router.get('/shopfavStatus', shopCollect.shopFav);// 店铺收藏状态
router.get('/share', share.getShareContent);
module.exports = router;
... ...
... ... @@ -13,7 +13,8 @@ var searching,
bannerSwiper,
navType,
appVersion = $('input[name="app_version"]').val(),
uid = $('input[name="uid"]').val();
uid = $('input[name="uid"]').val(),
ids = [];
var shopNav = require('shopCollect/shop-nav.hbs'),
shopList = require('shopCollect/shop-list.hbs');
... ... @@ -23,6 +24,39 @@ require('../common/share');
navType = window.queryString;
function shopFav(shopIds) {
return $.ajax({
method: 'get',
url: '/activity/shopfavStatus',
data: {
uid: window.queryString.uid || uid,
shopIds: shopIds
},
success: function(data) {
var i,
it,
$it;
for (i = 0; i < data.length; i++) {
it = data[i];
if (it && it.id) {
$it = $('.shop-info[data-id=' + it.id + ']', $('.shop-list'));
if (it.favorite === 'Y') {
$it.find('.collect-btn').addClass('already-collect');
} else {
$it.find('.collect-btn').removeClass('already-collect');
}
}
}
},
error: function() {
tip.show('网络断开连接了~');
}
})
}
// 店铺列表数据
function shopListData(tabName, stoping) {
... ... @@ -47,6 +81,18 @@ function shopListData(tabName, stoping) {
stoping = false;
//获取收藏状态
$('.shop-list').find('.shop-info').each(function() {
var id = $(this).data('id');
if(id) {
ids.push(id);
}
})
shopFav(ids.join(','));
// 店铺收藏
$('.collect-btn').on('click', function() {
var opt,
... ...
... ... @@ -55,6 +55,7 @@
.fans {
margin-right: 30px;
color: #666;
}
.collect-btn {
... ... @@ -81,7 +82,7 @@
margin-left: 25px;
font-size: 22px;
width: 170px;
height: 70px;
height: 65px;
}
span {
... ... @@ -102,6 +103,7 @@
}
.giving {
width: 170px;
color: #b0b0b0;
}
}
... ...