Authored by 徐炜

Merge remote-tracking branch 'origin/feature/guang-optim' into release/wap-optim4

# Conflicts:
#	config/cache.js
#	public/js/common/helpers/image2.js
... ... @@ -66,7 +66,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: 20
limit: 4
};
return serviceAPI.get('guang/api/v2/article/getList', param, {
... ... @@ -143,7 +143,8 @@ const _article = (param) => {
uid: param.uid,
udid: param.udid,
sort_id: 0,
tag: param.tag ? param.tag : null
tag: param.tag ? param.tag : null,
limit: 4
// author_id: param.authorId ? param.authorId : null,
// limit: param.limit ? param.limit : null
... ...
... ... @@ -19,13 +19,15 @@
{{# ../swiper}}
<div class="swiper-slide">
<a href="{{url}}">
{{#if @first}}
<img src="{{image2 img width=200 height=100 q=60}}">
{{^}}
<img class="swiper-lazy" data-src="{{image2 img width=200 height=100 q=60}}">
{{/if}}
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ ../swiper}}
</div>
<div class="swiper-pagination swiper-pagi-{{typeId}}"></div>
</div>
{{/if}}
{{/if}}
... ...
... ... @@ -3,7 +3,7 @@
{{# authorInfo}}
<div id="author-infos" class="editor-header clearfix" data-id={{uid}}>
<div class="avatar">
<img src="{{avatar}}">
<img src="{{image2 avatar mode=2 q=60}}">
</div>
<div class="text">
<p class="name">{{name}}</p>
... ...
... ... @@ -4,13 +4,15 @@
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
{{#if @first}}
<img src="{{image2 img q=60}}">
{{^}}
<img class="swiper-lazy" data-src="{{image2 img q=60}}">
{{/if}}
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
{{# infos}}
... ...
<div class="guang-info" data-id="{{id}}">
{{# author}}
<a class="info-author clearfix" href={{url}}>
<img class="lazy avatar" data-original={{avatar}}>
<img class="lazy avatar" data-original={{image2 avatar mode=2 q=60}}>
<span class="name">{{name}}</span>
</a>
{{/ author}}
... ... @@ -36,7 +36,11 @@
</a>
{{/if}}
<a href="{{url}}">
<img class="lazy" data-original="{{img}}" alt="{{alt}}">
{{#if @first}}
<img src="{{image2 img q=60}}" alt="{{alt}}">
{{^}}
<img class="lazy" data-original="{{image2 img q=60}}" alt="{{alt}}">
{{/if}}
</a>
</div>
... ...
<div class="guang-info" data-id="{{id}}">
{{# author}}
<a class="info-author clearfix" href={{url}}>
<img class="lazy avatar" data-original={{avatar}}>
<img class="lazy avatar" data-original={{image2 avatar mode=2 q=60}}>
<span class="name">{{name}}</span>
</a>
{{/ author}}
... ... @@ -36,7 +36,11 @@
</a>
{{/if}}
<a href="{{url}}">
<img class="lazy" data-original="{{img}}" alt="{{alt}}">
{{#if @first}}
<img src="{{image2 img q=60}}" alt="{{alt}}">
{{^}}
<img class="lazy" data-original="{{image2 img q=60}}" alt="{{alt}}">
{{/if}}
</a>
</div>
... ...
... ... @@ -117,6 +117,9 @@ exports.intro = (req, res, next) => {
introModel.getintroIntro({
productskn: req.params.productskn
}, req).then(html => {
res.set({
'Cache-Control': 'max-age=' + 1800
});
res.send(html);
});
... ...
... ... @@ -12,6 +12,9 @@ const cachePage = {
'/kids': 30 * SECOND,
'/lifestyle': 30 * SECOND,
//ajax获取频道页楼层
'/channel/getResourceContent': 30 * MINUTE,
// 商品分类
'/cate': 5 * MINUTE,
... ... @@ -21,12 +24,21 @@ const cachePage = {
// 商品详情ajax
// 店铺推荐
'/product/detail/preference': 5 * MINUTE,
'/product/detail/intro/:productskn': 15 * MINUTE,
// 店铺人气单品
'/product/new/shop/hotlist': 5 * MINUTE,
// 店铺简介
'/product/index/intro' : 15 * MINUTE,
// 逛
'/guang/': 1 * MINUTE,
'/guang/info/index': 10 * MINUTE,
'/guang/author/index': 1 * MINUTE,
'/guang/tags/index': 1 * MINUTE,
'/guang/plustar': 1 * MINUTE,
'/guang/index/page': 1 * MINUTE,
// '/guang/plustar/brandinfo': 1 * MINUTE,
'/guang/star': 1 * MINUTE,
... ... @@ -40,6 +52,9 @@ const cachePage = {
'/product/index/index': 1 * MINUTE,
'/product/index/brand': 1 * MINUTE,
'/product/search/filter': 1 * MINUTE,
'/product/search/search': 1 * MINUTE,
'/product/new': 1 * MINUTE,
// 秒杀列表
... ...
... ... @@ -100,6 +100,7 @@
"yoho-jquery-qrcode": "^0.14.0",
"yoho-mlellipsis": "0.0.3",
"yoho-qs": "^1.0.1",
"yoho-swiper": "^3.3.1"
"yoho-swiper": "^3.3.1",
"yoho-swiper2": "0.0.3"
}
}
... ...
... ... @@ -3,8 +3,7 @@
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer');
var $ = require('yoho-jquery');
var $footer = $('#yoho-footer'),
$yohoPage = $('.yoho-page'),
... ... @@ -177,8 +176,6 @@ $.extend({
var user = getUser();
var backToTopHammer;
rePosFooter(); // 计算底部位置
if (user === 0) {
... ... @@ -200,10 +197,9 @@ $.extend({
}
if ($backToTop.length > 0) {
backToTopHammer = new Hammer($backToTop[0]);
backToTopHammer.on('tap', function(e) {
$backToTop.on('touchend touchcancel', function(e) {
$(window).scrollTop(0);
e.srcEvent.preventDefault();
e.preventDefault();
return false;
});
}
... ...
module.exports = function(url, opts) {
if (url) {
module.exports = function (imageUrl, opts) {
if (imageUrl) {
let params = opts.hash;
let urls = url.split('?');
let urls = imageUrl.split('?');
let query = urls[1] || '';
let uri = urls[0];
... ... @@ -24,12 +24,22 @@ module.exports = function(url, opts) {
} else {
query += '/quality/' + params.q;
}
} else if (query.indexOf('imageView/') === 0) {
if (params.q && query.indexOf('/q/') > 0) {
query = query.replace(/\/q\/\d+/g, '/q/' + params.q);
} else {
query += '/q/' + params.q;
}
if (params.mode) {
query = query.replace(/imageView\/\d{1}\//, 'imageView/' + params.mode + '/');
}
}
} else {
query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
}
return uri + '?' + query;
} else {
return url;
return imageUrl;
}
};
... ...
... ... @@ -70,7 +70,7 @@ $nav.on('touchend touchcancel', function(e) {
return;
}
e.preventDefault();
index = $this.index();
$this.addClass('focus');
... ...
... ... @@ -8,7 +8,7 @@ var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload'),
Swiper = require('yoho-swiper');
Swiper = require('yoho-swiper2');
var tip = require('../plugin/tip');
var loading = require('../plugin/loading');
... ... @@ -52,12 +52,15 @@ function initSwiper(typeId) {
if (!typeId) {
return;
}
if (!mySwiper[typeId]) {
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
lazyLoading: true,
wrapperClass: 'swiper-wrap-' + typeId,
pagination: '.swiper-pagi-' + typeId,
autoplay: 3000
});
}
}
/**
... ...
... ... @@ -5,10 +5,9 @@
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload'),
Swiper = require('yoho-swiper');
Swiper = require('yoho-swiper2');
var tip = require('../plugin/tip');
var loading = require('../plugin/loading');
... ... @@ -55,12 +54,15 @@ function initSwiper(typeId) {
if (typeof typeId === undefined) {
return;
}
if (!mySwiper[typeId]) {
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
lazyLoading: true,
wrapperClass: 'swiper-wrap-' + typeId,
pagination: '.swiper-pagi-' + typeId,
autoplay: 3000
});
}
}
/**
... ... @@ -85,38 +87,20 @@ function setLazyLoadAndMellipsis($infos) {
* @params $container 逛资讯列表容器
*/
function initInfosEvt($container) {
var cHammer;
if (typeof $container === 'undefined') {
return;
}
if (typeof $container[0] === 'undefined') {
return;
}
cHammer = new Hammer($container[0]);
// 点赞或者收藏事件
cHammer.on('tap', function(e) {
var $this = $(e.target),
opt = 'ok',
$btn,
$info,
yhChannel;
// e.preventDefault();
// 点赞
$btn = $this.closest('.like-btn');
if ($btn.length > 0 && !isLoading) {
$container.find('.like-btn').on('touchend touchcancel', function(e) {
var opt = 'ok', $btn = $(this), $info, isLoading;
e.preventDefault();
if ($btn.hasClass('like')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
$info = $btn.closest('.guang-info');
isLoading = true;
$.ajax({
type: 'POST',
url: '/guang/opt/praiseArticle',
... ... @@ -127,10 +111,8 @@ function initInfosEvt($container) {
success: function(data) {
var code = data.code;
if (code === 200) {
$btn.next('.like-count').text(data.data);
// 切换点赞状态
$btn.toggleClass('like');
}
... ... @@ -143,18 +125,16 @@ function initInfosEvt($container) {
}
});
return;
}
});
// APP收藏
$btn = $this.closest('.collect-btn');
if ($btn.length > 0) {
$container.find('.collect-btn').on('touchend touchcancel', function(e) {
var opt = 'ok', $btn = $(this), $info, isLoading, yhChannel;
e.preventDefault();
if ($btn.hasClass('collected')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
$info = $btn.closest('.guang-info');
isLoading = true;
if (getUrlParam('yh_channel')) {
yhChannel = getUrlParam('yh_channel');
}
... ... @@ -179,7 +159,7 @@ function initInfosEvt($container) {
tip.show('网络断开连接了~');
}
});
}
return;
});
setLazyLoadAndMellipsis($container.find('.guang-info'));
... ... @@ -253,8 +233,6 @@ function loadMore($container, opt, url) {
getDynamicData.getDynamicData();
window.rePosFooter();// 插入内容后重新计算底部位置
getDynamicData.getDynamicData();
}
opt.page++;
... ...
... ... @@ -78,6 +78,7 @@ function renderData(data) {
function getDynamicData() {
'use strict';
setTimeout(function() {
var idArr = [];
$('.info-list').not('.hide').find('.guang-info').each(function() {
... ... @@ -89,6 +90,7 @@ function getDynamicData() {
});
getDynamicByIds(idArr.join(',')).then(renderData);
}, 150);
}
module.exports = {
... ...
... ... @@ -38,6 +38,7 @@
.banner-swiper {
position: static;
max-height: 312px;
height: 312px;
ul {
position: relative;
... ...
... ... @@ -8,10 +8,10 @@ module.exports = {
imgSrc: function(imgSrc) {
return url.resolve(assetUrl, imgSrc);
},
image2: function(url, opts) {
if (url) {
image2: function(imageUrl, opts) {
if (imageUrl) {
let params = opts.hash;
let urls = url.split('?');
let urls = imageUrl.split('?');
let query = urls[1] || '';
let uri = urls[0];
... ... @@ -34,13 +34,23 @@ module.exports = {
} else {
query += '/quality/' + params.q;
}
} else if (query.indexOf('imageView/') === 0){
if (params.q && query.indexOf('/q/') > 0) {
query = query.replace(/\/q\/\d+/g, '/q/' + params.q);
} else {
query += '/q/' + params.q;
}
if (params.mode) {
query = query.replace(/imageView\/\d{1}\//, 'imageView/' + params.mode + '/');
}
}
} else {
query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
}
return uri + '?' + query;
} else {
return url;
return imageUrl;
}
},
ifor: function() {
... ...