Authored by yyq

h1

... ... @@ -84,7 +84,7 @@ const category = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
return Promise.all([
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
req.ctx(aboutModel).getCategoryDataWithCache(channel)
]).then(result => {
res.render('category', Object.assign(result[1], responseData, result[0]));
... ... @@ -98,7 +98,7 @@ const chanpin = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
return Promise.all([
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
req.ctx(aboutModel).getChanpinData(channel)
]).then(result => {
res.render('chanpin', Object.assign(result[1], responseData, result[0]));
... ...
... ... @@ -257,7 +257,7 @@ module.exports = class extends global.yoho.BaseModel {
let brandsModelCtx = new BrandsModel(that.ctx);
return co(function*() {
let headerData = yield headerModel.requestHeaderData(channel);
let headerData = yield headerModel.requestHeaderData(channel, true);
let responseData = {
module: 'brands',
... ...
... ... @@ -247,7 +247,7 @@ exports.detail = (req, res, next) => {
}
let promises = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
reqCtx.getArticleContent(id, info.title),
reqCtx.getHotTags(1, 20, channel, isHotDegrade),
reqCtx.getArticleComments(udid, uid, id, page, pageSize),
... ...
... ... @@ -6,10 +6,10 @@
<div class="currencies block">
<h2 class="title"></h2>
<h1 class="my-currency{{#if tip}} has-tip{{/if}}">目前可用有货币:<em>{{myCurrency}}</em></h1>
<p class="my-currency{{#if tip}} has-tip{{/if}}">目前可用有货币:<em>{{myCurrency}}</em></p>
{{# tip}}
<h1 class="currency-tip">{{date}}即将过期:<em>{{count}}</em></h1>
<p class="currency-tip">{{date}}即将过期:<em>{{count}}</em></p>
{{/ tip}}
<div class="tab-wrap">
... ...
... ... @@ -217,7 +217,7 @@ module.exports = class extends global.yoho.BaseModel {
};
let newsAPi = new NewsAPi(this.ctx);
let apiMethod = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
newsAPi.getRecoArticles({
gender: _.get(this.ctx, 'req.yoho.gender', '1,3'),
page: 1,
... ...
... ... @@ -183,7 +183,7 @@ function getGlobalProductListData(params, yoho) {
}
return Promise.props({
header: headerModel.requestHeaderData(yoho.channel),
header: headerModel.requestHeaderData(yoho.channel, true),
fullList: this.globalApi.getGlobalProductListAsync(Object.assign({
physical_channel: yoho.channelNum,
limit: 1
... ...
... ... @@ -56,7 +56,7 @@ function getListData(params, channel) {
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
this.searchApi.getSortList({}, channel),
this.searchApi.getProductList(searchParams, 'categoryList')
];
... ... @@ -181,7 +181,7 @@ function getListNewData(params, channel) {
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
this.searchApi.getSortList({}, channel),
this.searchApi.getProductList(Object.assign(searchParams), 'newProduct'),
this.searchApi.getWeekNew(params)
... ...
... ... @@ -238,16 +238,16 @@ function getSaleOthersData(params, channel) {
if (params.saleType === '2') { // 会员专区
promiseObject = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
this.saleApi.getSaleGoodsList(params),
this.saleApi.getSaleBannerList(contentCode[channel].vip),
this.saleApi.getSaleGoodsList({saleType: '2', limit: '1', channel: channel}),
this.saleApi.getUserProfile(params.uid)
];
baseUrl += '/vip';
} else { // 罪行降价
} else { // 最新降价
promiseObject = [
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
this.saleApi.getSaleGoodsList(params),
this.saleApi.getSaleBannerList(contentCode[channel].newSale),
this.saleApi.getSaleGoodsList({limit: '1', channel: channel})
... ... @@ -473,7 +473,7 @@ function getSalebreakingYardsData(params, channel) {
const baseUrl = `/${_.toLower(channel)}-sale/breakingYards`;
return api.all([
headerModel.requestHeaderData(channel),
headerModel.requestHeaderData(channel, true),
this.saleApi.getSaleBannerList(contentCode[channel].breakCode),
this.saleApi.getSalebreakingYardsSortList(params)
]).then(result => {
... ...
... ... @@ -225,7 +225,7 @@ function _getBaseShopData(channel, params, shopInfo) {
return co(function* () {
let result = yield Promise.props({
header: headerModel.requestHeaderData(channel), // 头部数据
header: headerModel.requestHeaderData(channel, true), // 头部数据
sort: this.searchApi.getSortList({shop_id: shopId}),
decorator: this.searchApi.getShopDecorator(shopId), // 店铺装修数据
product: this.searchApi.getProductList(Object.assign(searchParams,
... ... @@ -425,7 +425,7 @@ function _getShopListData(channel, params, shopInfo) {
return co(function* () {
let result = yield Promise.props({
header: headerModel.requestHeaderData(channel), // 头部数据
header: headerModel.requestHeaderData(channel, true), // 头部数据
shopInfo: shopInfo ? shopInfo : this.api.getShopInfo(shopId), // 店铺介绍
decorator: this.searchApi.getShopDecorator(shopId), // 店铺装修数据
sort: this.searchApi.getSortList({shop_id: shopId}),
... ...
... ... @@ -219,24 +219,26 @@ const getHeaderNavAsync = () => {
* @param {String} 频道类型
* @return {promise}
*/
const cacheHeaderHtml = {
boys: [],
girls: [],
kids: [],
lifestyle: []
};
const cacheHeaderHtml = {};
const THIRTY_MINUTES = 1000 * 60 * 10;
async function requestHeaderData(type) {
let resData = {};
async function requestHeaderData(type, noH1) {
const usableType = ['boys', 'girls', 'kids', 'lifestyle'];
let resData = {disHeaderH1: noH1};
let _html;
if (!cacheHeaderHtml[type]) {
type = 'boys';
if (usableType.indexOf(type) < 0) {
type = usableType[0];
}
let cacheData = cacheHeaderHtml[type];
let cacheKey = noH1 ? `${type}_noh1` : type;
let cacheData = cacheHeaderHtml[cacheKey];
if (!cacheData) {
cacheHeaderHtml[cacheKey] = [];
cacheData = [];
}
if (_.isEmpty(cacheData[0]) || ((new Date() - cacheData[1]) > THIRTY_MINUTES)) {
let channelNum = (function() {
... ... @@ -286,7 +288,7 @@ async function requestHeaderData(type) {
_html = cacheData[0];
} else {
_html = template(resData);
cacheHeaderHtml[type] = [_html, new Date()];
cacheHeaderHtml[cacheKey] = [_html, new Date()];
}
} else {
_html = cacheData[0];
... ...
... ... @@ -93,7 +93,11 @@
<div class="head-wrapper clearfix">
<div class="center-content">
<div class="outlets-logo"></div>
<div class="main-logo"><a href="//www.yohobuy.com/" class="main-link"></a></div>
{{#if @root.disHeaderH1}}
<div class="main-logo"><a href="//www.yohobuy.com/" class="main-link" title="YOHO!BUY 有货-潮流服饰,潮流女装,潮流男装,时尚潮流购物网站"></a></div>
{{^}}
<h1 class="main-logo"><a href="//www.yohobuy.com/" class="main-link" title="YOHO!BUY 有货-潮流服饰,潮流女装,潮流男装,时尚潮流购物网站"></a></h1>
{{/if}}
<ul class="main-nav-list">
{{# navbars}}
<li class="{{type}}">
... ...