Showing
5 changed files
with
80 additions
and
4 deletions
@@ -54,8 +54,19 @@ const shopList = (req, res, next) => { | @@ -54,8 +54,19 @@ const shopList = (req, res, next) => { | ||
54 | }).catch(next); | 54 | }).catch(next); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | +//获取文章收藏状态 | ||
58 | +const shopFav = (req, res, next) => { | ||
59 | + let uid = req.query.uid || req.user.uid || ''; | ||
60 | + let shopIds = req.query.shopIds; | ||
61 | + | ||
62 | + shopModel.shopFav(uid, shopIds).then((result) => { | ||
63 | + res.json(result); | ||
64 | + }).catch(next); | ||
65 | +}; | ||
66 | + | ||
57 | module.exports = { | 67 | module.exports = { |
58 | shopIndex, | 68 | shopIndex, |
59 | shopList, | 69 | shopList, |
60 | - shopNav | 70 | + shopNav, |
71 | + shopFav | ||
61 | }; | 72 | }; |
@@ -56,8 +56,24 @@ const banner = () => { | @@ -56,8 +56,24 @@ const banner = () => { | ||
56 | }); | 56 | }); |
57 | }; | 57 | }; |
58 | 58 | ||
59 | +const shopFav = (uid, shopIds) => { | ||
60 | + return api.get('', { | ||
61 | + method: 'app.shops.promoteFavorite', | ||
62 | + shop_ids: shopIds, | ||
63 | + uid: uid | ||
64 | + }, { | ||
65 | + cache: true, | ||
66 | + code: 200 | ||
67 | + }).then((result) => { | ||
68 | + if (result.data) { | ||
69 | + return result.data; | ||
70 | + } | ||
71 | + }); | ||
72 | +}; | ||
73 | + | ||
59 | module.exports = { | 74 | module.exports = { |
60 | shopList, | 75 | shopList, |
61 | shopNav, | 76 | shopNav, |
62 | - banner | 77 | + banner, |
78 | + shopFav | ||
63 | }; | 79 | }; |
@@ -95,6 +95,7 @@ router.get('/coin/sendCoin', coin.sendCoin); | @@ -95,6 +95,7 @@ router.get('/coin/sendCoin', coin.sendCoin); | ||
95 | router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏 | 95 | router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏 |
96 | router.get('/shopList', shopCollect.shopList);// 店铺收藏列表 | 96 | router.get('/shopList', shopCollect.shopList);// 店铺收藏列表 |
97 | router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航 | 97 | router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航 |
98 | +router.get('/shopfavStatus', shopCollect.shopFav);// 店铺收藏状态 | ||
98 | router.get('/share', share.getShareContent); | 99 | router.get('/share', share.getShareContent); |
99 | 100 | ||
100 | module.exports = router; | 101 | module.exports = router; |
@@ -13,7 +13,8 @@ var searching, | @@ -13,7 +13,8 @@ var searching, | ||
13 | bannerSwiper, | 13 | bannerSwiper, |
14 | navType, | 14 | navType, |
15 | appVersion = $('input[name="app_version"]').val(), | 15 | appVersion = $('input[name="app_version"]').val(), |
16 | - uid = $('input[name="uid"]').val(); | 16 | + uid = $('input[name="uid"]').val(), |
17 | + ids = []; | ||
17 | 18 | ||
18 | var shopNav = require('shopCollect/shop-nav.hbs'), | 19 | var shopNav = require('shopCollect/shop-nav.hbs'), |
19 | shopList = require('shopCollect/shop-list.hbs'); | 20 | shopList = require('shopCollect/shop-list.hbs'); |
@@ -23,6 +24,39 @@ require('../common/share'); | @@ -23,6 +24,39 @@ require('../common/share'); | ||
23 | 24 | ||
24 | navType = window.queryString; | 25 | navType = window.queryString; |
25 | 26 | ||
27 | +function shopFav(shopIds) { | ||
28 | + return $.ajax({ | ||
29 | + method: 'get', | ||
30 | + url: '/activity/shopfavStatus', | ||
31 | + data: { | ||
32 | + uid: window.queryString.uid || uid, | ||
33 | + shopIds: shopIds | ||
34 | + }, | ||
35 | + success: function(data) { | ||
36 | + var i, | ||
37 | + it, | ||
38 | + $it; | ||
39 | + | ||
40 | + for (i = 0; i < data.length; i++) { | ||
41 | + it = data[i]; | ||
42 | + | ||
43 | + if (it && it.id) { | ||
44 | + $it = $('.shop-info[data-id=' + it.id + ']', $('.shop-list')); | ||
45 | + | ||
46 | + if (it.favorite === 'Y') { | ||
47 | + $it.find('.collect-btn').addClass('already-collect'); | ||
48 | + } else { | ||
49 | + $it.find('.collect-btn').removeClass('already-collect'); | ||
50 | + } | ||
51 | + } | ||
52 | + } | ||
53 | + }, | ||
54 | + error: function() { | ||
55 | + tip.show('网络断开连接了~'); | ||
56 | + } | ||
57 | + }) | ||
58 | +} | ||
59 | + | ||
26 | // 店铺列表数据 | 60 | // 店铺列表数据 |
27 | function shopListData(tabName, stoping) { | 61 | function shopListData(tabName, stoping) { |
28 | 62 | ||
@@ -47,6 +81,18 @@ function shopListData(tabName, stoping) { | @@ -47,6 +81,18 @@ function shopListData(tabName, stoping) { | ||
47 | 81 | ||
48 | stoping = false; | 82 | stoping = false; |
49 | 83 | ||
84 | + | ||
85 | + //获取收藏状态 | ||
86 | + $('.shop-list').find('.shop-info').each(function() { | ||
87 | + var id = $(this).data('id'); | ||
88 | + | ||
89 | + if(id) { | ||
90 | + ids.push(id); | ||
91 | + } | ||
92 | + }) | ||
93 | + | ||
94 | + shopFav(ids.join(',')); | ||
95 | + | ||
50 | // 店铺收藏 | 96 | // 店铺收藏 |
51 | $('.collect-btn').on('click', function() { | 97 | $('.collect-btn').on('click', function() { |
52 | var opt, | 98 | var opt, |
@@ -55,6 +55,7 @@ | @@ -55,6 +55,7 @@ | ||
55 | 55 | ||
56 | .fans { | 56 | .fans { |
57 | margin-right: 30px; | 57 | margin-right: 30px; |
58 | + color: #666; | ||
58 | } | 59 | } |
59 | 60 | ||
60 | .collect-btn { | 61 | .collect-btn { |
@@ -81,7 +82,7 @@ | @@ -81,7 +82,7 @@ | ||
81 | margin-left: 25px; | 82 | margin-left: 25px; |
82 | font-size: 22px; | 83 | font-size: 22px; |
83 | width: 170px; | 84 | width: 170px; |
84 | - height: 70px; | 85 | + height: 65px; |
85 | } | 86 | } |
86 | 87 | ||
87 | span { | 88 | span { |
@@ -102,6 +103,7 @@ | @@ -102,6 +103,7 @@ | ||
102 | } | 103 | } |
103 | 104 | ||
104 | .giving { | 105 | .giving { |
106 | + width: 170px; | ||
105 | color: #b0b0b0; | 107 | color: #b0b0b0; |
106 | } | 108 | } |
107 | } | 109 | } |
-
Please register or login to post a comment