Showing
5 changed files
with
47 additions
and
24 deletions
@@ -114,19 +114,24 @@ class FavoriteData | @@ -114,19 +114,24 @@ class FavoriteData | ||
114 | } | 114 | } |
115 | 115 | ||
116 | /** | 116 | /** |
117 | - * 取消商品或品牌收藏 | ||
118 | - * @param type $uid 用户uid | ||
119 | - * @param type $productId 商品id或品牌id | ||
120 | - * @param type $bool 商品或品牌 | 117 | + * 取消商品或品牌或店铺收藏 |
118 | + * @param type $uid 用户uid | ||
119 | + * @param type $productId 商品id或品牌id或店铺id | ||
120 | + * @param type $isBrand 商品或品牌 | ||
121 | + * @param type $isShop 是否是店铺 | ||
121 | * @return type | 122 | * @return type |
122 | */ | 123 | */ |
123 | - public static function cancelProductFav($uid, $productId, $isBrand = false) | 124 | + public static function cancelProductFav($uid, $productId, $isBrand = false, $isShop = false) |
124 | { | 125 | { |
125 | $param = Yohobuy::param(); | 126 | $param = Yohobuy::param(); |
126 | $param['method'] = 'web.favorite.cancel'; | 127 | $param['method'] = 'web.favorite.cancel'; |
127 | $param['favIds'] = $productId; | 128 | $param['favIds'] = $productId; |
128 | $param['uid'] = $uid; | 129 | $param['uid'] = $uid; |
129 | - $param['type'] = $isBrand ? 'brand' : 'product'; | 130 | + if ($isShop) { |
131 | + $param['type'] = 'shop'; | ||
132 | + } else { | ||
133 | + $param['type'] = $isBrand ? 'brand' : 'product'; | ||
134 | + } | ||
130 | $param['client_secret'] = Sign::getSign($param); | 135 | $param['client_secret'] = Sign::getSign($param); |
131 | 136 | ||
132 | return Yohobuy::get(Yohobuy::API_URL, $param); | 137 | return Yohobuy::get(Yohobuy::API_URL, $param); |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | {{^}} | 14 | {{^}} |
15 | <ul> | 15 | <ul> |
16 | {{# brands}} | 16 | {{# brands}} |
17 | - <li class="fav-brand fav-row" data-id="{{id}}"> | 17 | + <li class="fav-brand fav-row" data-id="{{id}}" data-shopid="{{shop_id}}" data-brandOrShopType="{{brandOrShopType}}"> |
18 | <div class="checkbox"> | 18 | <div class="checkbox"> |
19 | <input type="checkbox"> | 19 | <input type="checkbox"> |
20 | </div> | 20 | </div> |
@@ -392,7 +392,9 @@ $('#me-checkall').click(function() { | @@ -392,7 +392,9 @@ $('#me-checkall').click(function() { | ||
392 | 392 | ||
393 | //删除收藏 | 393 | //删除收藏 |
394 | $('.del-favorite').click(function(e) { | 394 | $('.del-favorite').click(function(e) { |
395 | - var id = $(this).closest('.fav-row').data('id'); | 395 | + var id = $(this).closest('.fav-row').data('id'), |
396 | + shopid = $(this).closest('.fav-row').data('shopid'), | ||
397 | + brandorshoptype = $(this).closest('.fav-row').data('brandorshoptype'); | ||
396 | 398 | ||
397 | e.preventDefault(); | 399 | e.preventDefault(); |
398 | 400 | ||
@@ -401,6 +403,8 @@ $('.del-favorite').click(function(e) { | @@ -401,6 +403,8 @@ $('.del-favorite').click(function(e) { | ||
401 | url: '/home/favorite/cancel', | 403 | url: '/home/favorite/cancel', |
402 | data: { | 404 | data: { |
403 | id: id, | 405 | id: id, |
406 | + shopid: shopid, | ||
407 | + brandorshoptype: brandorshoptype, | ||
404 | type: favType | 408 | type: favType |
405 | } | 409 | } |
406 | }).then(function(data) { | 410 | }).then(function(data) { |
@@ -166,29 +166,36 @@ class FavoriteModel | @@ -166,29 +166,36 @@ class FavoriteModel | ||
166 | $result = array('brands' => array('empty' => '您没有收藏品牌'), 'pager' => array()); | 166 | $result = array('brands' => array('empty' => '您没有收藏品牌'), 'pager' => array()); |
167 | $brand = FavoriteData::favoriteBrandData($uid, $page, $limit); | 167 | $brand = FavoriteData::favoriteBrandData($uid, $page, $limit); |
168 | do { | 168 | do { |
169 | + | ||
169 | if (empty($brand['data']) || empty($brand['data']['page_total'])) { | 170 | if (empty($brand['data']) || empty($brand['data']['page_total'])) { |
170 | break; | 171 | break; |
171 | } | 172 | } |
173 | + | ||
172 | if ($brand['data']['page_total'] < $page) { | 174 | if ($brand['data']['page_total'] < $page) { |
173 | - $page = $data['data']['page_total']; | 175 | + $page = $brand['data']['page_total']; |
174 | $brand = FavoriteData::favoriteBrandData($uid, $page, $limit); | 176 | $brand = FavoriteData::favoriteBrandData($uid, $page, $limit); |
175 | - continue; | ||
176 | } | 177 | } |
177 | - if (isset($brand['data']['brand_list'])) { | ||
178 | - foreach ($brand['data']['brand_list'] as $brandkey => $brandval) { | ||
179 | - $brands[$brandkey]['id'] = $brandval['brand_id']; //品牌id | ||
180 | - $brands[$brandkey]['img'] = Images::getImageUrl($brandval['brand_ico'], 100, 100); //品牌缩略图 | ||
181 | - $brands[$brandkey]['url'] = Helpers::url('', '', $brandval['brand_domain']); //品牌链接 | ||
182 | - $brands[$brandkey]['name'] = $brandval['brand_name']; //品牌名 | ||
183 | - $brands[$brandkey]['naCount'] = $brandval['new_product_num']; //新品到着数量 | ||
184 | - $brands[$brandkey]['colCount'] = $brandval['brand_favorite_num']; //收藏人气 | ||
185 | - $result['brands'] = $brands; | ||
186 | - } | ||
187 | - $total = isset($brand['data']['total']) ? $brand['data']['total'] : 0; //消息总条数 | ||
188 | - $pageTotal = isset($brand['data']['page_total']) ? $brand['data']['page_total'] : 0; //总页数 | ||
189 | - $page = isset($brand['data']['page']) ? $brand['data']['page'] : 0; //当前页 | ||
190 | - $result['pager'] = self::getPager($page, $total, $pageTotal, $limit, $type); | 178 | + |
179 | + if (empty($brand['data']['brand_list'])) { | ||
180 | + break; | ||
181 | + } | ||
182 | + | ||
183 | + $brands = array(); | ||
184 | + foreach ($brand['data']['brand_list'] as $brandkey => $brandval) { | ||
185 | + $brands[$brandkey]['id'] = $brandval['brand_id']; //品牌id | ||
186 | + $brands[$brandkey]['brandOrShopType'] = empty($brandval['brandOrShopType']) ? '' : $brandval['brandOrShopType']; | ||
187 | + $brands[$brandkey]['shop_id'] = empty($brandval['shop_id']) ? '' : $brandval['shop_id']; | ||
188 | + $brands[$brandkey]['img'] = Images::getImageUrl($brandval['brand_ico'], 100, 100); //品牌缩略图 | ||
189 | + $brands[$brandkey]['url'] = Helpers::url('', '', $brandval['brand_domain']); //品牌链接 | ||
190 | + $brands[$brandkey]['name'] = $brandval['brand_name']; //品牌名 | ||
191 | + $brands[$brandkey]['naCount'] = $brandval['new_product_num']; //新品到着数量 | ||
192 | + $brands[$brandkey]['colCount'] = $brandval['brand_favorite_num']; //收藏人气 | ||
191 | } | 193 | } |
194 | + $result['brands'] = $brands; | ||
195 | + $total = isset($brand['data']['total']) ? $brand['data']['total'] : 0; //消息总条数 | ||
196 | + $pageTotal = isset($brand['data']['page_total']) ? $brand['data']['page_total'] : 0; //总页数 | ||
197 | + $page = isset($brand['data']['page']) ? $brand['data']['page'] : 0; //当前页 | ||
198 | + $result['pager'] = self::getPager($page, $total, $pageTotal, $limit, $type); | ||
192 | } | 199 | } |
193 | while (false); | 200 | while (false); |
194 | return $result; | 201 | return $result; |
@@ -183,10 +183,17 @@ class FavoriteController extends WebAction | @@ -183,10 +183,17 @@ class FavoriteController extends WebAction | ||
183 | $uid = $this->getUid(true); | 183 | $uid = $this->getUid(true); |
184 | $id = $this->get('id', ''); | 184 | $id = $this->get('id', ''); |
185 | $type = $this->get('type', ''); | 185 | $type = $this->get('type', ''); |
186 | + $shopid = $this->get('shopid', ''); | ||
187 | + $brandorshoptype = $this->get('brandorshoptype', ''); | ||
188 | + | ||
186 | if (!$uid || !$id) { | 189 | if (!$uid || !$id) { |
187 | $result = array('code' => 400, 'message' => '缺少参数', 'data' => ''); | 190 | $result = array('code' => 400, 'message' => '缺少参数', 'data' => ''); |
188 | break; | 191 | break; |
189 | } | 192 | } |
193 | + if ($brandorshoptype && $shopid && $brandorshoptype === 'shop') { | ||
194 | + $result = FavoriteData::cancelProductFav($uid, $shopid, false, true); //取消店铺收藏 | ||
195 | + break; | ||
196 | + } | ||
190 | switch (strval($type)) { | 197 | switch (strval($type)) { |
191 | case 'brand': | 198 | case 'brand': |
192 | $result = FavoriteData::cancelProductFav($uid, $id, true); //取消品牌收藏 | 199 | $result = FavoriteData::cancelProductFav($uid, $id, true); //取消品牌收藏 |
-
Please register or login to post a comment