Authored by wangqing

合并冲突

<?php
namespace Configs;
/**
* 缓存配置文件
*/
class WebCacheConfig
{
const KEY_WEB_INDEX_BRANDS_LIST_DATA = 'key_web_index_brands_list_data';//频道brands数据
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);
}
... ...
... ... @@ -4,7 +4,7 @@ namespace WebPlugin\DataProcess;
use WebPlugin\Images;
use WebPlugin\Helpers;
use WebPlugin\Cache;
use Configs\CacheConfig;
use Configs\WebCacheConfig;
use LibModels\Web\Product\SearchData;
/**
... ... @@ -488,7 +488,7 @@ class Process
unset($data[$key + 3]);
}
$type_key = sprintf("%s_%s", $type, $key + 2);
$cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $type_key);
Cache::set($cacheKey, $floor, 86400);
$result['preferenceBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
unset($data[$key], $data[$key + 1], $data[$key + 2]);
... ... @@ -869,7 +869,7 @@ class Process
}
$floor['moreBrand'] = 'http://yohobuy.com/brands';
$type_key = sprintf("%s_%s", $type, $key);
$cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $type_key);
Cache::set($cacheKey, $floor, 86400);
$result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
}
... ...
... ... @@ -2,7 +2,8 @@ define("index", ["jquery","handlebars","source-map","index","lazyload","jquery.p
var webYohobuy;
require("js/common");
require("js/header");
require("js/simple-header");
require("js/product/entry");
require("js/home/entry");
require("js/passport/entry");
... ... @@ -10,7 +11,7 @@ require("js/passport/entry");
module.exports = webYohobuy;
});
define("js/common", ["jquery","handlebars","source-map","index"], function(require, exports, module){
define("js/common", ["jquery"], function(require, exports, module){
/**
* 页面公共逻辑和接口
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -18,8 +19,10 @@ define("js/common", ["jquery","handlebars","source-map","index"], function(requi
*/
var $ = require("jquery");
require("js/footer");
var $body = $('body');
require("js/footer");
... ... @@ -109,33 +112,52 @@ function getShoppingKey() {
}
//YAS统计代码
//(function(w, d, s, j, f) {
// var a = d.createElement(s);
// var m = d.getElementsByTagName(s)[0];
//
// w.YohoAcquisitionObject = f;
//
// w[f] = function() {
// w[f].p = arguments;
// };
//
// a.async = 1;
// a.src = j;
// m.parentNode.insertBefore(a, m);
//})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function(w, d, s, j, f) {
var a = d.createElement(s);
var m = d.getElementsByTagName(s)[0];
w.YohoAcquisitionObject = f;
w[f] = function() {
w[f].p = arguments;
};
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function() {
var uid = getUid();
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, '', '');
}
}());
//window.resize在width<1180时适配成990
$(window).on('resize', function() {
var w = $(this).width();
//return top
if (w < 1360) {
$('.return-top').addClass('min');
} else {
$('.return-top').removeClass('min');
}
//body
if (w < 1180) {
$body.addClass('min-screen');
} else {
$body.removeClass('min-screen');
}
}).trigger('resize');
window.cookie = cookie;
window.setCookie = setCookie;
... ... @@ -145,11 +167,6 @@ window.getUser = getUser;
window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
if($('.simple-header').hasClass('simple-header')){
require("js/simple-header");
}else{
require("js/header");
}
});
... ... @@ -315,109 +332,6 @@ actionhomeFootChange();
//暴露给有可能通AJAX改变内容的页面去用
window.rePosReturnTop = rePosReturn;
});
define("js/simple-header", ["jquery"], function(require, exports, module){
var $ = require("jquery");
if ($('.simple-header').size() > 0) {
$('.tool-options').on('mouseenter', function() {
$(this).find('.tool-select').fadeIn();
}).on('mouseleave', function() {
$(this).find('.tool-select').fadeOut();
});
}
/**
* 格式化用户名
* @return {[type]} [description]
*/
function formatUsernName(userName) {
var name,
char,
_num = 0,
_length = 0,
t;
for (t = 0; t < userName.length; t++) {
char = userName.substr(t, 1);
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
_length += 2;
} else {
_length += 1;
}
}
if (_length <= 10) {
name = userName;
} else {
_num = 0;
name = '';
for (t = 0; t < userName.length; t++) {
if (_num < 10) {
char = userName.substr(t, 1);
if (char !== '*') {
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
_num += 2;
} else {
_num += 1;
}
}
name += char;
}
}
if (name.length < userName.length) {
name += '...';
}
}
return name;
}
/**
* 设置简单头部登陆状态
* @return {[type]} [description]
*/
function setLoginStatus(_data) {
var loginHtml,
name;
if (_data && _data.href && _data.href.user) {
name = formatUsernName(_data.href.user);
loginHtml = '<span>Hi~</span><a href="">' +
name + '</a>&nbsp;<a href="' + _data.href.logout + '">[退出]</a>';
} else {
name = formatUsernName(_data.user);
loginHtml = '<span>Hi~</span><a href="">' +
name + '</a>&nbsp;<a href="http://www.yohobuy.com/signin.html">[请登录]</a>' +
'<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>';
}
$('.header-tool li').eq(0).html(loginHtml);
}
/**
* 获取登录信息
* @return {[type]} [description]
*/
function actionLoginInfo() {
$.ajax({
type: 'GET',
url: '/common/getSimpleHeader',
data: {},
success: function(data) {
if (data.code === 200) {
setLoginStatus(data.data);
}
}
});
}
/**
* 初始化函数
* @return {[type]} [description]
*/
function init() {
actionLoginInfo(); //获取登录信息
}
init();
});
define("js/header", ["jquery","handlebars","source-map","index"], function(require, exports, module){
/**
* 头部
... ... @@ -1930,7 +1844,7 @@ function actionLoginInfo() {
* 初始化函数
* @return {[type]} [description]
*/
function init() {
exports.init = function() {
actionNav(); //处理导航
actionTipPic(); //鼠标移入后查询
actionExeTemplate(); //处理模板
... ... @@ -1954,9 +1868,112 @@ function init() {
actionLoginInfo(); //获取登录信息
actionCover(); //初次登录弹框
actionAddKeyWords(); //增加关键字
};
});
define("js/simple-header", ["jquery"], function(require, exports, module){
var $ = require("jquery");
if ($('.simple-header').size() > 0) {
$('.tool-options').on('mouseenter', function() {
$(this).find('.tool-select').fadeIn();
}).on('mouseleave', function() {
$(this).find('.tool-select').fadeOut();
});
}
init();
/**
* 格式化用户名
* @return {[type]} [description]
*/
function formatUsernName(userName) {
var name,
char,
_num = 0,
_length = 0,
t;
for (t = 0; t < userName.length; t++) {
char = userName.substr(t, 1);
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
_length += 2;
} else {
_length += 1;
}
}
if (_length <= 10) {
name = userName;
} else {
_num = 0;
name = '';
for (t = 0; t < userName.length; t++) {
if (_num < 10) {
char = userName.substr(t, 1);
if (char !== '*') {
if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
_num += 2;
} else {
_num += 1;
}
}
name += char;
}
}
if (name.length < userName.length) {
name += '...';
}
}
return name;
}
/**
* 设置简单头部登陆状态
* @return {[type]} [description]
*/
function setLoginStatus(_data) {
var loginHtml,
name;
if (_data && _data.href && _data.href.user) {
name = formatUsernName(_data.href.user);
loginHtml = '<span>Hi~</span><a href="">' +
name + '</a>&nbsp;<a href="' + _data.href.logout + '">[退出]</a>';
} else {
name = formatUsernName(_data.user);
loginHtml = '<span>Hi~</span><a href="">' +
name + '</a>&nbsp;<a href="http://www.yohobuy.com/signin.html">[请登录]</a>' +
'<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>';
}
$('.header-tool li').eq(0).html(loginHtml);
}
/**
* 获取登录信息
* @return {[type]} [description]
*/
function actionLoginInfo() {
$.ajax({
type: 'GET',
url: '/common/getSimpleHeader',
data: {},
success: function(data) {
if (data.code === 200) {
setLoginStatus(data.data);
}
}
});
}
/**
* 初始化函数
* @return {[type]} [description]
*/
exports.init = function() {
actionLoginInfo(); //获取登录信息
};
});
define("js/product/entry", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
/**
... ... @@ -2535,11 +2552,6 @@ exports.init = function(num) {
wrapperPt, //鼠标移入时弹层的上内边距
containerPt; //商品列表容器的上内边距
// 获取图片之前,先把获取上一张图片的ajax请求取消。 网络差的时候会出现错误
// if (getProductAjax && getProductAjax.readyState!= 4) {
// getProductAjax.abort();
// }
$.ajax({
type: 'POST',
url: '/product/list/getProductPic',
... ... @@ -2614,11 +2626,6 @@ $(document).on('hover', '.good-select-color li', function() {
$goodInfoMain.on('click', '.col-btn', function() {
var $this = $(this);
if (!window.getUid()) {
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
return;
}
$.ajax({
type: 'POST',
url: '/product/list/changeFavorite',
... ... @@ -2629,17 +2636,28 @@ $goodInfoMain.on('click', '.col-btn', function() {
}).then(function(res) {
if (res.code === 200) {
$this.toggleClass('coled');
} else if (res.code === 403) {
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
}
});
});
// 左侧导航
$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');
});
... ... @@ -2760,40 +2778,37 @@ module.exports = function($o, rowWidth) {
};
});
define("js/product/brand", ["jquery"], function(require, exports, module){
/**
* 品牌页面
* @auhtor: bikai<kai.bi@yoho.cn>
* @date: 2016/1/21
*/
var $ = require("jquery");
$('#brand-favor').on('click', function() {
var $this = $(this),
uid = window.getUid();
if (!uid) {
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
return;
}
$.ajax({
type: 'post',
url: '/product/index/favoriteBrand',
data: {
uid: uid,
brandId: $this.data('id')
}
}).then(function(res) {
if (res.code === 200) {
if (res.message === 'add') {
$this.find('i').addClass('coled');
} else {
$this.find('i').removeClass('coled');
}
}
});
});
/**
* 品牌页面
* @auhtor: bikai<kai.bi@yoho.cn>
* @date: 2016/1/21
*/
var $ = require("jquery");
$('#brand-favor').on('click', function() {
var $this = $(this),
uid = window.getUid();
$.ajax({
type: 'post',
url: '/product/index/favoriteBrand',
data: {
uid: uid,
brandId: $this.data('id')
}
}).then(function(res) {
if (res.code === 200) {
if (res.message === 'add') {
$this.find('i').addClass('coled');
} else {
$this.find('i').removeClass('coled');
}
} else if (res.code === 403) {
location.href = '/signin.html?refer=' + encodeURIComponent(location.href);
}
});
});
});
define("js/product/hotrank", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
... ... @@ -4741,8 +4756,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')) {
... ... @@ -4809,6 +4824,7 @@ function validateRule(page, $element, callback) {
} else {
validateResult[2].message = '短信验证码错误';
validateResult[2].status = false;
callback();
}
}
... ... @@ -4822,8 +4838,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 {
... ... @@ -4963,10 +4979,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');
}
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -179,18 +179,19 @@ $account.on('keyup', function() {
//数字邮箱补全
postfix = mailPostfix.num;
matchStr = accountMatch[1];
} else {
postfix = mailPostfix.other;
matchStr = account.match(/@(.*)/)[1];
}
matchStr = accountMatch[1];
for (i = 0; i < postfix.length; i++) {
if (postfix[i].indexOf(matchStr) > -1) {
html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + postfix[i] + '</li>';
}
}
if (html !== '') {
if (html !== '' && /.com$/.test(account) === false) {
$emailAutoComplete.html(html).removeClass('hide');
} else {
... ... @@ -283,7 +284,7 @@ $('#login-btn').on('click', function() {
location.href = data.data.session;
}
} else {
$passwordTip.removeClass('hide').children('em').text(data.message);
$passwordTip.removeClass('hide').children('em').html(data.message);
$password.addClass('error');
}
},
... ...
... ... @@ -169,6 +169,11 @@ $tip: sprite-map("passport/tip/*.png", $spacing: 10px);
background: sprite($tip, error) no-repeat;
margin-right: 5px;
}
a {
text-decoration: underline;
color: f00;
}
}
/*完善信息提示框*/
... ...
... ... @@ -9,6 +9,7 @@
}
.goods {
min-width: 984px;
height: 241px;
margin: 30px 0;
overflow: hidden;
... ... @@ -48,17 +49,10 @@
}
}
@media (min-width: 1180px) {
.latest-walk {
.goods {
min-width: 984px;
}
}
}
.min-screen .latest-walk {
.goods {
width: 820px;
min-width: 820px;
height: 301px;
}
... ...
... ... @@ -3,7 +3,7 @@ use Action\WebAction;
use Index\HomeModel;
use LibModels\Web\Home\IndexData;
use WebPlugin\Cache;
use Configs\CacheConfig;
use Configs\WebCacheConfig;
use Api\Yohobuy;
use WebPlugin\Images;
use WebPlugin\Helpers;
... ... @@ -20,7 +20,7 @@ class CommonController extends WebAction
$type = $this->get('type');
$data = array();
if (! empty($type)) {
$key = CacheConfig::KEY_INDEX_BRANDS_LIST_DATA . '_' . $type;
$key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
// array('logoBrand'=>'','moreBrand'=>'')
$data = Cache::get($key);
}
... ...
<?php
use Action\WebAction;
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);
}
}
\ No newline at end of file
}
... ...
<?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);
}
}
\ No newline at end of file
}
... ...
<?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
use Action\WebAction;
use WebPlugin\Cache;
use Configs\CacheConfig;
use Configs\WebCacheConfig;
use WebPlugin\AuthCode;
use Index\HomeModel;
class ToolsController extends WebAction
... ... @@ -32,11 +32,11 @@ class ToolsController extends WebAction
{
//频道=>key
$channels = array(
'导航' => CacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
'导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
);
$html = '';
foreach ($channels as $key => $val) {
... ... @@ -58,7 +58,7 @@ class ToolsController extends WebAction
$key = AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
//导航清除
if($key == CacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
$list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
foreach ($list as $val) {
Cache::delete($key.'_'.$val);
... ...
<?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'], // 父级
... ... @@ -82,7 +83,7 @@ class HomeModel
'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;
... ... @@ -242,7 +247,7 @@ class HomeModel
public static function getNewArrival($channel)
{
$result = array();
$key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
$key = sprintf(WebCacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
//缓存数据
$result = Cache::get($key);
if(empty($result)) {
... ...