Authored by hf

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

... ... @@ -25,6 +25,7 @@ var start = 0,
lazyLoad($('img.lazy'));
$('.nav-btn').on('touchstart', function(event) {
$sideNav.css('pointer-events', 'none');
$mobileWrap.addClass('menu-open');
$overlay.show().css('opacity', 0.3);
$sideNav.addClass('on');
... ... @@ -37,6 +38,11 @@ $('.nav-btn').on('touchstart', function(event) {
height: $(window).height(),
overflow: 'hidden'
});
setTimeout(function() {
$sideNav.css('pointer-events', 'auto');
}, 400);
return false;
});
... ...
... ... @@ -79,8 +79,8 @@ function loadData($parent, url, page) {
page: page
},
success: function(data) {
var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading');
var $loadingMask = $parent.closest('.fav-type').find('.fav-content-loading');
if (url === 'favBrand') {
$brandLoadMore.addClass('hide');
} else {
... ... @@ -91,23 +91,23 @@ function loadData($parent, url, page) {
$loadingMask.addClass('hide');
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
} else if (data === 'end') {
//处理data等于end时如果loadingMask存在且没有hide样式的情况
if ($loadingMask && !$loadingMask.hasClass('hide')) {
//处理data等于end时如果loadingMask存在且没有hide样式的情况
if ($loadingMask && !$loadingMask.hasClass('hide')) {
$loadingMask.addClass('hide');
$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
}
//$parent.closest('.fav-type').find('.fav-null-box').removeClass('hide');
}
$parent.closest('.fav-type').find('.fav-load-background')
.removeClass('fav-load-background').html('没有更多了');
.removeClass('fav-load-background').html('没有更多了');
// hf: fixes bug to 修改没有数据还调接口,加载错误页面问题
brandLockId = true;
lockId = true;
} else if (data.length > 10) {
$parent.append(data);
//如果有数据loadingMask会被remove掉
//如果有数据loadingMask会被remove掉
$loadingMask.remove();
if (url === 'favBrand') {
initSwiper(data);//如果是收藏品牌需要初始化swiper
... ...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>{{staticTitle}}</title>
<!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> -->
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="grey">
<script>
(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);
</script>
</head>
<body>
<div class="main-wrap">
元宵节抽签
</div>
</body>
... ...
<?php
use Action\HuodongAction;
use Plugin\Helpers;
use LibModels\Wap\Cuxiao\ActivityData;
use Api\Yohobuy;
/**
* 元宵抽签活动
*/
class YuanxiaoController extends HuodongAction
{
/**
* 元宵抽签
*/
public function indexAction()
{
$this->_view->display('index', array(
'staticTitle' => '元宵抽签'
));
}
}
... ...
... ... @@ -41,7 +41,7 @@ class HfController extends AbstractAction
* patchv 当前补丁的版本号,没有就传空 string "100"
* filecode md5(md5(文件内容) + "yohopatch2016") string "1233321121212332"
* ]
* echo md5(file_get_contents('http://ad.yoho.cn/test/main.js'));
* echo md5(file_get_contents('http://cdn.yoho.cn/app-hotfix/yohobuy/4.0.0/main.js'));
*/
public function v1Action()
{
... ... @@ -51,16 +51,17 @@ class HfController extends AbstractAction
$version = $this->post('app_version');
switch ($version) {
case '4.0.0': // 版本号
// $result['data']['url'] = 'http://ad.yoho.cn/test/main.js';
// $result['data']['patchv'] = '102';
// $result['data']['filecode'] = md5('bae3f6522d7a53436931799ac10f8a40' . 'yohopatch2016');
// $result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data']));
// break;
$result['data']['url'] = 'http://cdn.yoho.cn/app-hotfix/yohobuy/4.0.0/main.js';
$result['data']['patchv'] = '102';
$result['data']['filecode'] = md5('53b86b14490ead50ff78cac30a2494f3' . 'yohopatch2016');
$result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data']));
break;
default: // 默认
$result['data']['url'] = '';
$result['data']['patchv'] = '';
$result['data']['filecode'] = '';
$result['md5'] = md5(self::PRIVATE_KEY . ':' . json_encode($result['data']));
break;
}
$this->echoJson($result);
... ...
... ... @@ -113,6 +113,11 @@ class SearchController extends AbstractAction
$classNames = Category\ClassModel::getClassNames();
do {
// 品类名称为空时跳出
if (empty($classNames)) {
break;
}
/* 精确查一级品类 */
$sorts = array_keys($classNames['first'], $query, true);
if (isset($sorts[0])) {
... ...
... ... @@ -115,7 +115,7 @@ class UserModel
// 处理个人中心页面优选新品数据
if (!empty($preferenceData['data'])) {
foreach ($preferenceData['data'] as $value) {
$value = Helpers::formatProduct($value, false, true, true, 299, 388, false, false);
$value = Helpers::formatProduct($value, false, true, true, 299, 388, false);
if (false !== $value) {
$result['recommendList'][] = $value;
}
... ... @@ -188,31 +188,48 @@ class UserModel
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && $page <= $favProduct['data']['page_total']) {
$datas = array();
$product = array();
foreach ($favProduct['data']['product_list'] as $val) {
if (empty($val['product_skn'])) {
continue;
}
do {
// 开始就没获取到数据或者获取的数据为空时的处理
if ((!$favProduct || isset($favProduct['data']['product_list']) && empty($favProduct['data']['product_list'])) && $page == 1) {
break;
}
// 加载第二页以及第二页之后的数据时接口不返回时的处理
if ($page > 1 && !$favProduct) {
$result['end'] = true;
break;
}
if ($page <= $favProduct['data']['page_total']) {
$datas = array();
$product = array();
$product['fav_id'] = $val['product_id'];
$product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
$product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
;
$product['title'] = $val['product_name'];
$product['price'] = '¥' . Helpers::transPrice($val['market_price']);
$product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
$product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
$product['sellOut'] = ($val['storage'] <= 0);
$datas[] = $product;
}
!empty($datas) && $result['hasFavProduct'] = $datas;
} else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) {
$result['end'] = true;
}
foreach ($favProduct['data']['product_list'] as $val) {
if (empty($val['product_skn'])) {
continue;
}
$product = array();
$product['fav_id'] = $val['product_id'];
$product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
$product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
;
$product['title'] = $val['product_name'];
$product['price'] = '¥' . Helpers::transPrice($val['market_price']);
$product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
$product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
$product['sellOut'] = ($val['storage'] <= 0);
$datas[] = $product;
}
if (!empty($datas)) {
$result['hasFavProduct'] = $datas;
}
} else {
$result['end'] = true;
}
} while (false);
return $result;
}
... ... @@ -234,40 +251,56 @@ class UserModel
$favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit);
// 处理用户收藏的品牌数据
if (isset($favBrand['data']) && $page <= $favBrand['data']['page_total']) {
$datas = array();
$brand = array();
foreach ($favBrand['data']['brand_list'] as $val) {
$brand = array();
$brand['id'] = $val['brand_id'];
$brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
$brand['brandName'] = $val['brand_name'];
$brand['update'] = $val['new_product_num'];
$brand['discount'] = $val['product_discount_num'];
$brand['link'] = Helpers::url('', array(), $val['brand_domain']);
// 处理品牌产品
$product = array();
foreach ($val['new_product'] as $one) {
if (empty($one['product_skn'])) {
continue;
}
do {
// 开始就没获取到数据或者获取的数据为空时的处理
if ((!$favBrand || isset($favBrand['data']['total']) && empty($favBrand['data']['total'])) && $page == 1) {
break;
}
// 加载第二页以及第二页之后的数据时接口不返回时的处理
if ($page > 1 && !$favBrand) {
$result['end'] = true;
break;
}
if ($page <= $favBrand['data']['page_total']) {
$datas = array();
$brand = array();
foreach ($favBrand['data']['brand_list'] as $val) {
$brand = array();
$brand['id'] = $val['brand_id'];
$brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
$brand['brandName'] = $val['brand_name'];
$brand['update'] = $val['new_product_num'];
$brand['discount'] = $val['product_discount_num'];
$brand['link'] = Helpers::url('', array(), $val['brand_domain']);
// 处理品牌产品
$product = array();
$product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
$product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
$product['price'] = '¥' . Helpers::transPrice($one['market_price']);
$product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
foreach ($val['new_product'] as $one) {
if (empty($one['product_skn'])) {
continue;
}
$product = array();
$product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
$product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
$product['price'] = '¥' . Helpers::transPrice($one['market_price']);
$product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
$brand['productList'][] = $product;
}
$brand['productList'][] = $product;
$datas[] = $brand;
}
$datas[] = $brand;
if (!empty($datas)) {
$result['hasFavBrand'] = $datas;
}
} else {
$result['end'] = true;
}
!empty($datas) && $result['hasFavBrand'] = $datas;
} else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) {
$result['end'] = true;
}
} while (false);
return $result;
}
... ... @@ -331,7 +364,7 @@ class UserModel
$record = array();
$record['product_name'] = $val['product_name'];
$record['product_id'] = $val['product_id'];
$record['product_skn'] = $val['product_skn'];
$record['link'] = Helpers::url('/product/show_' . $val['product_skn'] . '.html');
$record['image'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
$record['sales_price'] = Helpers::transPrice($val['sales_price']);
... ...
... ... @@ -220,7 +220,7 @@ class IndexController extends AbstractAction
$data['goodList'] += $condition;
$data['pageFooter'] = true;
if ($title === '') {
if (empty($title)) {
$title = $domain;
}
$this->setTitle($title);
... ...