Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into feature/web-list
Showing
6 changed files
with
98 additions
and
5 deletions
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | namespace LibModels\Web\Home; | 2 | namespace LibModels\Web\Home; |
3 | use Api\Yohobuy; | 3 | use Api\Yohobuy; |
4 | use Api\Sign; | 4 | use Api\Sign; |
5 | -use Plugin\Helpers; | 5 | +use WebPlugin\Helpers; |
6 | class UserData extends \LibModels\Wap\Home\UserData | 6 | class UserData extends \LibModels\Wap\Home\UserData |
7 | { | 7 | { |
8 | /** | 8 | /** |
1 | +<?php | ||
2 | +namespace LibModels\Web\Product; | ||
3 | + | ||
4 | +use Api\Yohobuy; | ||
5 | +/** | ||
6 | + * FavoriteData | ||
7 | + * 收藏相关接口 | ||
8 | + * @author Administrator | ||
9 | + */ | ||
10 | +class FavoriteData { | ||
11 | + | ||
12 | + const URL_PRODUCT_FAVORITE = 'shops/service/v1/favorite/'; | ||
13 | + | ||
14 | + /** | ||
15 | + * 根据uid和商品的skn查询是否被用户收藏 | ||
16 | + * @param $uid | ||
17 | + * @param $productSkn | ||
18 | + * @return boolean 收藏 true 未收藏 false | ||
19 | + */ | ||
20 | + public static function getUidProductFav($uid, $productSkn) | ||
21 | + { | ||
22 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'getUidProductFav', array($uid, $productSkn)); | ||
23 | + } | ||
24 | + | ||
25 | + /** | ||
26 | + * 根据uid和商品的skn收藏商品 | ||
27 | + * @param $uid | ||
28 | + * @param $productSkn | ||
29 | + * @return bool | ||
30 | + */ | ||
31 | + public static function addUidProductFav($uid, $productSkn) | ||
32 | + { | ||
33 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'addUidProductFav', array($uid, $productSkn)); | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 根据uid和商品的skn取消收藏商品 | ||
38 | + * @param $uid | ||
39 | + * @param $productSkn | ||
40 | + * @return bool | ||
41 | + */ | ||
42 | + public static function delUidProductFav($uid, $productSkn) | ||
43 | + { | ||
44 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'delUidProductFav', array($uid, $productSkn)); | ||
45 | + } | ||
46 | + | ||
47 | +} |
@@ -71,7 +71,7 @@ class Bootstrap extends Bootstrap_Abstract | @@ -71,7 +71,7 @@ class Bootstrap extends Bootstrap_Abstract | ||
71 | $controller = 'Index'; | 71 | $controller = 'Index'; |
72 | $action = 'Index'; | 72 | $action = 'Index'; |
73 | // 二级域名 | 73 | // 二级域名 |
74 | - if (2 === $level) { | 74 | + if (3 === $level) { |
75 | $url = strtolower($dispatcher->getRequest()->getRequestUri()); | 75 | $url = strtolower($dispatcher->getRequest()->getRequestUri()); |
76 | if(empty($url) || $url == '/index' || $url == '/') { | 76 | if(empty($url) || $url == '/index' || $url == '/') { |
77 | $urlAction = '/index'; | 77 | $urlAction = '/index'; |
@@ -221,6 +221,7 @@ class SearchModel | @@ -221,6 +221,7 @@ class SearchModel | ||
221 | //组织数据结构 | 221 | //组织数据结构 |
222 | $data = HelperSearch::getProductPic($data['data']['product_list'], $options); | 222 | $data = HelperSearch::getProductPic($data['data']['product_list'], $options); |
223 | } | 223 | } |
224 | + $data['isFavorite'] = $options['isFavorite']; | ||
224 | echo json_encode($data); | 225 | echo json_encode($data); |
225 | } | 226 | } |
226 | 227 |
1 | <?php | 1 | <?php |
2 | use Action\WebAction; | 2 | use Action\WebAction; |
3 | use Product\SearchModel; | 3 | use Product\SearchModel; |
4 | +use LibModels\Web\Product\FavoriteData; | ||
5 | + | ||
4 | class ListController extends WebAction | 6 | class ListController extends WebAction |
5 | { | 7 | { |
6 | public function indexAction() | 8 | public function indexAction() |
@@ -12,6 +14,7 @@ class ListController extends WebAction | @@ -12,6 +14,7 @@ class ListController extends WebAction | ||
12 | 'positionId' => $positionId, | 14 | 'positionId' => $positionId, |
13 | 'reviewNum' => 6 | 15 | 'reviewNum' => 6 |
14 | ); | 16 | ); |
17 | + | ||
15 | $indexData = Product\IndexModel::getIndexData($condition, $options); | 18 | $indexData = Product\IndexModel::getIndexData($condition, $options); |
16 | 19 | ||
17 | $data = array( | 20 | $data = array( |
@@ -31,8 +34,6 @@ class ListController extends WebAction | @@ -31,8 +34,6 @@ class ListController extends WebAction | ||
31 | 'order' => 's_t_desc' | 34 | 'order' => 's_t_desc' |
32 | ); | 35 | ); |
33 | $options = array( | 36 | $options = array( |
34 | - 'specialsale_id' => 'Y', | ||
35 | - 'needDay' => 'Y', | ||
36 | 'reviewNum' => 6 | 37 | 'reviewNum' => 6 |
37 | ); | 38 | ); |
38 | 39 | ||
@@ -69,7 +70,12 @@ class ListController extends WebAction | @@ -69,7 +70,12 @@ class ListController extends WebAction | ||
69 | */ | 70 | */ |
70 | public function getProductPicAction() | 71 | public function getProductPicAction() |
71 | { | 72 | { |
73 | + if (!$this->isAjax()) { | ||
74 | + return; | ||
75 | + } | ||
72 | $product_skn = $this->post('skn'); | 76 | $product_skn = $this->post('skn'); |
77 | + $uid = $this->getUid(); | ||
78 | + | ||
73 | if (!$product_skn) { | 79 | if (!$product_skn) { |
74 | return ; | 80 | return ; |
75 | } | 81 | } |
@@ -90,6 +96,46 @@ class ListController extends WebAction | @@ -90,6 +96,46 @@ class ListController extends WebAction | ||
90 | 'imgSize' => $imgSize, | 96 | 'imgSize' => $imgSize, |
91 | 'minImgSize' => $minImgSize, | 97 | 'minImgSize' => $minImgSize, |
92 | ); | 98 | ); |
99 | + | ||
100 | + $isFavorite = false; | ||
101 | + if ($uid) { | ||
102 | + $favorite = FavoriteData::getUidProductFav($uid, $product_skn); | ||
103 | + if (isset($favorite['code']) && $favorite['code'] == 200) { | ||
104 | + $isFavorite = true; | ||
105 | + } | ||
106 | + } | ||
107 | + $options['isFavorite'] = $isFavorite; | ||
93 | SearchModel::getProductPic($product_skn, $options); | 108 | SearchModel::getProductPic($product_skn, $options); |
94 | } | 109 | } |
110 | + | ||
111 | + /** | ||
112 | + * 根据product_skn收藏 | ||
113 | + * @author | ||
114 | + * @return json | ||
115 | + */ | ||
116 | + public static function changeFavoriteAction() | ||
117 | + { | ||
118 | + if (!$this->isAjax()) { | ||
119 | + return; | ||
120 | + } | ||
121 | + $product_skn = $this->post('skn'); | ||
122 | + $isFavorite = $this->post('isFavorite'); | ||
123 | + $uid = $this->getUid(); | ||
124 | + | ||
125 | + do { | ||
126 | + if (!$product_skn && !$uid) { | ||
127 | + break; | ||
128 | + } | ||
129 | + if ($isFavorite) { | ||
130 | + $result = FavoriteData::delUidProductFav($uid, $product_skn); | ||
131 | + $this->echoJson($result); | ||
132 | + break; | ||
133 | + }else{ | ||
134 | + $result = FavoriteData::addUidProductFav($uid, $product_skn); | ||
135 | + $this->echoJson($result); | ||
136 | + break; | ||
137 | + } | ||
138 | + } while(false); | ||
139 | + | ||
140 | + } | ||
95 | } | 141 | } |
-
Please register or login to post a comment