Authored by ccbikai

Merge branch 'hotfix/star'

... ... @@ -57,7 +57,7 @@ const _processIndexData = (dataList) => {
if (list.ads) {
_.forEach(list.ads.data, (data) => {
formatData.ads.push({
src: data.src + '/q/80',
src: data.src.replace('imageView', 'imageView2'),
url: data.url
});
});
... ... @@ -65,7 +65,7 @@ const _processIndexData = (dataList) => {
// 首页明星文章数据处理
if (list.list) {
_.forEach(list.list, (data) => {
_.forEach(list.list, (data, index) => {
const avatar = {
tags: []
};
... ... @@ -74,7 +74,11 @@ const _processIndexData = (dataList) => {
avatar.isSwiper = true;
}
_.forEach(data.ext.tags, (tags) => {
_.forEach(data.ext.tags, (tags, i) => {
if (i >= 1) {
return;
}
avatar.tags.push({
avatarUrl: `/guang/star/detail?tag=${tags.tagName}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${tags.tagName}"}}}`, // eslint-disable-line
cover: tags.cover ? (tags.cover + '?imageView2/2/w/104/h/104/q/80') : tags.cover,
... ... @@ -82,7 +86,12 @@ const _processIndexData = (dataList) => {
});
});
if (formatData.articles.length > 10) {
return;
}
formatData.articles.push(_.merge({
noLazy: index < 2,
id: data.id,
url: data.url,
title: data.title,
... ... @@ -97,10 +106,11 @@ const _processIndexData = (dataList) => {
// 首页明星头像数据处理
if (list.tags) {
_.forEach(list.tags, (data) => {
_.forEach(list.tags, (data, index) => {
let url = `/guang/star/detail?tag=${data.tagName}&openby:yohobuy{"action":"go.h5","params":{"id":"","share":"","shareparam":{},"islogin":"N","type":0,"updateflag":"N","url":"http://m.yohobuy.com/guang/star/detail","param":{"tag":"${data.tagName}"}}}`; // eslint-disable-line
formatData.starAvatar.push({
// noLazy: index < 5,
url: url,
cover: data.cover ? (data.cover + '?imageView2/2/w/180/h/180/q/80') : data.cover
});
... ... @@ -136,7 +146,7 @@ const _processGuangData = (list, flag) => {
// data.src += '/q/80';
if (key < 4) {
if (key < 2) {
data.islazy = true;
}
... ...
... ... @@ -11,7 +11,13 @@
<ul class="clearfix swiper-wrapper">
{{# starAvatar}}
<li class="swiper-slide">
<a href='{{url}}' style="background-image: url({{image cover 180 180}})" class="star"></a>
{{#if noLazy}}
<a href='{{url}}' class="star" style="background: url('{{image cover 180 180}}')">
</a>
{{else}}
<a href='{{url}}' class="star swiper-lazy" data-background="{{image cover 180 180}}">
</a>
{{/if}}
</li>
{{/ starAvatar}}
</ul>
... ... @@ -22,7 +28,27 @@
{{#each articles}}
<li data-id="{{id}}">
<div class="star-avatar">
{{#if isSwiper}}
<div class="avatar-wrap avatar-num-{{tags.length}}">
{{# tags}}
<a href="{{avatarUrl}}">
{{#if ../noLazy}}
<img src="{{image cover 100 100}}" class="rank-avatar" ></img>
{{else}}
<img data-original="{{image cover 100 100}}" class="rank-avatar lazy" ></img>
{{/if}}
<p class="name">{{tagName}}</p>
</a>
{{/ tags}}
{{# tags}}
{{#if @first}}
<a href="{{avatarUrl}}">
<img data-original="{{image cover 100 100}}" class="rank-avatar lazy" ></img>
<p class="name">{{tagName}}</p>
</a>
{{/if}}
{{/ tags}}
</div>
{{!-- {{#if isSwiper}}
<div class="article-avatar-swiper">
<ul class="clearfix swiper-wrapper">
{{#each tags}}
... ... @@ -42,7 +68,7 @@
<p class="name">{{tagName}}</p>
</a>
{{/ tags}}
{{/if}}
{{/if}} --}}
</div>
<a class="star-article" href='{{url}}'>
<i class="article-arrow"></i>
... ... @@ -50,7 +76,11 @@
<div class="artice-cont">
<p>{{articeTxt}}</p>
<div class="artice-imgs-area">
{{#if noLazy}}
<img src="{{image src 266 266}}" />
{{else}}
<img data-original="{{image src 266 266}}" class="lazy" />
{{/if}}
{{!-- <ul class="artice-imgs">
{{#each articeImg}}
... ...
... ... @@ -16,8 +16,8 @@ module.exports = {
domains: {
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/'
},
subDomains: {
... ...
'use strict';
const fs = require('fs');
let devHost = 'localhost';
let devHost = '127.0.0.1';
fs.readFile('.devhost', (err, buf)=> {
if (!err) {
... ...
... ... @@ -6,18 +6,12 @@
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip'),
lazyLoad = require('yoho-jquery-lazyload'),
ellipsis = require('yoho-mlellipsis'),
loading = require('../plugin/loading'),
PullRefresh = require('../plugin/pull-refresh');
var $window = $(window),
stopLoading = false,
$mainContent = $('.main-content'),
$headTab = $('.head-tab'),
headTabH = $headTab.height(),
scrollH = $(window).height() - headTabH,
$loadingTip = $('.loading-tip'),
u = navigator.userAgent,
isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
... ... @@ -32,8 +26,8 @@ var $window = $(window),
var mySwiper;
*/
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
$avatarClone, $starArticle, $avatarWrap, starIScroll;
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, bannerSwiper,
$avatarClone, $avatarWrap, starIScroll;
var swiperNum = $('.avatar-wrap .swiper-slide').width() / 2;
... ... @@ -42,39 +36,36 @@ if ($window.width() === 375 && isiOS) {
}
require('../common');
lazyLoad($('img.lazy'));
ellipsis.init();
require('yoho-jquery-lazyload');
$window.on('mousewheel', false);
$('#yoho-header, .head-tab').on('touchmove', function() {
return false;
});
// 限制标题字数
function txtLimit(dom, item1, item2) {
var $title = dom.find(item1),
$cont = dom.find(item2);
$title[0].mlellipsis(2);
$cont[0].mlellipsis(3);
}
// 设置默认头像
function setAvatar($userAvatar) {
var myImage = new Image(),
avatar = '';
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
myImage.onload = function() {
$userAvatar.css('background-image', 'url(' + avatar + ')');
};
if (avatar) {
myImage.src = avatar;
} else {
$userAvatar.addClass('default-avater');
}
}
// function txtLimit() {
//
// }
// // 设置默认头像
// function setAvatar($userAvatar) {
// var myImage = new Image(),
// avatar = '';
//
// // 部分老用户没有头像,显示默认头像
// avatar = $userAvatar.data('avatar');
//
// // myImage.onload = function() {
// // $userAvatar.css('background-image', 'url(' + avatar + ')');
// // };
// //
// // if (avatar) {
// // myImage.src = avatar;
// // } else {
// // $userAvatar.addClass('default-avater');
// // }
// }
// 明星头像点击居中显示或跳转
... ... @@ -98,14 +89,18 @@ function bindAvatar(dom) {
}
function setIndexAction() {
$('.avatar').each(function(key, item) {
$(item).addClass('avatar-' + key);
});
// $('.avatar').each(function(key, item) {
// $(item).addClass('avatar-' + key);
// });
// 明星头像 swiper 初始化
if (bannerLen > 1) {
avatarSwiper = new Swiper('.avatar-1', {
loop: true,
console.log(Math.floor($avatarWrap.find('.swiper-slide').length / 2));
avatarSwiper = new Swiper($avatarWrap.find('.avatar-swiper')[0], {
lazyLoading: true,
lazyLoadingInPrevNextAmount: 3,
// loop: true,
initialSlide: 2,
centeredSlides: true,
slidesPerView: 'auto',
... ... @@ -115,7 +110,7 @@ function setIndexAction() {
watchSlidesProgress: true,
watchSlidesVisibility: true,
onInit: function() {
$('.avatar-1 li').on('click', function() {
$avatarWrap.on('click', 'li', function() {
res = bindAvatar($(this));
return res;
});
... ... @@ -124,19 +119,19 @@ function setIndexAction() {
}
// 明星动态头像左右滑动
if ($('.article-avatar-swiper').find('li').length > 1) {
new Swiper('.article-avatar-swiper', {
initialSlide: 0,
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 5000
});
}
// if ($('.article-avatar-swiper').find('li').length > 1) {
// new Swiper('.article-avatar-swiper', {
// initialSlide: 0,
// lazyLoading: true,
// lazyLoadingInPrevNext: true,
// loop: true,
// autoplay: 5000
// });
// }
// banner swiper 初始化
if ($('.banner-swiper').find('li').length > 1) {
new Swiper('.banner-swiper', {
bannerSwiper = new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
... ... @@ -148,25 +143,20 @@ function setIndexAction() {
});
}
if ($('.star-info').find('li').length > 0) {
$starArticle.each(function(key, item) {
txtLimit($(item), '.article-title', 'p');
// articleImgAction($(item), key);
});
}
$('.rank-avatar').each(function(key, item) {
setAvatar($(item));
});
$('#yoho-header, .head-tab').on('touchmove', function() {
return false;
});
// if ($('.star-info').find('li').length > 0) {
// $starArticle.each(function(key, item) {
// txtLimit($(item), '.article-title', 'p');
//
// // articleImgAction($(item), key);
// });
// }
// $('.rank-avatar').each(function(key, item) {
// setAvatar($(item));
// });
}
function initAction() {
$starArticle = $('.star-article');
$avatarWrap = $('.avatar-wrap');
bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
... ... @@ -178,16 +168,14 @@ function initAction() {
$avatarClone = $('.avatar-clone');
// 限制标题字数
$('.cont-area').each(function() {
txtLimit($(this), '.title', '.cont-txt');
$('img.lazy').lazyload({
effect: 'fadeIn'
});
lazyLoad($('img.lazy'));
setIndexAction();
}
initAction();
// 首页数据请求
getIndexHtml = function() {
... ... @@ -195,33 +183,27 @@ getIndexHtml = function() {
$.ajax({
url: '/guang/star/getIndexHtml',
dataType: 'html',
success: function(data) {
stopLoading = false;
if (data) {
if (avatarSwiperClone) {
avatarSwiperClone.destroy(true, true);
avatarSwiperClone = '';
}
$mainContent.html(data);
initAction();
})
.done(function(data) {
if (data) {
if (avatarSwiperClone) {
avatarSwiperClone.destroy(true, true);
avatarSwiperClone = null;
}
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
$mainContent.html(data);
initAction();
}
})
.always(function() {
stopLoading = false;
loading.hideLoadingMask();
});
};
initAction();
// 下拉刷新,上拉加载
starIScroll = new PullRefresh('.star-main', {
height: scrollH,
pullDown: function() {
if (!stopLoading) {
stopLoading = true;
... ... @@ -232,58 +214,66 @@ starIScroll = new PullRefresh('.star-main', {
starIScroll.iScroll.on('scrollStart', function() {
// 下拉
if (this.directionY === -1) {
$loadingTip.slideDown();
}
});
// if (this.directionY === -1) {
// $loadingTip.slideDown();
// }
starIScroll.iScroll.on('scroll', function() {
if (this.directionY !== -1) {
starIScroll.iScroll.refresh();
}
if ($avatarWrap.offset().top <= headTabH) {
$avatarClone.show();
if (!avatarSwiperClone) {
avatarSwiperClone = new Swiper('.avatar-0', {
loop: true,
initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
centeredSlides: true,
slidesPerView: 'auto',
loopedSlides: bannerLen,
spaceBetween: 10,
slidesOffsetBefore: -swiperNum,
watchSlidesProgress: true,
watchSlidesVisibility: true,
onInit: function() {
$('.avatar-0 li').on('click', function() {
res = bindAvatar($(this));
return res;
});
}
});
avatarSwiperClone.params.control = avatarSwiper;
avatarSwiper.params.control = avatarSwiperClone;
}
}
if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
$avatarClone.hide();
}
bannerSwiper && bannerSwiper.startAutoplay();
});
// starIScroll.iScroll.on('scroll', function() {
// var avatarOffsetT;
//
// if (this.directionY !== -1) {
// setTimeout(function() {
// starIScroll.iScroll.refresh();
// }, 0);
// }
//
// avatarOffsetT = $avatarWrap[0].offsetTop;
//
// if (-this.y >= avatarOffsetT) {
// $avatarClone.show();
//
// if (!avatarSwiperClone) {
// avatarSwiperClone = new Swiper($avatarClone[0], {
// loop: true,
// initialSlide: $avatarWrap.find('.swiper-slide-active').index() % bannerLen,
// centeredSlides: true,
// slidesPerView: 'auto',
// loopedSlides: bannerLen,
// spaceBetween: 10,
// slidesOffsetBefore: -swiperNum,
// watchSlidesProgress: true,
// watchSlidesVisibility: true,
// onInit: function() {
// $avatarClone.find('li').on('click', function() {
// res = bindAvatar($(this));
// return res;
// });
// }
// });
//
// avatarSwiperClone.params.control = avatarSwiper;
// avatarSwiper.params.control = avatarSwiperClone;
// }
// } else {
// $avatarClone.hide();
// }
// });
starIScroll.iScroll.on('scrollEnd', function() {
$loadingTip.slideUp();
});
// $loadingTip.slideUp();
$('img').on('load', function() {
starIScroll && starIScroll.iScroll.refresh();
bannerSwiper && bannerSwiper.stopAutoplay();
});
window.setCookie('guangStarUid', window.queryString.uid);
// $('img').on('load', function() {
// starIScroll && starIScroll.iScroll.refresh();
// });
// 明星动态文章图片相关操作
/*
function articleImgAction(dom, key) {
... ...
... ... @@ -29,14 +29,10 @@ function PullRefresh(seclector, options) {
return;
}
if (options.height) {
$em.height(options.height);
}
this.iScroll = new IScroll($em.get(0), {
this.iScroll = new IScroll($em.get(0), $.extend({
click: true,
probeType: 3
});
}, options));
this.iScroll.on('scrollStart', function() {
if (this.y === 0) {
... ... @@ -44,7 +40,6 @@ function PullRefresh(seclector, options) {
}
pullStart = this.y;
$window.trigger('scroll');
});
this.iScroll.on('scrollEnd', function() {
... ...
@keyframes avatar2 {
0% {
transform: translate3d(0, 0, 0);
}
25% {
transform: translate3d(0, 0, 0);
}
40% {
transform: translate3d(-120px, 0, 0);
}
75% {
transform: translate3d(-120px, 0, 0);
}
90% {
transform: translate3d(-240px, 0, 0);
}
90.0001% {
transform: translate3d(0, 0, 0);
}
}
@keyframes avatar3 {
0% {
transform: translate3d(0, 0, 0);
}
27% {
transform: translate3d(0, 0, 0);
}
35% {
transform: translate3d(-120px, 0, 0);
}
59% {
transform: translate3d(-120px, 0, 0);
}
67% {
transform: translate3d(-240px, 0, 0);
}
91% {
transform: translate3d(-240px, 0, 0);
}
99% {
transform: translate3d(-360px, 0, 0);
}
99.00001% {
transform: translate3d(0, 0, 0);
}
}
... ...
@import "avatar";
@import "star";
@import "special";
@import "collocation";
... ...
... ... @@ -23,10 +23,19 @@
font-weight: bold;
}
.lazy {
opacity: 0.1;
&[src^="http"],
&[src^="//"] {
opacity: 1;
}
}
.head-tab {
position: fixed;
top: 0;
width: 100%;
width: 640px;
height: 88px;
background: #000;
z-index: 3;
... ... @@ -122,7 +131,13 @@
}
.star-main {
margin-top: 88px;
margin: 88px 0;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
height: calc(100vh - 88px);
}
.avatar-swiper {
... ... @@ -146,6 +161,7 @@
height: 110px;
margin-top: 36px;
background: #000;
transition: all 400ms;
a {
border-radius: 5px;
... ... @@ -173,16 +189,36 @@
li {
float: left;
margin-bottom: 30px;
padding-left: 10px;
}
}
.star-avatar {
width: 134px;
padding-left: 30px;
width: 120px;
margin-right: 20px;
box-sizing: border-box;
float: left;
overflow: hidden;
.avatar-wrap {
white-space: nowrap;
font-size: 0;
&.avatar-num-2 {
animation: avatar2 10s infinite;
}
&.avatar-num-3 {
animation: avatar3 15s infinite;
}
}
a {
display: inline-block;
padding: 8px;
width: 120px;
}
.article-avatar-swiper {
width: 104px;
overflow: hidden;
... ... @@ -192,7 +228,7 @@
width: 104px;
height: 104px;
border-radius: 50%;
float: left;
margin: 0 auto;
}
.name {
... ... @@ -216,7 +252,6 @@
float: left;
padding: 20px 30px;
box-sizing: border-box;
margin-left: 18px;
.article-arrow {
position: absolute;
... ... @@ -231,8 +266,14 @@
.article-title {
font-size: 28px;
line-height: 38px;
height: 76px;
color: #fff;
word-wrap: break-word;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.artice-cont {
... ... @@ -247,13 +288,19 @@
}
.artice-imgs-area {
width: 100%;
position: relative;
display: table;
margin: 10px 0;
width: 266px;
height: 266px;
overflow: hidden;
img {
width: 266px;
float: left;
margin: 25px 0;
position: absolute;
width: 100%;
left: 0;
top: 50%;
transform: translateY(-50%);
}
}
... ... @@ -294,7 +341,7 @@
.pic-icon {
width: 19px;
height: 15px;
background: url('/guang/star/img.png') no-repeat;
background: url("/guang/star/img.png") no-repeat;
background-size: contain;
display: inline-block;
margin: 6px 4px 0 8px;
... ... @@ -394,16 +441,15 @@
}
.default-avater {
background-image: resolve('guang/star/user-avatar.png');
background-image: resolve("guang/star/user-avatar.png");
}
.loading-tip {
position: absolute;
top: 0;
top: 88px;
left: 50%;
transform: translate(-50%, 0);
padding: 30px 0;
display: none;
text-align: center;
color: #ccc;
font-size: 18px;
... ...