code review by fei.hong: do modify app api hotfix main.js
Showing
8 changed files
with
159 additions
and
72 deletions
@@ -25,6 +25,7 @@ var start = 0, | @@ -25,6 +25,7 @@ var start = 0, | ||
25 | lazyLoad($('img.lazy')); | 25 | lazyLoad($('img.lazy')); |
26 | 26 | ||
27 | $('.nav-btn').on('touchstart', function(event) { | 27 | $('.nav-btn').on('touchstart', function(event) { |
28 | + $sideNav.css('pointer-events', 'none'); | ||
28 | $mobileWrap.addClass('menu-open'); | 29 | $mobileWrap.addClass('menu-open'); |
29 | $overlay.show().css('opacity', 0.3); | 30 | $overlay.show().css('opacity', 0.3); |
30 | $sideNav.addClass('on'); | 31 | $sideNav.addClass('on'); |
@@ -37,6 +38,11 @@ $('.nav-btn').on('touchstart', function(event) { | @@ -37,6 +38,11 @@ $('.nav-btn').on('touchstart', function(event) { | ||
37 | height: $(window).height(), | 38 | height: $(window).height(), |
38 | overflow: 'hidden' | 39 | overflow: 'hidden' |
39 | }); | 40 | }); |
41 | + | ||
42 | + setTimeout(function() { | ||
43 | + $sideNav.css('pointer-events', 'auto'); | ||
44 | + }, 400); | ||
45 | + | ||
40 | return false; | 46 | return false; |
41 | }); | 47 | }); |
42 | 48 |
@@ -79,8 +79,8 @@ function loadData($parent, url, page) { | @@ -79,8 +79,8 @@ function loadData($parent, url, page) { | ||
79 | page: page | 79 | page: page |
80 | }, | 80 | }, |
81 | success: function(data) { | 81 | success: function(data) { |
82 | - var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); | ||
83 | - | 82 | + var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading'); |
83 | + | ||
84 | if (url === 'favBrand') { | 84 | if (url === 'favBrand') { |
85 | $brandLoadMore.addClass('hide'); | 85 | $brandLoadMore.addClass('hide'); |
86 | } else { | 86 | } else { |
@@ -91,23 +91,23 @@ function loadData($parent, url, page) { | @@ -91,23 +91,23 @@ function loadData($parent, url, page) { | ||
91 | $loadingMask.addClass('hide'); | 91 | $loadingMask.addClass('hide'); |
92 | $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | 92 | $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); |
93 | } else if (data === 'end') { | 93 | } else if (data === 'end') { |
94 | - | ||
95 | - //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
96 | - if ($loadingMask && !$loadingMask.hasClass('hide')) { | 94 | + |
95 | + //处理data等于end时如果loadingMask存在且没有hide样式的情况 | ||
96 | + if ($loadingMask && !$loadingMask.hasClass('hide')) { | ||
97 | $loadingMask.addClass('hide'); | 97 | $loadingMask.addClass('hide'); |
98 | - $parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); | ||
99 | - } | ||
100 | - | 98 | + //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide'); |
99 | + } | ||
100 | + | ||
101 | $parent.closest('.fav-type').find('.fav-load-background') | 101 | $parent.closest('.fav-type').find('.fav-load-background') |
102 | - .removeClass('fav-load-background').html('没有更多了'); | ||
103 | - | 102 | + .removeClass('fav-load-background').html('没有更多了'); |
103 | + | ||
104 | // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 | 104 | // hf: fixes bug to 修改没有数据还调接口,加载错误页面问题 |
105 | brandLockId = true; | 105 | brandLockId = true; |
106 | lockId = true; | 106 | lockId = true; |
107 | } else if (data.length > 10) { | 107 | } else if (data.length > 10) { |
108 | $parent.append(data); | 108 | $parent.append(data); |
109 | - | ||
110 | - //如果有数据loadingMask会被remove掉 | 109 | + |
110 | + //如果有数据loadingMask会被remove掉 | ||
111 | $loadingMask.remove(); | 111 | $loadingMask.remove(); |
112 | if (url === 'favBrand') { | 112 | if (url === 'favBrand') { |
113 | initSwiper(data);//如果是收藏品牌需要初始化swiper | 113 | initSwiper(data);//如果是收藏品牌需要初始化swiper |
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | +<head> | ||
4 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
5 | + <meta charset="utf-8"> | ||
6 | + <title>{{staticTitle}}</title> | ||
7 | + <!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> --> | ||
8 | + <meta name="format-detection" content="telephone=no"> | ||
9 | + <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui"> | ||
10 | + <meta name="apple-mobile-web-app-capable" content="yes"> | ||
11 | + <meta name="apple-mobile-web-app-status-bar-style" content="grey"> | ||
12 | + <script> | ||
13 | + (function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="80px"}else{e.style.fontSize=80*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window); | ||
14 | + </script> | ||
15 | +</head> | ||
16 | +<body> | ||
17 | + <div class="main-wrap"> | ||
18 | + 元宵节抽签 | ||
19 | + </div> | ||
20 | +</body> |
1 | +<?php | ||
2 | + | ||
3 | +use Action\HuodongAction; | ||
4 | +use Plugin\Helpers; | ||
5 | +use LibModels\Wap\Cuxiao\ActivityData; | ||
6 | +use Api\Yohobuy; | ||
7 | + | ||
8 | +/** | ||
9 | + * 元宵抽签活动 | ||
10 | + */ | ||
11 | +class YuanxiaoController extends HuodongAction | ||
12 | +{ | ||
13 | + /** | ||
14 | + * 元宵抽签 | ||
15 | + */ | ||
16 | + public function indexAction() | ||
17 | + { | ||
18 | + $this->_view->display('index', array( | ||
19 | + 'staticTitle' => '元宵抽签' | ||
20 | + )); | ||
21 | + } | ||
22 | +} |
@@ -41,7 +41,7 @@ class HfController extends AbstractAction | @@ -41,7 +41,7 @@ class HfController extends AbstractAction | ||
41 | * patchv 当前补丁的版本号,没有就传空 string "100" | 41 | * patchv 当前补丁的版本号,没有就传空 string "100" |
42 | * filecode md5(md5(文件内容) + "yohopatch2016") string "1233321121212332" | 42 | * filecode md5(md5(文件内容) + "yohopatch2016") string "1233321121212332" |
43 | * ] | 43 | * ] |
44 | - * echo md5(file_get_contents('http://ad.yoho.cn/test/main.js')); | 44 | + * echo md5(file_get_contents('http://cdn.yoho.cn/app-hotfix/yohobuy/4.0.0/main.js')); |
45 | */ | 45 | */ |
46 | public function v1Action() | 46 | public function v1Action() |
47 | { | 47 | { |
@@ -51,16 +51,17 @@ class HfController extends AbstractAction | @@ -51,16 +51,17 @@ class HfController extends AbstractAction | ||
51 | $version = $this->post('app_version'); | 51 | $version = $this->post('app_version'); |
52 | switch ($version) { | 52 | switch ($version) { |
53 | case '4.0.0': // 版本号 | 53 | case '4.0.0': // 版本号 |
54 | -// $result['data']['url'] = 'http://ad.yoho.cn/test/main.js'; | ||
55 | -// $result['data']['patchv'] = '102'; | ||
56 | -// $result['data']['filecode'] = md5('bae3f6522d7a53436931799ac10f8a40' . 'yohopatch2016'); | ||
57 | -// $result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data'])); | ||
58 | -// break; | 54 | + $result['data']['url'] = 'http://cdn.yoho.cn/app-hotfix/yohobuy/4.0.0/main.js'; |
55 | + $result['data']['patchv'] = '102'; | ||
56 | + $result['data']['filecode'] = md5('53b86b14490ead50ff78cac30a2494f3' . 'yohopatch2016'); | ||
57 | + $result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data'])); | ||
58 | + break; | ||
59 | default: // 默认 | 59 | default: // 默认 |
60 | $result['data']['url'] = ''; | 60 | $result['data']['url'] = ''; |
61 | $result['data']['patchv'] = ''; | 61 | $result['data']['patchv'] = ''; |
62 | $result['data']['filecode'] = ''; | 62 | $result['data']['filecode'] = ''; |
63 | $result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data'])); | 63 | $result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data'])); |
64 | + break; | ||
64 | } | 65 | } |
65 | 66 | ||
66 | $this->echoJson($result); | 67 | $this->echoJson($result); |
@@ -113,6 +113,11 @@ class SearchController extends AbstractAction | @@ -113,6 +113,11 @@ class SearchController extends AbstractAction | ||
113 | $classNames = Category\ClassModel::getClassNames(); | 113 | $classNames = Category\ClassModel::getClassNames(); |
114 | 114 | ||
115 | do { | 115 | do { |
116 | + // 品类名称为空时跳出 | ||
117 | + if (empty($classNames)) { | ||
118 | + break; | ||
119 | + } | ||
120 | + | ||
116 | /* 精确查一级品类 */ | 121 | /* 精确查一级品类 */ |
117 | $sorts = array_keys($classNames['first'], $query, true); | 122 | $sorts = array_keys($classNames['first'], $query, true); |
118 | if (isset($sorts[0])) { | 123 | if (isset($sorts[0])) { |
@@ -115,7 +115,7 @@ class UserModel | @@ -115,7 +115,7 @@ class UserModel | ||
115 | // 处理个人中心页面优选新品数据 | 115 | // 处理个人中心页面优选新品数据 |
116 | if (!empty($preferenceData['data'])) { | 116 | if (!empty($preferenceData['data'])) { |
117 | foreach ($preferenceData['data'] as $value) { | 117 | foreach ($preferenceData['data'] as $value) { |
118 | - $value = Helpers::formatProduct($value, false, true, true, 299, 388, false, false); | 118 | + $value = Helpers::formatProduct($value, false, true, true, 299, 388, false); |
119 | if (false !== $value) { | 119 | if (false !== $value) { |
120 | $result['recommendList'][] = $value; | 120 | $result['recommendList'][] = $value; |
121 | } | 121 | } |
@@ -188,31 +188,48 @@ class UserModel | @@ -188,31 +188,48 @@ class UserModel | ||
188 | $favProduct = UserData::favoriteProductData($uid, $page, $limit); | 188 | $favProduct = UserData::favoriteProductData($uid, $page, $limit); |
189 | 189 | ||
190 | // 处理用户收藏的商品数据 | 190 | // 处理用户收藏的商品数据 |
191 | - if (isset($favProduct['data']) && $page <= $favProduct['data']['page_total']) { | ||
192 | - $datas = array(); | ||
193 | - $product = array(); | ||
194 | - foreach ($favProduct['data']['product_list'] as $val) { | ||
195 | - if (empty($val['product_skn'])) { | ||
196 | - continue; | ||
197 | - } | 191 | + do { |
192 | + // 开始就没获取到数据或者获取的数据为空时的处理 | ||
193 | + if ((!$favProduct || isset($favProduct['data']['product_list']) && empty($favProduct['data']['product_list'])) && $page == 1) { | ||
194 | + break; | ||
195 | + } | ||
198 | 196 | ||
197 | + // 加载第二页以及第二页之后的数据时接口不返回时的处理 | ||
198 | + if ($page > 1 && !$favProduct) { | ||
199 | + $result['end'] = true; | ||
200 | + break; | ||
201 | + } | ||
202 | + | ||
203 | + if ($page <= $favProduct['data']['page_total']) { | ||
204 | + $datas = array(); | ||
199 | $product = array(); | 205 | $product = array(); |
200 | - $product['fav_id'] = $val['product_id']; | ||
201 | - $product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : ''; | ||
202 | - $product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : ''; | ||
203 | - ; | ||
204 | - $product['title'] = $val['product_name']; | ||
205 | - $product['price'] = '¥' . Helpers::transPrice($val['market_price']); | ||
206 | - $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false; | ||
207 | - $product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false; | ||
208 | - $product['sellOut'] = ($val['storage'] <= 0); | ||
209 | - | ||
210 | - $datas[] = $product; | ||
211 | - } | ||
212 | - !empty($datas) && $result['hasFavProduct'] = $datas; | ||
213 | - } else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) { | ||
214 | - $result['end'] = true; | ||
215 | - } | 206 | + foreach ($favProduct['data']['product_list'] as $val) { |
207 | + if (empty($val['product_skn'])) { | ||
208 | + continue; | ||
209 | + } | ||
210 | + | ||
211 | + $product = array(); | ||
212 | + $product['fav_id'] = $val['product_id']; | ||
213 | + $product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : ''; | ||
214 | + $product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : ''; | ||
215 | + ; | ||
216 | + $product['title'] = $val['product_name']; | ||
217 | + $product['price'] = '¥' . Helpers::transPrice($val['market_price']); | ||
218 | + $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false; | ||
219 | + $product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false; | ||
220 | + $product['sellOut'] = ($val['storage'] <= 0); | ||
221 | + | ||
222 | + $datas[] = $product; | ||
223 | + } | ||
224 | + | ||
225 | + if (!empty($datas)) { | ||
226 | + $result['hasFavProduct'] = $datas; | ||
227 | + } | ||
228 | + } else { | ||
229 | + $result['end'] = true; | ||
230 | + } | ||
231 | + | ||
232 | + } while (false); | ||
216 | 233 | ||
217 | return $result; | 234 | return $result; |
218 | } | 235 | } |
@@ -234,40 +251,56 @@ class UserModel | @@ -234,40 +251,56 @@ class UserModel | ||
234 | $favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit); | 251 | $favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit); |
235 | 252 | ||
236 | // 处理用户收藏的品牌数据 | 253 | // 处理用户收藏的品牌数据 |
237 | - if (isset($favBrand['data']) && $page <= $favBrand['data']['page_total']) { | ||
238 | - $datas = array(); | ||
239 | - $brand = array(); | ||
240 | - foreach ($favBrand['data']['brand_list'] as $val) { | ||
241 | - $brand = array(); | ||
242 | - $brand['id'] = $val['brand_id']; | ||
243 | - $brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : ''; | ||
244 | - $brand['brandName'] = $val['brand_name']; | ||
245 | - $brand['update'] = $val['new_product_num']; | ||
246 | - $brand['discount'] = $val['product_discount_num']; | ||
247 | - $brand['link'] = Helpers::url('', array(), $val['brand_domain']); | ||
248 | - | ||
249 | - // 处理品牌产品 | ||
250 | - $product = array(); | ||
251 | - foreach ($val['new_product'] as $one) { | ||
252 | - if (empty($one['product_skn'])) { | ||
253 | - continue; | ||
254 | - } | 254 | + do { |
255 | + // 开始就没获取到数据或者获取的数据为空时的处理 | ||
256 | + if ((!$favBrand || isset($favBrand['data']['total']) && empty($favBrand['data']['total'])) && $page == 1) { | ||
257 | + break; | ||
258 | + } | ||
255 | 259 | ||
260 | + // 加载第二页以及第二页之后的数据时接口不返回时的处理 | ||
261 | + if ($page > 1 && !$favBrand) { | ||
262 | + $result['end'] = true; | ||
263 | + break; | ||
264 | + } | ||
265 | + | ||
266 | + if ($page <= $favBrand['data']['page_total']) { | ||
267 | + $datas = array(); | ||
268 | + $brand = array(); | ||
269 | + foreach ($favBrand['data']['brand_list'] as $val) { | ||
270 | + $brand = array(); | ||
271 | + $brand['id'] = $val['brand_id']; | ||
272 | + $brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : ''; | ||
273 | + $brand['brandName'] = $val['brand_name']; | ||
274 | + $brand['update'] = $val['new_product_num']; | ||
275 | + $brand['discount'] = $val['product_discount_num']; | ||
276 | + $brand['link'] = Helpers::url('', array(), $val['brand_domain']); | ||
277 | + | ||
278 | + // 处理品牌产品 | ||
256 | $product = array(); | 279 | $product = array(); |
257 | - $product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : ''; | ||
258 | - $product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : ''; | ||
259 | - $product['price'] = '¥' . Helpers::transPrice($one['market_price']); | ||
260 | - $product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false; | 280 | + foreach ($val['new_product'] as $one) { |
281 | + if (empty($one['product_skn'])) { | ||
282 | + continue; | ||
283 | + } | ||
284 | + | ||
285 | + $product = array(); | ||
286 | + $product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : ''; | ||
287 | + $product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : ''; | ||
288 | + $product['price'] = '¥' . Helpers::transPrice($one['market_price']); | ||
289 | + $product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false; | ||
290 | + | ||
291 | + $brand['productList'][] = $product; | ||
292 | + } | ||
261 | 293 | ||
262 | - $brand['productList'][] = $product; | 294 | + $datas[] = $brand; |
263 | } | 295 | } |
264 | 296 | ||
265 | - $datas[] = $brand; | 297 | + if (!empty($datas)) { |
298 | + $result['hasFavBrand'] = $datas; | ||
299 | + } | ||
300 | + } else { | ||
301 | + $result['end'] = true; | ||
266 | } | 302 | } |
267 | - !empty($datas) && $result['hasFavBrand'] = $datas; | ||
268 | - } else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) { | ||
269 | - $result['end'] = true; | ||
270 | - } | 303 | + } while (false); |
271 | 304 | ||
272 | return $result; | 305 | return $result; |
273 | } | 306 | } |
@@ -331,7 +364,7 @@ class UserModel | @@ -331,7 +364,7 @@ class UserModel | ||
331 | 364 | ||
332 | $record = array(); | 365 | $record = array(); |
333 | $record['product_name'] = $val['product_name']; | 366 | $record['product_name'] = $val['product_name']; |
334 | - $record['product_id'] = $val['product_id']; | 367 | + $record['product_skn'] = $val['product_skn']; |
335 | $record['link'] = Helpers::url('/product/show_' . $val['product_skn'] . '.html'); | 368 | $record['link'] = Helpers::url('/product/show_' . $val['product_skn'] . '.html'); |
336 | $record['image'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : ''; | 369 | $record['image'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : ''; |
337 | $record['sales_price'] = Helpers::transPrice($val['sales_price']); | 370 | $record['sales_price'] = Helpers::transPrice($val['sales_price']); |
@@ -220,7 +220,7 @@ class IndexController extends AbstractAction | @@ -220,7 +220,7 @@ class IndexController extends AbstractAction | ||
220 | $data['goodList'] += $condition; | 220 | $data['goodList'] += $condition; |
221 | $data['pageFooter'] = true; | 221 | $data['pageFooter'] = true; |
222 | 222 | ||
223 | - if ($title === '') { | 223 | + if (empty($title)) { |
224 | $title = $domain; | 224 | $title = $domain; |
225 | } | 225 | } |
226 | $this->setTitle($title); | 226 | $this->setTitle($title); |
-
Please register or login to post a comment