Authored by hf

Merge branch 'develop' into test

... ... @@ -100,6 +100,18 @@ class AbstractAction extends Controller_Abstract
{
return $this->_request->getParam($key, $default);
}
/**
* 封装一下获取服务器的参数
*
* @param String $key
* @param mixed $default
* @return mixed
*/
protected function server($key, $default = null)
{
return $this->_request->getServer($key, $default);
}
/**
* 关闭模板自动渲染
... ...
<?php
namespace LibModels\Wap\Category;
use Api\Yohobuy;
... ... @@ -15,26 +16,28 @@ use Api\Sign;
*/
class FocusData
{
/**
* 获取关注数据
*
* @param integ $uid 用户ID
* @param string $gender 性别
* @param integer $limit 读取数目限制,默认为10
* @param integer $page 读取分页限制,默认为1
* @return array 关注数据
*/
/**
* 获取关注数据
*
* @param integ $uid 用户ID
* @param string $gender 性别
* @param integer $limit 读取数目限制,默认为10
* @param integer $page 读取分页限制,默认为1
* @return array 关注数据
*/
public static function getFocusData($uid, $gender, $limit = 10, $page = 1)
{
// 构建必传参数
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['limit'] = $limit;
$param['page'] = $page;
// 构建必传参数
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['limit'] = $limit;
$param['page'] = $page;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL.'guang/api/v1/attention/getlist', $param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'guang/api/v1/attention/getlist', $param);
}
}
... ...
... ... @@ -58,7 +58,7 @@ class PlusstarData
$build['client_secret'] = Sign::getSign($build);
$urlList['all'] = Yohobuy::httpBuildQuery($url, $build);
return Yohobuy::getMulti($urlList);
return Yohobuy::getMulti($urlList, array(), 1800); // 缓存30分钟
}
/**
... ... @@ -96,7 +96,7 @@ class PlusstarData
$original['client_secret'] = Sign::getSign($original);
$urlList['original'] = Yohobuy::httpBuildQuery($url, $original);
return Yohobuy::getMulti($urlList);
return Yohobuy::getMulti($urlList, array(), 1800); // 缓存30分钟
}
/**
... ...
... ... @@ -33,7 +33,7 @@ class BrandData
$param['type'] = 'brand';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param, true);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
... ... @@ -52,7 +52,7 @@ class BrandData
$param['type'] = 'brand';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param, true);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
... ...
<?php
namespace Plugin\DataProcess;
use Plugin\Helpers;
/**
... ... @@ -19,8 +20,7 @@ class ListProcess
{
$result = array();
if(isset($data['product_list']))
{
if (isset($data['product_list'])) {
$result['new'] = self::getProductData($data['product_list']);
}
if ($returnFilter && isset($data['filter'])) {
... ... @@ -28,7 +28,6 @@ class ListProcess
}
return $result;
}
/**
... ... @@ -47,7 +46,6 @@ class ListProcess
}
return $products;
}
/**
... ... @@ -60,23 +58,21 @@ class ListProcess
public static function getFilterData($data, $gender = '1,2,3')
{
// 过滤条件数据
$filters = array('classify'=>array());
$filters = array('classify' => array());
// 返回数据中有没有gender时要添加gender
// $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
$num = 1;
foreach ($data as $key => $val) {
if(empty($val))
{
if (empty($val)) {
continue;
}
if (!is_callable("self::$key")) {
continue;
}
$build = self::$key($val, $gender);
if($num === 1)
{
if ($num === 1) {
$build['active'] = true;
}
... ... @@ -88,7 +84,6 @@ class ListProcess
self::sortArrByField($filters['classify'], 'sort_col');
return $filters;
}
private static function brand($data)
... ... @@ -167,7 +162,7 @@ class ListProcess
foreach ($data as $key => $one) {
$discount = array();
$discount['dataId'] = $key;
$discount['name'] = $one['name'] .'折商品';
$discount['name'] = $one['name'] . '折商品';
$result['subs'][] = $discount;
}
... ... @@ -200,7 +195,9 @@ class ListProcess
// 处理选中状态
foreach ($result['subs'] as &$val) {
$val['dataId'] === $gender && $val['chosed'] = true;
if ($val['dataId'] === $gender) {
$val['chosed'] = true;
}
}
return $result;
... ... @@ -222,23 +219,24 @@ class ListProcess
)
);
$category = array();
foreach ($data as $one) {
$category = array();
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
$category['name'] = $one['category_name'];
/*// 子品类(目前h5不支持二级)
if(isset($one['sub']))
{
$category['subs'] = array();
foreach ($one['sub'] as $single) {
$subitem = array();
$subitem['dataId'] = $single['category_id'];
$subitem['name'] = $single['category_name'];
/* // 子品类(目前h5不支持二级)
if(isset($one['sub']))
{
$category['subs'] = array();
foreach ($one['sub'] as $single) {
$subitem = array();
$subitem['dataId'] = $single['category_id'];
$subitem['name'] = $single['category_name'];
$category['subs'][] = $subitem;
}
}*/
$category['subs'][] = $subitem;
}
} */
$result['subs'][] = $category;
}
... ... @@ -262,8 +260,9 @@ class ListProcess
)
);
$price = array();
foreach ($data as $key => $one) {
$price = array();
$price['dataId'] = $key;
$price['name'] = $one;
... ... @@ -289,9 +288,10 @@ class ListProcess
)
);
$size = array();
foreach ($data as $one) {
$size = array();
$size['dataId'] = $one['size_id'];
$size['dataId'] = $one['size_id'];
$size['name'] = $one['size_name'];
$result['subs'][] = $size;
... ... @@ -307,7 +307,8 @@ class ListProcess
* @param string $field 字段名称
* @param boolean $desc 时候降序排列,默认为false
*/
private static function sortArrByField(&$array, $field, $desc = false){
private static function sortArrByField(&$array, $field, $desc = false)
{
$fieldArr = array();
foreach ($array as $k => $v) {
$fieldArr[$k] = $v[$field];
... ... @@ -315,4 +316,5 @@ class ListProcess
$sort = $desc == false ? SORT_ASC : SORT_DESC;
array_multisort($fieldArr, $sort, $array);
}
}
... ...
... ... @@ -33,7 +33,7 @@ class Helpers
$url = 'http://search' . SUB_DOMAIN;
break;
case 'index': // 默认
$url = '';
$url = SITE_MAIN;
break;
default: // 其它子域名
$url = 'http://' . $module . SUB_DOMAIN;
... ... @@ -201,7 +201,7 @@ class Helpers
$result['product_id'] = $productData['product_id'];
$result['thumb'] = Images::getImageUrl($productData['default_images'], $width, $height);
$result['name'] = $productData['product_name'];
$result['price'] = $productData['market_price'] . '.00';
$result['price'] = empty($productData['market_price']) ? false : $productData['market_price'] . '.00';
$result['salePrice'] = $productData['sales_price'] . '.00';
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_'
... ...
... ... @@ -7,8 +7,6 @@ var $ = require('jquery');
var $footer = $('#yoho-footer');
var FOOTERHEIGHT = 120; //footer height
function cookie(name) {
var cookies = document.cookie,
cookieVal,
... ... @@ -100,7 +98,7 @@ function rePosFooter() {
return;
}
if ($('body').height() < $(window).height() - FOOTERHEIGHT) {
if ($('body').height() <= $(window).height()) {
$footer.addClass('bottom');
} else {
$footer.removeClass('bottom');
... ... @@ -113,7 +111,7 @@ function rePosFooter() {
var user = getUser();
if ($('body').height() < $(window).height() - FOOTERHEIGHT) {
if ($('body').height() <= $(window).height()) {
$footer.addClass('bottom');
}
... ...
... ... @@ -8,7 +8,7 @@ var $searchBox = $('.search-box'),
$indexSearch = $('.index-search'),
$indexLogo = $('.index-logo');
$searchBox.find('input').on('focus', function() {
function showBigSearch() {
$indexLogo.css({
width: 0
});
... ... @@ -19,7 +19,9 @@ $searchBox.find('input').on('focus', function() {
width: '15.5rem'
});
$('.clear-text, .no-search').show();
}).on('blur', function() {
}
function hideBigSearch() {
$indexLogo.css({
width: '5.4rem'
});
... ... @@ -30,12 +32,22 @@ $searchBox.find('input').on('focus', function() {
width: '9.6rem'
});
$('.clear-text, .no-search').hide();
}
$searchBox.find('input').on('focus', function() {
showBigSearch();
});
$searchBox.find('.clear-text').click(function() {
$searchBox.find('input').val('').trigger('focus');
$searchBox.find('.clear-text').on('touchend', function() {
$searchBox.find('input').val('');
});
$searchBox.find('.search-icon').click(function() {
$searchBox.find('.search-icon').on('touchend', function() {
$indexSearch.submit();
});
$('.no-search').on('touchend', function() {
$searchBox.find('input').val('');
hideBigSearch();
});
window.rePosFooter();
... ...
... ... @@ -108,7 +108,7 @@
padding: 0 20rem / $pxConvertRem;
a {
display: block;
padding-top: 10rem / $pxConvertRem;
// padding-top: 10rem / $pxConvertRem;
height: 76rem / $pxConvertRem;
line-height: 76rem / $pxConvertRem;
font-size: 28rem / $pxConvertRem;
... ... @@ -116,13 +116,14 @@
border-top: 1px solid #f9f9f9;
i {
display: inline-block;
margin-top: -4rem / $pxConvertRem;
margin-left: 24rem / $pxConvertRem;
width: 58rem / $pxConvertRem;
height: 38rem / $pxConvertRem;
text-align: center;
vertical-align: middle;
font-size: 18rem / $pxConvertRem;
line-height: 39rem / $pxConvertRem;
line-height: 38rem / $pxConvertRem;
color: #fff;
border-radius: 50rem / $pxConvertRem;;
}
... ...
... ... @@ -4,12 +4,12 @@
position: fixed;
top: 0;
bottom: 0;
// left: 0;
left: -540rem / $pxConvertRem;
right: 640rem / $pxConvertRem;
width: 540rem / $pxConvertRem;
z-index: -1;
overflow: hidden;
@include transition(right .3s);
@include transition(all .3s);
ul {
background: #f0f0f0;
... ... @@ -107,6 +107,7 @@
}
.side-nav.on {
left: 0;
right: 100rem / $pxConvertRem;
z-index: 3;
}
... ...
... ... @@ -24,7 +24,8 @@
width: 384rem / $pxConvertRem;
height: 112rem / $pxConvertRem;
overflow: hidden;
transition: width 400ms;
z-index: 3;
@include transition(width .4s);
.search-box {
float: left;
position: relative;
... ... @@ -96,10 +97,10 @@
min-height: 800rem / $pxConvertRem;
.index-channel-list {
padding-top: 50%;
margin-top: -50%;
width: 100%;
position: absolute;
top: -180rem / $pxConvertRem;
top: 50%;
.list-item {
display: block;
... ... @@ -114,6 +115,9 @@
background: #000;
border: 4px solid #fff;
font-weight: bold;
&:last-child {
margin-bottom: 0;
}
}
.lighter {
font-weight: lighter;
... ...
... ... @@ -19,7 +19,7 @@ class HomeController extends AbstractAction
public function indexAction()
{
// 目前跳到老站
$this->go(OLD_MAIN . '/home');
// $this->go(OLD_MAIN . '/home');
}
}
... ...
... ... @@ -123,7 +123,9 @@ class BrandModel
$list = array();
$build = array();
foreach ($brand['data']['brands'] as $char => $value) {
$build = array();
foreach ($value as $row) {
$list = array();
$list['name'] = $row['brand_name'];
$list['isHot'] = ($row['is_hot'] === 'Y') ? true : false;
$list['isNew'] = ($row['is_show_new'] === 'Y') ? true : false;
... ...
... ... @@ -160,7 +160,7 @@ class HomeModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($cache, $result);
Cache::set($cache, $result);
}
}
... ...
... ... @@ -59,7 +59,7 @@ class SideModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_COMMON_SIDE_NAV, $result, 3600); // 缓存1小时
Cache::set(CacheConfig::KEY_COMMON_SIDE_NAV, $result);
}
}
... ...
... ... @@ -57,7 +57,7 @@ class ListModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 600); // 缓存10分钟
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
... ... @@ -140,7 +140,7 @@ class ListModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 600); // 缓存10分钟
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
... ... @@ -186,7 +186,7 @@ class ListModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 10800); // 缓存3小时
Cache::set($key, $result); // 缓存1小时
}
}
... ...
... ... @@ -16,6 +16,6 @@ class IndexController extends AbstractAction
public function indexAction()
{
// 跳转到老版
$this->go(OLD_MAIN . '/cart/index/index');
// $this->go(OLD_MAIN . '/cart/index/index');
}
}
... ...
... ... @@ -2,6 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Product\BrandData;
use Plugin\Helpers;
/**
* 商品操作相关的控制器
... ... @@ -56,6 +57,11 @@ class OptController extends AbstractAction
}
while (false);
if (isset($result['code']) && $result['code'] == 412) {
$referer = $this->server('HTTP_REFERER', SITE_MAIN);
$result['data'] = Helpers::url('/signin.html', array('refer' => $referer));
}
$this->echoJson($result);
}
... ...
... ... @@ -36,11 +36,11 @@ class RecomController extends AbstractAction
$gender = $this->get('gender', '1,3');
// 女
if ($gender === '2,3') {
$recom = RecomData::mayLike('2,3', 2);
$recom = RecomData::mayLike('2,3', 2, $page);
}
// 男
else {
$recom = RecomData::mayLike('1,3', 1);
$recom = RecomData::mayLike('1,3', 1, $page);
}
/* 判断是否有内容返回 */
... ... @@ -58,10 +58,13 @@ class RecomController extends AbstractAction
foreach ($recom['data']['product_list'] as $value) {
$data['goods'][] = Helpers::formatProduct($value, true, true, true, 276, 366);
}
$this->_view->display('maylike', $data);
} while (false);
echo ' ';
if (isset($data)) {
$this->_view->display('maylike', $data);
} else {
echo ' ';
}
}
/**
... ... @@ -100,11 +103,13 @@ class RecomController extends AbstractAction
foreach ($recom['data']['product_list'] as $value) {
$data['goods'][] = Helpers::formatProduct($value, true);
}
$this->_view->display('maylike', $data);
} while (false);
echo ' ';
if (isset($data)) {
$this->_view->display('maylike', $data);
} else {
echo ' ';
}
}
/**
... ... @@ -119,23 +124,22 @@ class RecomController extends AbstractAction
if (!$this->isAjax()) {
break;
}
/* 创意生活只有一页数据 */
$page = $this->get('page', 1);
if (intval($page) > 1) {
break;
}
}
/* 取可能喜欢的数据 */
$recom = RecomData::mayLikeLifestyle();
/* 构建人气单品数据 */
if (empty($recom['top']['data']['product_list'])) {
break;
}
$data = array();
$build = array();
$build['show'] = true;
foreach ($recom['top']['data']['product_list'] as $value) {
... ... @@ -177,47 +181,13 @@ class RecomController extends AbstractAction
// }
// $data['goodsContainer'][] = $build;
// }
$this->_view->display('maylikelife', $data);
} while (false);
echo ' ';
if (isset($data)) {
$this->_view->display('maylikelife', $data);
} else {
echo ' ';
}
}
// /**
// * 你可能喜欢的
// *
// * 备注:
// * 调用位于男生(BOYS),女生(GIRLS),潮童(KIDS),创意生活(LifeStyle)页面的底部.
// * 调用方式为AJAX,需要用JS遍历该数据集,替换图片URL地址中的{width},{height},{mode}.
// * JS替换示例: str.replace("{width}", 300).replace("{height}", 300).replace("{mode}", 2);
// *
// * @param string gender "1,3"表示男, "2,3"表示女, 当channel为3时该参数可不传
// * @param string channel 1表示男, 2表示女, 3表示潮童
// * @return json
// */
// public function maylikeAction()
// {
// if ($this->isAjax()) {
// $data = '';
// $gender = $this->get('gender', '1,3');
// $channel = $this->get('channel', '1');
//
// switch (strval($channel)) {
// case '1': // 男(Boys)
// case '2': // 女(Girls)
// $data = RecomData::mayLike($gender, $channel);
// break;
// case '3': // 潮童(Kids)
// $data = RecomData::mayLikeKids();
// break;
// case '4': // 创意生活(LifeStyle)
// $data = RecomData::mayLikeLifestyle();
// break;
// }
//
// $this->echoJson($data);
// }
// }
}
... ...