Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop
Conflicts: library/LibModels/Wap/Passport/LoginData.php library/Plugin/Helpers.php
Showing
12 changed files
with
366 additions
and
139 deletions
@@ -122,5 +122,15 @@ class AbstractAction extends Controller_Abstract | @@ -122,5 +122,15 @@ class AbstractAction extends Controller_Abstract | ||
122 | { | 122 | { |
123 | return $this->_request->isXmlHttpRequest(); | 123 | return $this->_request->isXmlHttpRequest(); |
124 | } | 124 | } |
125 | + | ||
126 | + /** | ||
127 | + * 跳转到错误页面 | ||
128 | + */ | ||
129 | + protected function error() | ||
130 | + { | ||
131 | + headers_sent() || header('Location: /error.html'); | ||
132 | + | ||
133 | + exit; | ||
134 | + } | ||
125 | 135 | ||
126 | } | 136 | } |
@@ -15,8 +15,8 @@ use Api\Yohobuy; | @@ -15,8 +15,8 @@ use Api\Yohobuy; | ||
15 | */ | 15 | */ |
16 | class DetailData | 16 | class DetailData |
17 | { | 17 | { |
18 | - const API_URI_ARTICLE = 'guang/service/v2/article/'; | ||
19 | - const API_URI_AUTHOR = 'guang/service/v1/author/'; | 18 | + const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; |
19 | + const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; | ||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * 逛资讯详情页数据封装 | 22 | * 逛资讯详情页数据封装 |
@@ -31,7 +31,7 @@ class DetailData | @@ -31,7 +31,7 @@ class DetailData | ||
31 | $result['getOtherArticle'] = array(); | 31 | $result['getOtherArticle'] = array(); |
32 | 32 | ||
33 | // 获取资讯 | 33 | // 获取资讯 |
34 | - $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::API_URI_ARTICLE, 'getArticle', array($id)); | 34 | + $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id)); |
35 | if (!isset($article['tag'])) { | 35 | if (!isset($article['tag'])) { |
36 | return $result; | 36 | return $result; |
37 | } else { | 37 | } else { |
@@ -39,7 +39,7 @@ class DetailData | @@ -39,7 +39,7 @@ class DetailData | ||
39 | } | 39 | } |
40 | 40 | ||
41 | // 获取作者信息 | 41 | // 获取作者信息 |
42 | - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::API_URI_AUTHOR, 'getAuthor', array($id), function ($retval) use (&$result) { | 42 | + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($id), function ($retval) use (&$result) { |
43 | $result['getAuthor'] = empty($retval) ? array() : $retval; | 43 | $result['getAuthor'] = empty($retval) ? array() : $retval; |
44 | }); | 44 | }); |
45 | 45 |
@@ -4,6 +4,7 @@ namespace LibModels\Wap\Guang; | @@ -4,6 +4,7 @@ namespace LibModels\Wap\Guang; | ||
4 | 4 | ||
5 | use Api\Sign; | 5 | use Api\Sign; |
6 | use Api\Yohobuy; | 6 | use Api\Yohobuy; |
7 | +use Plugin\Helpers; | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * 明星品牌和原创品牌相关的数据模型 | 10 | * 明星品牌和原创品牌相关的数据模型 |
@@ -17,6 +18,11 @@ use Api\Yohobuy; | @@ -17,6 +18,11 @@ use Api\Yohobuy; | ||
17 | class PlusstarData | 18 | class PlusstarData |
18 | { | 19 | { |
19 | 20 | ||
21 | + const URI_BRANDLIST = 'guang/api/v1/plustar/getlist'; | ||
22 | + const URI_BRANDINFO_PLUSSTAR = 'guang/service/v1/plustar/'; | ||
23 | + const URI_BRANDINFO_FAVORITE = 'shops/service/v1/favorite/'; | ||
24 | + const URI_BRANDINFO_ARTICLE = 'guang/service/v1/article/'; | ||
25 | + | ||
20 | /** | 26 | /** |
21 | * 品牌列表 | 27 | * 品牌列表 |
22 | * | 28 | * |
@@ -32,7 +38,7 @@ class PlusstarData | @@ -32,7 +38,7 @@ class PlusstarData | ||
32 | // 存放接口列表 | 38 | // 存放接口列表 |
33 | $urlList = array(); | 39 | $urlList = array(); |
34 | // 接口调用的URL | 40 | // 接口调用的URL |
35 | - $url = Yohobuy::SERVICE_URL . 'guang/api/v1/plustar/getlist'; | 41 | + $url = Yohobuy::SERVICE_URL . self::URI_BRANDLIST; |
36 | 42 | ||
37 | // 公共的参数 | 43 | // 公共的参数 |
38 | $param = Yohobuy::param(); | 44 | $param = Yohobuy::param(); |
@@ -80,7 +86,7 @@ class PlusstarData | @@ -80,7 +86,7 @@ class PlusstarData | ||
80 | $result['getArticleByBrand'] = array(); | 86 | $result['getArticleByBrand'] = array(); |
81 | 87 | ||
82 | // 品牌详情信息 | 88 | // 品牌详情信息 |
83 | - $brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/plustar/', 'getBrandInfo', array(array('id' => $id)) ); | 89 | + $brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_PLUSSTAR, 'getBrandInfo', array(array('id' => $id)) ); |
84 | if (!isset($brandInfo['brand_id'])) { | 90 | if (!isset($brandInfo['brand_id'])) { |
85 | return $result; | 91 | return $result; |
86 | } else { | 92 | } else { |
@@ -90,14 +96,14 @@ class PlusstarData | @@ -90,14 +96,14 @@ class PlusstarData | ||
90 | // 是否收藏店铺 | 96 | // 是否收藏店铺 |
91 | $isUidOk = $uid && is_numeric($uid); | 97 | $isUidOk = $uid && is_numeric($uid); |
92 | if ($isUidOk) { | 98 | if ($isUidOk) { |
93 | - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) { | 99 | + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) { |
94 | $result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data']; | 100 | $result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data']; |
95 | }); | 101 | }); |
96 | } | 102 | } |
97 | 103 | ||
98 | // 相关资讯列表 (3篇) | 104 | // 相关资讯列表 (3篇) |
99 | $result['getArticleByBrand'] = array(); | 105 | $result['getArticleByBrand'] = array(); |
100 | - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'guang/service/v1/article/', 'getArticleByBrand', array($brandInfo['brand_id'], 3, $udid), function($retval) use(&$result) { | 106 | + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_ARTICLE, 'getArticleByBrand', array($brandInfo['brand_id'], 3, $udid), function($retval) use(&$result) { |
101 | $result['getArticleByBrand'] = empty($retval) ? array() : $retval; | 107 | $result['getArticleByBrand'] = empty($retval) ? array() : $retval; |
102 | }); | 108 | }); |
103 | 109 | ||
@@ -120,24 +126,23 @@ class PlusstarData | @@ -120,24 +126,23 @@ class PlusstarData | ||
120 | break; | 126 | break; |
121 | } | 127 | } |
122 | 128 | ||
123 | - //$result['getNewProduct'] = $newProduct['data']['product_list']; | ||
124 | - | ||
125 | $skn = ''; | 129 | $skn = ''; |
126 | foreach ($newProduct['data']['product_list'] as $value) { | 130 | foreach ($newProduct['data']['product_list'] as $value) { |
127 | if (empty($value['goods_list'])) { | 131 | if (empty($value['goods_list'])) { |
128 | continue; | 132 | continue; |
129 | } | 133 | } |
130 | 134 | ||
135 | + // 商品信息列表 | ||
136 | + $result['getNewProduct'][] = Helpers::formatProduct($value); | ||
137 | + | ||
131 | // 用户是否收藏该商品 | 138 | // 用户是否收藏该商品 |
132 | $skn = $value['product_skn']; | 139 | $skn = $value['product_skn']; |
133 | $result['getUidProductFav'][ $skn ] = false; | 140 | $result['getUidProductFav'][ $skn ] = false; |
134 | if ($isUidOk) { | 141 | if ($isUidOk) { |
135 | - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) { | 142 | + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) { |
136 | $result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data']; | 143 | $result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data']; |
137 | }); | 144 | }); |
138 | } | 145 | } |
139 | - | ||
140 | - // @todo 需要根据页面结构封装返回数据 | ||
141 | } | 146 | } |
142 | } while (false); | 147 | } while (false); |
143 | 148 | ||
@@ -146,63 +151,8 @@ class PlusstarData | @@ -146,63 +151,8 @@ class PlusstarData | ||
146 | 151 | ||
147 | return $result; | 152 | return $result; |
148 | 153 | ||
149 | - | ||
150 | - // @todo 根据页面展示数据封装 | ||
151 | -// $url = ''; | ||
152 | -// if($uid > 0){ | ||
153 | -// $isLike = Favorite::getUidProductFav($uid, $new_goods_info['product_skn']); | ||
154 | -// } | ||
155 | -// if($client_type == 'web'){ | ||
156 | -// $baseUrl = QUtilsConfig::$websiteRoot['yohobuy']; | ||
157 | -// }else{ | ||
158 | -// $baseUrl = QUtilsConfig::$websiteRoot['h5']; | ||
159 | -// } | ||
160 | // $goods_url = MakeUrl::h5ProductDetailUrl($baseUrl,$new_goods_info['product_id'],$new_goods_info['goods_list'][0]['goods_id'],$new_goods_info['cn_alphabet']); | 154 | // $goods_url = MakeUrl::h5ProductDetailUrl($baseUrl,$new_goods_info['product_id'],$new_goods_info['goods_list'][0]['goods_id'],$new_goods_info['cn_alphabet']); |
161 | // $url = MakeUrl::makeUrl('go.productDetail',$goods_url, array('product_skn'=>$new_goods_info['product_skn']),$client_type); | 155 | // $url = MakeUrl::makeUrl('go.productDetail',$goods_url, array('product_skn'=>$new_goods_info['product_skn']),$client_type); |
162 | -// if((int)$new_goods_info['market_price'] == (int)$new_goods_info['sales_price']) | ||
163 | -// { | ||
164 | -// $new_goods_info['market_price'] = ''; | ||
165 | -// } | ||
166 | -// $tags = array( | ||
167 | -// 'isNew' => false, | ||
168 | -// 'isSale' => false, | ||
169 | -// 'isLimit' => false, | ||
170 | -// 'isYohood' => false, | ||
171 | -// 'midYear' => false, | ||
172 | -// 'yearEnd' => false, | ||
173 | -// ); | ||
174 | -// foreach ($new_goods_info['tags'] as $v){ | ||
175 | -// if($v == 'is_new'){ | ||
176 | -// $tags['isNew'] = true; | ||
177 | -// }elseif($v == 'is_discount'){ | ||
178 | -// $tags['isSale'] = true; | ||
179 | -// }elseif($v == 'is_limited'){ | ||
180 | -// $tags['isLimit'] = true; | ||
181 | -// }elseif($v == 'is_yohood'){ | ||
182 | -// $tags['isYohood'] = true; | ||
183 | -// }elseif($v == 'mid-year'){ | ||
184 | -// $tags['midYear'] = true; | ||
185 | -// }elseif($v == 'year-end'){ | ||
186 | -// $tags['yearEnd'] = true; | ||
187 | -// } | ||
188 | -// } | ||
189 | -// $newPatterns[$new_goods_info['product_skn']]= array ( | ||
190 | -// 'id'=>$new_goods_info['product_skn'], | ||
191 | -// 'product_id'=>$new_goods_info['product_id'], | ||
192 | -// 'product_skn'=>$new_goods_info['product_skn'], | ||
193 | -// 'thumb' => $new_goods_info['default_images'], | ||
194 | -// 'name' => $new_goods_info['product_name'], | ||
195 | -// 'isLike' => $isLike, | ||
196 | -// 'price' => $new_goods_info['market_price'], | ||
197 | -// 'salePrice' => $new_goods_info['sales_price'], | ||
198 | -// 'isSale' => $new_goods_info['is_discount'] == 'Y' ? true : false, | ||
199 | -// 'isFew' => $new_goods_info['is_soon_sold_out'] == 'Y' ? true : false, | ||
200 | -// 'isNew' => $new_goods_info['is_new'] == 'Y' ? true : false, | ||
201 | -// 'url' => $url, | ||
202 | -// 'tags' => $tags | ||
203 | -// ); | ||
204 | - | ||
205 | - | ||
206 | } | 156 | } |
207 | 157 | ||
208 | } | 158 | } |
1 | <?php | 1 | <?php |
2 | namespace LibModels\Wap\Passport; | 2 | namespace LibModels\Wap\Passport; |
3 | 3 | ||
4 | -use Api\Yohobuy; | ||
5 | use Api\Sign; | 4 | use Api\Sign; |
5 | +use Api\Yohobuy; | ||
6 | 6 | ||
7 | +/** | ||
8 | + * 登录的数据模型 | ||
9 | + * | ||
10 | + * @name LoginData | ||
11 | + * @package LibModels/Wap/Passport | ||
12 | + * @copyright yoho.inc | ||
13 | + * @version 1.0 (2015-10-12 14:05:04) | ||
14 | + * @author fei.hong <fei.hong@yoho.cn> | ||
15 | + */ | ||
7 | class LoginData | 16 | class LoginData |
8 | -{ | ||
9 | - /** | ||
10 | - * 第三方登录接口(包括alipay,qq,sina) | ||
11 | - * @param string $nickname 姓名 | ||
12 | - * @param string $openId 第三方唯一识别码 | ||
13 | - * @param string $sourceType 登录方式 | ||
14 | - * @return array 登录返回结果 | ||
15 | - */ | ||
16 | - public static function signinByOpenID($nickname, $openId, $sourceType) | ||
17 | - { | ||
18 | - // 构建必传参数 | ||
19 | - $param = Yohobuy::param(); | 17 | +{ |
18 | + | ||
19 | + /** | ||
20 | + * 登录 | ||
21 | + * | ||
22 | + * @param string $profile 邮箱或手机号 | ||
23 | + * @param string $password 密码 | ||
24 | + * @return array | ||
25 | + */ | ||
26 | + public static function signin($profile, $password) | ||
27 | + { | ||
28 | + $param = Yohobuy::param(); | ||
29 | + $param['method'] = 'app.passport.signin'; | ||
30 | + $param['profile'] = $profile; | ||
31 | + $param['password'] = $password; | ||
32 | + | ||
33 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 用户信息 | ||
38 | + * | ||
39 | + * @param int $uid 用户唯一ID | ||
40 | + * @return array | ||
41 | + */ | ||
42 | + public static function profile($uid) | ||
43 | + { | ||
44 | + $param = Yohobuy::param(); | ||
45 | + $param['method'] = 'app.passport.profile'; | ||
46 | + $param['uid'] = $uid; | ||
47 | + | ||
48 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 第三方登录接口(包括alipay,qq,sina) | ||
53 | + * @param string $nickname 姓名 | ||
54 | + * @param string $openId 第三方唯一识别码 | ||
55 | + * @param string $sourceType 登录方式 | ||
56 | + * @return array 登录返回结果 | ||
57 | + */ | ||
58 | + public static function signinByOpenID($nickname, $openId, $sourceType) | ||
59 | + { | ||
60 | + // 构建必传参数 | ||
61 | + $param = Yohobuy::param(); | ||
20 | 62 | ||
21 | $param['method'] = 'app.passport.signinByOpenID'; | 63 | $param['method'] = 'app.passport.signinByOpenID'; |
22 | - $param['openId'] = $openId; | ||
23 | - $param['source_type'] = $sourceType; | 64 | + $param['openId'] = $openId; |
65 | + $param['source_type'] = $sourceType; | ||
24 | $param['client_secret'] = Sign::getSign($param); | 66 | $param['client_secret'] = Sign::getSign($param); |
25 | 67 | ||
26 | return Yohobuy::get(Yohobuy::API_URL, $param); | 68 | return Yohobuy::get(Yohobuy::API_URL, $param); |
27 | - } | 69 | + } |
28 | } | 70 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -/* | ||
4 | - * To change this license header, choose License Headers in Project Properties. | ||
5 | - * To change this template file, choose Tools | Templates | ||
6 | - * and open the template in the editor. | 3 | +namespace LibModels\Wap\Passport; |
4 | + | ||
5 | +use Api\Sign; | ||
6 | +use Api\Yohobuy; | ||
7 | + | ||
8 | +/** | ||
9 | + * 注册的数据模型 | ||
10 | + * | ||
11 | + * @name RegData | ||
12 | + * @package LibModels/Wap/Passport | ||
13 | + * @copyright yoho.inc | ||
14 | + * @version 1.0 (2015-10-12 14:04:55) | ||
15 | + * @author fei.hong <fei.hong@yoho.cn> | ||
7 | */ | 16 | */ |
17 | +class RegData | ||
18 | +{ | ||
19 | + | ||
20 | + /** | ||
21 | + * 获取地区数据 | ||
22 | + * | ||
23 | + * @return array 地区数据 | ||
24 | + */ | ||
25 | + public static function getAreasData() | ||
26 | + { | ||
27 | + $param = Yohobuy::param(); | ||
28 | + $param['method'] = 'app.passport.getArea'; | ||
29 | + $param['client_secret'] = Sign::getSign($param); | ||
30 | + | ||
31 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * 发送手机注册验证码 | ||
36 | + * | ||
37 | + * @param string $area 地区号 如"86" | ||
38 | + * @param string $mobile 手机号 | ||
39 | + * @return array | ||
40 | + */ | ||
41 | + public static function sendCodeToMobile($area, $mobile) | ||
42 | + { | ||
43 | + $param = Yohobuy::param(); | ||
44 | + $param['method'] = 'app.register.sendRegCodeToMobile'; | ||
45 | + $param['area'] = $area; | ||
46 | + $param['mobile'] = $mobile; | ||
47 | + $param['client_secret'] = Sign::getSign($param); | ||
48 | + | ||
49 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * 验证手机注册的识别码 | ||
54 | + * | ||
55 | + * @param string $area 地区号 如"86" | ||
56 | + * @param string $mobile 手机号 | ||
57 | + * @param string $code 验证码 | ||
58 | + * @return array | ||
59 | + */ | ||
60 | + public static function validMobileCode($area, $mobile, $code) | ||
61 | + { | ||
62 | + $param = Yohobuy::param(); | ||
63 | + $param['method'] = 'app.register.validRegCode'; | ||
64 | + $param['area'] = $area; | ||
65 | + $param['mobile'] = $mobile; | ||
66 | + $param['code'] = $code; | ||
67 | + $param['client_secret'] = Sign::getSign($param); | ||
68 | + | ||
69 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * 通过手机注册 | ||
74 | + * | ||
75 | + * @param string $area 地区号 如"86" | ||
76 | + * @param string $mobile 手机号 | ||
77 | + * @param string $password 登录密码 | ||
78 | + * @return array | ||
79 | + */ | ||
80 | + public static function regMobile($area, $mobile, $password) | ||
81 | + { | ||
82 | + $param = Yohobuy::param(); | ||
83 | + $param['method'] = 'app.passport.register'; | ||
84 | + $param['area'] = $area; | ||
85 | + $param['profile'] = $mobile; | ||
86 | + $param['password'] = $password; | ||
87 | + $param['client_secret'] = Sign::getSign($param); | ||
88 | + | ||
89 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
90 | + } | ||
8 | 91 | ||
92 | +} |
@@ -22,15 +22,55 @@ class Helpers | @@ -22,15 +22,55 @@ class Helpers | ||
22 | } | 22 | } |
23 | 23 | ||
24 | /** | 24 | /** |
25 | - * 从数组中中获取指定键值对应的元素 | ||
26 | - * @param array $array 需要获取的数组 | ||
27 | - * @param array|string $keys 指定键值,数组或者字符串 | ||
28 | - * @return array 获取的数据 | 25 | + * 格式化商品信息 |
26 | + * | ||
27 | + * @param array $productData 需要格式化的商品数据 | ||
28 | + * @return array | false | ||
29 | */ | 29 | */ |
30 | - public static function array_get($array, $keys) | 30 | + public static function formatProduct($productData) |
31 | { | 31 | { |
32 | - return array_intersect_key($array, array_flip((array) $keys)); | 32 | + // 商品信息有问题,则不显示 |
33 | + if (!isset($productData['product_skn'])) { | ||
34 | + return false; | ||
35 | + } | ||
36 | + | ||
37 | + // 市场价和售价一样,则不显示市场价 | ||
38 | + if (intval($productData['market_price']) === intval($productData['sales_price'])) { | ||
39 | + $productData['market_price'] = ''; | ||
40 | + } | ||
41 | + | ||
42 | + $result = array(); | ||
43 | + $result['id'] = $productData['product_skn']; | ||
44 | + $result['product_id'] = $productData['product_id']; | ||
45 | + $result['thumb'] = $productData['default_images']; | ||
46 | + $result['name'] = $productData['product_name']; | ||
47 | + $result['price'] = $productData['market_price']; | ||
48 | + $result['salePrice'] = $productData['sales_price']; | ||
49 | + $result['isFew'] = ($productData['is_soon_sold_out'] === 'Y') ? true : false; | ||
50 | + $result['url'] = ''; // @todo | ||
51 | + $result['tags'] = array( | ||
52 | + 'isNew' => false, // 新品 | ||
53 | + 'isSale' => false, // 在售 | ||
54 | + 'isLimit' => false, // 限量 | ||
55 | + 'isNewFestival' => false, // 新品节 | ||
56 | + 'isReNew' => false, // 再到着 | ||
57 | + 'isYohood' => false, // YOHOOD | ||
58 | + 'midYear' => false, // 年中 | ||
59 | + 'yearEnd' => false, // 年末 | ||
60 | + ); | ||
61 | + | ||
62 | + foreach ($productData['tags'] as $tag) { | ||
63 | + if ($tag['is_limited'] === 'Y') { | ||
64 | + $result['tags']['isLimit'] = true; | ||
65 | + } elseif ($tag['is_yohood'] === 'Y') { | ||
66 | + $result['tags']['isYohood'] = true; | ||
67 | + } elseif ($tag['is_new'] === 'Y') { | ||
68 | + $result['tags']['isNew'] = true; | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
72 | + return $result; | ||
73 | + | ||
33 | } | 74 | } |
34 | 75 | ||
35 | - | ||
36 | } | 76 | } |
@@ -32,7 +32,7 @@ class TemplateLayout implements View_Interface | @@ -32,7 +32,7 @@ class TemplateLayout implements View_Interface | ||
32 | */ | 32 | */ |
33 | public function assign($name, $value = null) | 33 | public function assign($name, $value = null) |
34 | { | 34 | { |
35 | - $this->tpl_vars[$name] = $value; | 35 | + $this->_tpl_vars[$name] = $value; |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
@@ -43,10 +43,10 @@ class TemplateLayout implements View_Interface | @@ -43,10 +43,10 @@ class TemplateLayout implements View_Interface | ||
43 | */ | 43 | */ |
44 | public function clear($name = null) | 44 | public function clear($name = null) |
45 | { | 45 | { |
46 | - if (isset($this->tpl_vars[$name])) { | ||
47 | - unset($this->tpl_vars[$name]); | 46 | + if (isset($this->_tpl_vars[$name])) { |
47 | + unset($this->_tpl_vars[$name]); | ||
48 | } else { | 48 | } else { |
49 | - $this->tpl_vars = array(); | 49 | + $this->_tpl_vars = array(); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
@@ -79,8 +79,11 @@ class TemplateLayout implements View_Interface | @@ -79,8 +79,11 @@ class TemplateLayout implements View_Interface | ||
79 | if (!file_exists($viewName)) { | 79 | if (!file_exists($viewName)) { |
80 | return ''; | 80 | return ''; |
81 | } | 81 | } |
82 | - | ||
83 | - $tpl_vars = array_merge($this->tpl_vars, $tpl_vars); | 82 | + |
83 | + // 合并通过assign传递的参数 | ||
84 | + if (is_array($this->_tpl_vars)) { | ||
85 | + $tpl_vars = array_merge($this->_tpl_vars, $tpl_vars); | ||
86 | + } | ||
84 | // 取得模板的最后修改时间戳 | 87 | // 取得模板的最后修改时间戳 |
85 | $lastModifyTime = filemtime($viewName); | 88 | $lastModifyTime = filemtime($viewName); |
86 | // 使用MD5生成唯一的键名 | 89 | // 使用MD5生成唯一的键名 |
@@ -131,7 +134,7 @@ class TemplateLayout implements View_Interface | @@ -131,7 +134,7 @@ class TemplateLayout implements View_Interface | ||
131 | { | 134 | { |
132 | $result = false; | 135 | $result = false; |
133 | if (is_dir($path)) { | 136 | if (is_dir($path)) { |
134 | - $this->tpl_dir = $path; | 137 | + $this->_tpl_dir = $path; |
135 | $result = true; | 138 | $result = true; |
136 | } | 139 | } |
137 | return $result; | 140 | return $result; |
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | }()); | 23 | }()); |
24 | })(document, window); | 24 | })(document, window); |
25 | </script> | 25 | </script> |
26 | - <link rel="stylesheet" href="http://static.dev.yohobuy.com/css/index.css"> | 26 | + <link rel="stylesheet" href="http://172.16.6.248:8088/css/index.css"> |
27 | </head> | 27 | </head> |
28 | <body {{#if isPassportPage}}class=passport-body{{/if}}> | 28 | <body {{#if isPassportPage}}class=passport-body{{/if}}> |
29 | {{> layout/page_header}} | 29 | {{> layout/page_header}} |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
3 | use LibModels\Wap\Guang\PlusstarData; | 4 | use LibModels\Wap\Guang\PlusstarData; |
5 | +use Plugin\Helpers; | ||
4 | 6 | ||
5 | /** | 7 | /** |
6 | * 明星品牌和原创品牌 | 8 | * 明星品牌和原创品牌 |
7 | */ | 9 | */ |
8 | class PlusstarController extends AbstractAction | 10 | class PlusstarController extends AbstractAction |
9 | { | 11 | { |
10 | - | 12 | + |
11 | /** | 13 | /** |
12 | * 品牌列表页 | 14 | * 品牌列表页 |
15 | + * | ||
16 | + * @param int gender "1,3"表示男, "2,3"表示女 | ||
13 | */ | 17 | */ |
14 | public function listAction() | 18 | public function listAction() |
15 | { | 19 | { |
16 | - $data = array( | ||
17 | - 'star' => array( | ||
18 | - array( | ||
19 | - 'imgs' => array( | ||
20 | - array( | ||
21 | - 'url' => 'http://stussy.m.yohobuy.com', | ||
22 | - 'img' => 'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/6KTZ_01.jpg' | ||
23 | - ), | ||
24 | - array( | ||
25 | - 'url' => 'http://stussy.m.yohobuy.com', | ||
26 | - 'img' =>'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/5HUF_01.jpg' | ||
27 | - ) | ||
28 | - ) | ||
29 | - ), | ||
30 | - array( | ||
31 | - 'url' => 'http://stussy.m.yohobuy.com', | ||
32 | - 'img' => 'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/4STAYREAL_02.jpg', | ||
33 | - 'deps' => '优秀的自助品牌,高瞻远瞩的建设性意见来测试文字溢出后的处理问题' | ||
34 | - ) | ||
35 | - ), | ||
36 | - 'plus' => array( | ||
37 | - ) | ||
38 | - ); | ||
39 | - $this->_view->assign('title', 'YOHO!有货'); | ||
40 | - $this->_view->display('list', array('test' => 'hello world')); | ||
41 | - | ||
42 | - $test = PlusstarData::brandList("1,3", 1); | ||
43 | - var_dump($test); | 20 | + $data = array('ps' => array('star' => array(), 'plus' => array())); |
21 | + | ||
22 | + $brandList = array(); | ||
23 | + $build = array(); | ||
24 | + $imgs = array(); | ||
25 | + | ||
26 | + $gender = $this->get('gender', '1,3'); | ||
27 | + // 女 | ||
28 | + if ($gender === '2,3') { | ||
29 | + $brandList = PlusstarData::brandList('2,3', 2); | ||
30 | + } | ||
31 | + // 男 | ||
32 | + else { | ||
33 | + $brandList = PlusstarData::brandList('1,3', 1); | ||
34 | + } | ||
35 | + | ||
36 | + // 明星品牌列表 | ||
37 | + if (!empty($brandList['star']['data']['list'][0]['data'])) { | ||
38 | + foreach ($brandList['star']['data']['list'][0]['data'] as $star) { | ||
39 | + $imgs = array(); | ||
40 | + $build = array(); | ||
41 | + | ||
42 | + // 情况1: 多张图 | ||
43 | + if (isset($star['data'][1])) { | ||
44 | + foreach ($star['data'] as $value) { | ||
45 | + $build['url'] = $value['url']; | ||
46 | + $build['img'] = Helpers::getImageUrl($value['src'], 640, 310); | ||
47 | + $imgs[] = $build; | ||
48 | + } | ||
49 | + $data['ps']['star'][] = array('imgs' => $imgs); | ||
50 | + } | ||
51 | + // 情况2: 单张图 | ||
52 | + elseif (isset($star['data'][0])) { | ||
53 | + $build['url'] = $star['data'][0]['url']; | ||
54 | + $build['img'] = $star['data'][0]['src']; | ||
55 | + $data['ps']['star'][] = $build; | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + // 原创品牌列表 | ||
61 | + if (!empty($brandList['original']['data']['list'][0]['data'])) { | ||
62 | + foreach ($brandList['original']['data']['list'][0]['data'] as $original) { | ||
63 | + $imgs = array(); | ||
64 | + $build = array(); | ||
65 | + | ||
66 | + // 情况1: 多张图 | ||
67 | + if (isset($original['data'][1])) { | ||
68 | + foreach ($original['data'] as $value) { | ||
69 | + $build['url'] = $value['url']; | ||
70 | + $build['img'] = Helpers::getImageUrl($value['src'], 640, 310); | ||
71 | + $build['deps'] = $original['brand_title']; | ||
72 | + $imgs[] = $build; | ||
73 | + } | ||
74 | + $data['ps']['plus'][] = array('imgs' => $imgs); | ||
75 | + } | ||
76 | + // 情况2: 单张图 | ||
77 | + elseif (isset($original['data'][0])) { | ||
78 | + $build['url'] = $original['data'][0]['url']; | ||
79 | + $build['img'] = Helpers::getImageUrl($original['data'][0]['src'], 640, 310); | ||
80 | + $build['deps'] = $original['brand_title']; | ||
81 | + $data['ps']['plus'][] = $build; | ||
82 | + } | ||
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + $this->_view->display('list', $data); | ||
87 | + | ||
88 | + $brandList = array(); | ||
89 | + $data = array(); | ||
44 | } | 90 | } |
45 | - | 91 | + |
46 | /** | 92 | /** |
47 | * 品牌介绍页 | 93 | * 品牌介绍页 |
48 | */ | 94 | */ |
49 | public function detailAction() | 95 | public function detailAction() |
50 | { | 96 | { |
51 | - $test = PlusstarData::brandInfo(67, '1,3', 123456); | ||
52 | - var_dump($test); | 97 | + $data = array(); |
98 | + | ||
99 | + $id = $this->get('id'); | ||
100 | + $gender = $this->get('gender', '1,3'); | ||
101 | + $uid = 0; // @todo | ||
102 | + $udid = null; // @todo | ||
103 | + | ||
104 | + do { | ||
105 | + /* 判断参数是否有效 */ | ||
106 | + if (!is_numeric($id) || ($gender !== '1,3' && $gender !== '2,3')) { | ||
107 | + break; | ||
108 | + } | ||
109 | + | ||
110 | + /* 判断品牌信息是否为空 */ | ||
111 | + $brandInfo = PlusstarData::brandInfo($id, $gender, $uid, $udid); var_dump($brandInfo); exit; | ||
112 | + if (empty($brandInfo['getBrandInfo']['brand_id'])) { | ||
113 | + break; | ||
114 | + } | ||
115 | + | ||
116 | + $data['id'] = $brandInfo['getBrandInfo']['brand_id']; | ||
117 | + $data['banner'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['cover_img'], 640, 309); | ||
118 | + $data['logo'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['brand_ico'], 160, 160); | ||
119 | + $data['name'] = $brandInfo['getBrandInfo']['name']; | ||
120 | + $data['isLike'] = $brandInfo['getUidBrandFav']; | ||
121 | + $data['likeUrl'] = "http://guang.m.yohobuy.com/plustar/brandinfo?id=285&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":285}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"701"}},"priority":"Y"}}"; | ||
122 | + $data['intro'] = empty($brandInfo['brand_intro']) ? '' : strip_tags($brandInfo['brand_intro']); | ||
123 | + $data['newArrival'] = array(); | ||
124 | + $data['newArrival']['moreUrl'] = ''; // @todo | ||
125 | + $data['newArrival']['naList'] = $brandInfo['getNewProduct']; | ||
126 | + $data['infos'] = array(); | ||
127 | + | ||
128 | + $brandInfo = array(); | ||
129 | + | ||
130 | + } while (false); | ||
131 | + | ||
132 | + if (array() === $data) { | ||
133 | + $this->error(); | ||
134 | + } else { | ||
135 | + $this->_view->display('detail', $data); | ||
136 | + } | ||
53 | } | 137 | } |
54 | - | ||
55 | -} | ||
138 | + | ||
139 | +} |
-
Please register or login to post a comment