Authored by hf

code review by fei.hong: do modify app api hotfix main.js

@@ -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
@@ -95,7 +95,7 @@ function loadData($parent, url, page) { @@ -95,7 +95,7 @@ function loadData($parent, url, page) {
95 //处理data等于end时如果loadingMask存在且没有hide样式的情况 95 //处理data等于end时如果loadingMask存在且没有hide样式的情况
96 if ($loadingMask && !$loadingMask.hasClass('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'); 98 + //$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
99 } 99 }
100 100
101 $parent.closest('.fav-type').find('.fav-load-background') 101 $parent.closest('.fav-type').find('.fav-load-background')
  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,7 +188,19 @@ class UserModel @@ -188,7 +188,19 @@ 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']) { 191 + do {
  192 + // 开始就没获取到数据或者获取的数据为空时的处理
  193 + if ((!$favProduct || isset($favProduct['data']['product_list']) && empty($favProduct['data']['product_list'])) && $page == 1) {
  194 + break;
  195 + }
  196 +
  197 + // 加载第二页以及第二页之后的数据时接口不返回时的处理
  198 + if ($page > 1 && !$favProduct) {
  199 + $result['end'] = true;
  200 + break;
  201 + }
  202 +
  203 + if ($page <= $favProduct['data']['page_total']) {
192 $datas = array(); 204 $datas = array();
193 $product = array(); 205 $product = array();
194 foreach ($favProduct['data']['product_list'] as $val) { 206 foreach ($favProduct['data']['product_list'] as $val) {
@@ -209,11 +221,16 @@ class UserModel @@ -209,11 +221,16 @@ class UserModel
209 221
210 $datas[] = $product; 222 $datas[] = $product;
211 } 223 }
212 - !empty($datas) && $result['hasFavProduct'] = $datas;  
213 - } else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) { 224 +
  225 + if (!empty($datas)) {
  226 + $result['hasFavProduct'] = $datas;
  227 + }
  228 + } else {
214 $result['end'] = true; 229 $result['end'] = true;
215 } 230 }
216 231
  232 + } while (false);
  233 +
217 return $result; 234 return $result;
218 } 235 }
219 236
@@ -234,7 +251,19 @@ class UserModel @@ -234,7 +251,19 @@ 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']) { 254 + do {
  255 + // 开始就没获取到数据或者获取的数据为空时的处理
  256 + if ((!$favBrand || isset($favBrand['data']['total']) && empty($favBrand['data']['total'])) && $page == 1) {
  257 + break;
  258 + }
  259 +
  260 + // 加载第二页以及第二页之后的数据时接口不返回时的处理
  261 + if ($page > 1 && !$favBrand) {
  262 + $result['end'] = true;
  263 + break;
  264 + }
  265 +
  266 + if ($page <= $favBrand['data']['page_total']) {
238 $datas = array(); 267 $datas = array();
239 $brand = array(); 268 $brand = array();
240 foreach ($favBrand['data']['brand_list'] as $val) { 269 foreach ($favBrand['data']['brand_list'] as $val) {
@@ -264,10 +293,14 @@ class UserModel @@ -264,10 +293,14 @@ class UserModel
264 293
265 $datas[] = $brand; 294 $datas[] = $brand;
266 } 295 }
267 - !empty($datas) && $result['hasFavBrand'] = $datas;  
268 - } else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) { 296 +
  297 + if (!empty($datas)) {
  298 + $result['hasFavBrand'] = $datas;
  299 + }
  300 + } else {
269 $result['end'] = true; 301 $result['end'] = true;
270 } 302 }
  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);