Authored by 王水玲

星潮 优化

... ... @@ -70,7 +70,7 @@ const contentCode = {
};
/**
* 折扣专场列表数据处理
* 折扣专场列表页及详情页公共方法
* @param {[array]} list
* @return {[array]}
*/
... ... @@ -81,6 +81,7 @@ const _processDiscount = (list, channel) => {
list = list || [];
list = camelCase(list);
// list为1条数据是表示详情页,flag 设为false,不需要拼接跳转链接
if (list.length === 1) {
flag = false;
}
... ... @@ -88,7 +89,7 @@ const _processDiscount = (list, channel) => {
_.forEach(list, (data) => {
if (flag === true) {
data.specialUrl = `/product/sale/discount/detail?id=${data.id}&channel=${channel}`;
_.merge(data, processTime(data.leftTime));
Object.assign(data, processTime(data.leftTime));
}
formatData.push(data);
... ... @@ -356,11 +357,11 @@ const getDiscountDetailData = (id, yhChannel) => {
res = _processDiscount(result.data);
return {
title: res[0].title,
productPool: res[0].productPool,
title: res[0] && res[0].title,
productPool: res[0] && res[0].productPool,
activity: {
coverUrl: res[0].coverUrl,
leftTime: res[0].leftTime
coverUrl: res[0] && res[0].coverUrl,
leftTime: res[0] && res[0].leftTime
}
};
} else {
... ...
... ... @@ -14,14 +14,10 @@ var $ = require('yoho-jquery'),
var $window = $(window),
$starArticle = $('.star-article'),
// $headTab = $('.head-tab'),
stopLoading = false,
avatarSwiper,
avatarSwiperClone,
getIndexHtml;
stopLoading = false;
/*
$headTab = $('.head-tab'),
$swiperView = $('.swiper-view'),
$viewImg = $('.view-img'),
$body = $('body'),
... ... @@ -31,7 +27,7 @@ var $window = $(window),
var mySwiper;
*/
var avatarKey, bannerLen, res;
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $avatar;
require('../common');
... ... @@ -124,7 +120,7 @@ function setIndexAction() {
starIScroll.iScroll.on('scroll', function() {
if ($avatarWrap.offset().top <= 0) {
$('.avatar-clone').show();
$avatarClone.show();
if (!avatarSwiperClone) {
avatarSwiperClone = new Swiper('.avatar-0', {
... ... @@ -151,7 +147,7 @@ function setIndexAction() {
}
if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
$('.avatar-clone').hide();
$avatarClone.hide();
}
});
... ... @@ -164,63 +160,6 @@ function setIndexAction() {
$loadingTip.slideUp();
});
// 明星动态文章图片相关操作
/*
function articleImgAction(dom, key) {
var $articeImgs = dom.find('.artice-imgs'),
$li = $articeImgs.find('li'),
imgLen = $articeImgs.find('img').length,
addFlagDom = $li.eq(2);
var i;
imgs = [];
$li.each(function() {
imgs.push($(this).find('img').attr('src'));
});
allImgs[key] = imgs;
$li.on('click', function() {
for (i = 0; i < imgLen; i++) {
$swiperView.find('ul').append('<li class="swiper-slide">' +
'<img class="swiper-lazy" data-src="' + allImgs[key][i] + '">' +
'<div class="swiper-lazy-preloader"></div></li>');
}
setTimeout(function() {
mySwiper = new Swiper('.swiper-view', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
slideElement: 'li'
});
$('.swiper-view li').on('click', function(e) {
if (e.target.nodeName === 'IMG') {
return;
}
$viewImg.hide();
$body.css({
overflow: 'auto'
});
$viewImg.find('li').remove();
mySwiper.destroy(false);
});
}, 100);
$viewImg.show();
$body.css({
overflow: 'hidden'
});
});
if (imgLen > 3 && addFlagDom.find('.img-size').length < 1) {
addFlagDom.append('<div class="img-size"><i class="pic-icon"></i>' + imgLen + '</div>');
}
}
*/
$('.avatar').each(function(key, item) {
$(item).addClass('avatar-' + key);
});
... ... @@ -307,10 +246,11 @@ getIndexHtml = function() {
}
$starMain.html(data);
bannerLen = $('.avatar .swiper-slide').length;
$avatar = $('.avatar');
bannerLen = $avatar.find('.swiper-slide').length;
if ($('.avatar-clone').length) {
$('.avatar-clone').remove();
if ($avatarClone) {
$avatarClone.remove();
}
$('.avatar li').each(function() {
... ... @@ -319,6 +259,8 @@ getIndexHtml = function() {
$starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
$avatarClone = $('.avatar-clone');
// 限制标题字数
$('.cont-area').each(function() {
txtLimit($(this), '.title', '.cont-txt');
... ... @@ -339,3 +281,60 @@ getIndexHtml = function() {
};
getIndexHtml();
// 明星动态文章图片相关操作
/*
function articleImgAction(dom, key) {
var $articeImgs = dom.find('.artice-imgs'),
$li = $articeImgs.find('li'),
imgLen = $articeImgs.find('img').length,
addFlagDom = $li.eq(2);
var i;
imgs = [];
$li.each(function() {
imgs.push($(this).find('img').attr('src'));
});
allImgs[key] = imgs;
$li.on('click', function() {
for (i = 0; i < imgLen; i++) {
$swiperView.find('ul').append('<li class="swiper-slide">' +
'<img class="swiper-lazy" data-src="' + allImgs[key][i] + '">' +
'<div class="swiper-lazy-preloader"></div></li>');
}
setTimeout(function() {
mySwiper = new Swiper('.swiper-view', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
slideElement: 'li'
});
$('.swiper-view li').on('click', function(e) {
if (e.target.nodeName === 'IMG') {
return;
}
$viewImg.hide();
$body.css({
overflow: 'auto'
});
$viewImg.find('li').remove();
mySwiper.destroy(false);
});
}, 100);
$viewImg.show();
$body.css({
overflow: 'hidden'
});
});
if (imgLen > 3 && addFlagDom.find('.img-size').length < 1) {
addFlagDom.append('<div class="img-size"><i class="pic-icon"></i>' + imgLen + '</div>');
}
}
*/
... ...