Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

<?php
namespace Configs;
/**
* 缓存配置文件
*/
class WebCacheConfig
{
const KEY_WEB_HOME_NAVBAR_DATA = 'key_web_home_navbar_data';//web的导航数据
const KEY_WEB_HOME_CHANNEL_DATA = 'key_web_home_channel_data';//web首页频道数据[boys, girls, kids, lifestyle]
const KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA = 'key_web_home_newarrival_data';//web频道最新上架数据[boys, girls, kids, lifestyle]
const KEY_WEB_PRODUCT_SEARCH_DATA = 'key_web_product_search_data'; // web搜索的数据
}
... ...
... ... @@ -19,8 +19,11 @@ class IndexData
*/
public static function getNavData($status = 1, $fields = 'id,sort_name,sort_name_en,parent_id,sort_url,sort_ico,content_code,is_new,is_hot,separative_sign')
{
$params = array('parent_id'=>'','platform'=>'web',
'status'=> $status,'fields'=> $fields
$params = array(
'parent_id'=>'',
'platform'=>'web',
'status'=> $status,
'fields'=> $fields
);
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params);
}
... ...
<script>
seajs.use('js/common');
</script>
{{!-- 正常头部 --}}
{{#headerdata}}
<script>
seajs.use('js/header',function(header){
header.init();
});
</script>
{{/headerdata}}
{{!-- 简单头部 --}}
{{#simpleHeader}}
<script>
seajs.use('js/simple-header',function(simpleheader){
simpleheader.init();
});
</script>
{{/simpleHeader}}
{{!-- 首页 --}}
{{#if boysHomePage}}
<script>
... ...
var webYohobuy;
require('./js/common');
require('./js/header');
require('./js/simple-header');
require('./js/product/entry');
require('./js/home/entry');
require('./js/passport/entry');
... ...
... ... @@ -5,11 +5,13 @@
*/
var $ = require('yoho.jquery');
var $body = $('body');
require('./footer');
function cookie(name) {
var cookies = document.cookie,
cookieVal,
... ... @@ -116,7 +118,7 @@ function getShoppingKey() {
uid = uid === 0 ? '' : uid;
window._ozuid = uid;//暴露ozuid
window._ozuid = uid; //暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
... ... @@ -151,3 +153,4 @@ window.getUser = getUser;
window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
... ...
... ... @@ -1509,7 +1509,7 @@ function actionLoginInfo() {
* 初始化函数
* @return {[type]} [description]
*/
function init() {
exports.init = function() {
actionNav(); //处理导航
actionTipPic(); //鼠标移入后查询
actionExeTemplate(); //处理模板
... ... @@ -1533,6 +1533,5 @@ function init() {
actionLoginInfo(); //获取登录信息
actionCover(); //初次登录弹框
actionAddKeyWords(); //增加关键字
}
};
init();
\ No newline at end of file
... ...
... ... @@ -198,8 +198,8 @@ function msgCaptchaAjaxFn(page, callback) {
function validateRule(page, $element, callback) {
var val = $.trim($element.val()),
regionCode;
regionCode,
pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;
//手机号校验
if ($element.hasClass('phone-num')) {
... ... @@ -266,6 +266,7 @@ function validateRule(page, $element, callback) {
} else {
validateResult[2].message = '短信验证码错误';
validateResult[2].status = false;
callback();
}
}
... ... @@ -279,8 +280,8 @@ function validateRule(page, $element, callback) {
validateResult[3].message = '密码只支持6-20位字符';
validateResult[3].status = false;
} else if (/\s/.test($element.val())) {
validateResult[3].message = '密码不能包含空格';
} else if (!pwdReg.test($element.val())) {
validateResult[3].message = '密码只能包含字母,数字,半角标点符号';
validateResult[3].status = false;
} else {
... ... @@ -420,10 +421,8 @@ exports.init = function(page) {
$('#agree-terms').click(function() {
if ($(this).attr('notchecked')) {
console.log(1);
$(this).removeAttr('notchecked');
} else {
console.log(2);
$(this).attr('notchecked', 'true');
}
... ...
... ... @@ -186,11 +186,20 @@ $goodInfoMain.on('click', '.col-btn', function() {
});
// 左侧导航
$productListNav.click(function() {
$productListNav.click(function(event) {
if (!$(event.target).hasClass('product-list-nav')) {
return;
}
if ($(this).hasClass('active')) {
$(this).find('.sort-child-list').stop(true, true).slideUp();
} else {
$(this).find('.sort-child-list').stop(true, true).slideDown();
}
$(this).toggleClass('active');
});
... ...
... ... @@ -94,8 +94,7 @@ function actionLoginInfo() {
* 初始化函数
* @return {[type]} [description]
*/
function init() {
exports.init = function() {
actionLoginInfo(); //获取登录信息
}
};
init();
\ No newline at end of file
... ...
... ... @@ -39,7 +39,7 @@
.good-detail-text {
color: #222;
font-size: 12px;
text-align: center;
text-align: left;
overflow: hidden;
> a {
... ...
... ... @@ -9,7 +9,7 @@
}
.goods {
width: 984px;
min-width: 984px;
height: 241px;
margin: 30px 0;
overflow: hidden;
... ... @@ -52,6 +52,7 @@
.min-screen .latest-walk {
.goods {
width: 820px;
min-width: 820px;
height: 301px;
}
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
/**
* 女
* 女生首页
*/
class GirlsController extends WebAction
{
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置浏览器缓存1分钟
$this->setExpires(60);
// 设置网站SEO信息
$this->setTitle('女生|时尚潮流女装,日韩女装,潮牌女装全球购|YOHO!BUY有货 100%正品保证', false);
$this->setKeywords('女生服饰,时尚潮流女装,日韩女装,女装正品购物网站,女装全球购');
$this->setDescription('YOHO!BUY有货官网女生频道汇集了全球女装潮流时尚,提供时尚潮流女装,日版女装,韩版女装,潮牌女装正品全球购。YOHO!BUY有货购物100%正品保证,支持货到付款。');
// 传递模板数据,渲染模板
$this->setWebNavHeader(HomeModel::COOKIE_NAME_GIRLS);
$data = array(
'boysHomePage' => true,
'footerTop'=> true,
'footerTop' => true,
'girls' => HomeModel::getChannelResource(HomeModel::COOKIE_NAME_GIRLS, HomeModel::CODE_GIRLS_CHANNEL)
);
$this->_view->display('index', $data);
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
/**
* 默认控制器
... ... @@ -15,7 +16,7 @@ class IndexController extends WebAction
{
if (null !== $this->get('go')) {
// 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
\Index\HomeModel::goSwitchChannel();
HomeModel::goSwitchChannel();
} else {
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
... ... @@ -23,11 +24,12 @@ class IndexController extends WebAction
$this->setExpires(60);
}
$this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_BOYS);
// 传递模板数据,渲染模板
$this->setWebNavHeader(HomeModel::COOKIE_NAME_BOYS);
$data = array(
'boysHomePage' => true,
'footerTop'=> true,
'boys' => \Index\HomeModel::getChannelResource(\Index\HomeModel::COOKIE_NAME_BOYS, \Index\HomeModel::CODE_BOYS_CHANNEL)
'boys' => HomeModel::getChannelResource(HomeModel::COOKIE_NAME_BOYS, HomeModel::CODE_BOYS_CHANNEL)
);
$this->_view->display('index', $data);
}
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
... ... @@ -10,15 +11,23 @@ class KidsController extends WebAction
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置浏览器缓存1分钟
$this->setExpires(60);
// 设置网站SEO信息
$this->setTitle('潮童|男童装,女童装,韩版童装,儿童服装服饰|YOHO!BUY有货 100%正品保证', false);
$this->setKeywords('潮童,男童装,女童装,韩版童装,儿童服装服饰');
$this->setDescription('YOHO!BUY有货官网潮童频道汇集了全球潮童潮流时尚,提供新款男童装,女童装,韩版童装,儿童服装服饰正品全球购。YOHO!BUY有货购物100%正品保证,支持货到付款。');
$this->setWebNavHeader(HomeModel::COOKIE_NAME_KIDS);
$data = array(
'boysHomePage' => true,
'footerTop'=> true,
'footerTop' => true,
'kids' => HomeModel::getChannelResource(HomeModel::COOKIE_NAME_KIDS, HomeModel::CODE_KIDS_CHANNEL)
);
$this->_view->display('index', $data);
}
}
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
... ... @@ -10,15 +11,24 @@ class LifestyleController extends WebAction
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置浏览器缓存1分钟
$this->setExpires(60);
// 设置网站的SEO信息
$this->setTitle('创意生活|创意生活馆,潮流创意家居,家居生活用品|YOHO!BUY有货 100%正品保证', false);
$this->setKeywords('创意生活,创意生活馆,潮流家居,潮流创意家居,家居生活用品,YOHO!有货');
$this->setDescription('YOHO!BUY有货官网创意生活频道汇集了创意生活馆,潮流创意家居,家居生活用品等正品网购,给您的生活带来更多创意。YOHO!BUY有货购物100%正品保证,支持货到付款。');
// 传递模板数据,渲染模板
$this->setWebNavHeader(HomeModel::COOKIE_NAME_LIFESTYLE);
$data = array(
'boysHomePage' => true,
'footerTop'=> true,
'footerTop' => true,
'lifestyle' => HomeModel::getChannelResource(HomeModel::COOKIE_NAME_LIFESTYLE, HomeModel::CODE_LIFESTYLE_CHANNEL)
);
$this->_view->display('index', $data);
}
}
... ...
<?php
namespace Index;
use Configs\CacheConfig;
use Configs\WebCacheConfig;
use Configs\ChannelConfig;
use WebPlugin\Helpers;
use WebPlugin\Cache;
... ... @@ -58,17 +58,18 @@ class HomeModel
*/
public static function getNavBars($channel = 'boys')
{
$menu = array();
$key = CacheConfig::KEY_WEB_HOME_NAVBAR_DATA.'_'.$channel;
$key = WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA . '_' . $channel;
$menu = Cache::get($key);
$data = array();
if(empty($menu)) {//数据缓存不存在
//数据缓存不存在
if(empty($menu)) {
$data = IndexData::getNavData();
//接口存在数据
if(!empty($data['data'])) {
$item = array();
$index_main = 0;
$subnav = array();
$thirdnav = array();
$indexMain = 0;
$indexSub = 0;
foreach ($data['data'] as $val) {
$item = array(
'name_cn' => $val['sort_name'], // 父级
... ... @@ -76,13 +77,13 @@ class HomeModel
'link' => $val['sort_url'],
'icon' => $val['sort_ico'],
'classname' => str_replace(' ', '', strtolower($val['sort_name_en'])) == $channel ? $channel : '',
'index_main' => $index_main ++,
'index_main' => $indexMain ++,
'content_code' => $val['content_code'],
'is_hot' => $val['is_hot'] == 'Y' ? true : false,
'is_new' => $val['is_new'] == 'Y' ? true : false,
// 'subnav' => array()
);
$index_sub = 0;
$indexSub = 0;
foreach ($val['sub'] as $sub) { // 二级
$subnav = array(
'name' => $sub['sort_name'],
... ... @@ -92,9 +93,10 @@ class HomeModel
'is_new' => $sub['is_new'] == 'Y' ? true : false,
'content_code' => $sub['content_code'],
// 'thirdnav' => array(),
'index_sub' => $index_sub ++
'index_sub' => $indexSub ++
);
if (isset($sub['sub'])) {
$thirdnav = array();
foreach ($sub['sub'] as $thirdsub) { // 三级
$thirdnav = array(
'title' => $thirdsub['sort_name'],
... ... @@ -123,8 +125,9 @@ class HomeModel
Cache::set($key, $menu, 3600);
}
}
//数据缓存和接口都空的,取二级数据
if(empty($menu) && empty($data)) {
if(empty($menu)) {
$menu = Cache::get($key,'slave');
}
... ... @@ -176,25 +179,27 @@ class HomeModel
/**
* 获取频道资源
*
* @param string $channel
* @param string $content_code
* @param string $channel 频道标识(boys,girls,kids,lifestyle)
* @param string $contentCode 资源码
* @return array
*/
public static function getChannelResource($channel, $content_code)
public static function getChannelResource($channel, $contentCode)
{
$key = CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.$content_code;
$key = WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA . '_' . $contentCode;
$data = Cache::get($key);
$resource = array();
if(empty($data)) {
$resource = IndexData::getResourceData($content_code);
if(isset($resource['data']) && !empty($resource['data']) && $resource['code'] == 200) {
$resource = IndexData::getResourceData($contentCode);
if (isset($resource['data']) && !empty($resource['data']) && $resource['code'] == 200) {
//格式化数据
$data = ChannelProcess::getFormat($channel, $resource['data']);
Cache::set($key, $data, 3600);//设置master,slave
//设置master,slave
Cache::set($key, $data, 3600);
//清空变量
$resource = array();
}
}
//master没有数据,资源位没有数据, 取二层缓存
if(empty($data) && (empty($resource) || !isset($resource['data']))) {
if(empty($data)) {
$data = Cache::get($key, 'slave');
}
return $data;
... ...