Authored by 郝肖肖

Merge branch 'hotfix/plusstar' into feature/plusstarSpeck

... ... @@ -62,3 +62,21 @@ exports.resourcesTemplate = (req, res, next) => {
});
}).catch(next);
};
/**
* 潮流优选首页-资源位-商品列表
*/
exports.resourcesGoodsList = (req, res, next) => {
let productSkn = req.body.productSkn || '';
let isApp = req.body.app_version || req.body.appVersion || false;
plusstarModel.getProductBatch(productSkn.split(','), {
isApp: isApp
}).then(result => {
res.render('plusstar/resources-goodsList', {
layout: false,
goods: result,
title: '潮流优选'
});
}).catch(next);
};
... ...
... ... @@ -138,14 +138,7 @@ const getResources = (params, options) => {
}
});
if (_.isEmpty(data.goods.productSkns)) {
return data;
}
return getProductBatch(data.goods.productSkns, options).then(res => {
data.goods.data = res;
return data;
});
return data;
});
};
... ...
... ... @@ -36,29 +36,29 @@ const getRssArticle = (gender) => {
return articlePromise.then((article) => {
// 内容列表
if (article.data.list.artList) {
let build = {};
let build = {};
let artListFunc = (i, len, resolve) => {
if (i < len) {
let value = article.data.list.artList[i];
if (typeof value.id !== 'undefined') {
build = guangProcess.formatArticle(value, false, false, true);
build.author.name = build.author.name || '';
return _genIntro(value.id).then((intro) => {
build.intro = intro;
result.push(build);
artListFunc(++i, len, resolve);
});
}
} else {
let artListFunc = (i, len, resolve) => {
if (i < len) {
let value = article.data.list.artList[i];
if (typeof value.id !== 'undefined') {
build = guangProcess.formatArticle(value, false, false, true);
build.author.name = build.author.name || '';
return _genIntro(value.id).then((intro) => {
build.intro = intro;
result.push(build);
artListFunc(++i, len, resolve);
});
}
} else {
resolve(result);
}
};
}
};
return new Promise((resolve) => {
artListFunc(0, article.data.list.artList.length, resolve);
});
});
}
}
});
};
... ... @@ -75,18 +75,18 @@ const _genIntro = (id) => {
resData.data.forEach((value) => {
if (value.text) { // 文字
result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>';
} else if (value.singleImage) { // 单张图
result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
} else if (value.singleImage) { // 单张图
result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
} else if (value.smallPic && value.smallPic.data) { // 多张小图
value.smallPic.data.forEach((small) => {
result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
});
result += '<br/>';
value.smallPic.data.forEach((small) => {
result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
});
result += '<br/>';
}
});
});
return result;
}
});
}
});
};
module.exports = {
... ...
... ... @@ -32,6 +32,7 @@ router.get('/', homeController.index); // 逛首页
router.get('/plusstar', plusstar.index); // 潮流优选
router.get('/plusstar/resources-template', plusstar.resourcesTemplate); // 潮流优选首页-资源位
router.post('/plusstar/resources-goodsList', plusstar.resourcesGoodsList); // 潮流优选首页-资源位-商品列表
router.get('/', index.index); // 逛首页
router.get('/tags/index', index.tag); // 逛标签页
... ...
<div class='plusstar-page'>
<div class='yoho-page plusstar-page'>
{{#if result.channel}}
<div class="tab-nav">
<ul>
... ...
{{#each goods}}
{{> common/goods}}
{{/each}}
\ No newline at end of file
... ...
... ... @@ -76,13 +76,12 @@
<a class="more" href="{{result.goods.title.moreUrl}}">
{{result.goods.title.moreName}}
</a>
<input type='hidden' value='{{result.goods.productSkns}}' class='product-skns' />
</div>
<div class="goods clearfix">
<!--商品--->
{{#each result.goods.data}}
{{> common/goods}}
{{/each}}
</div><!--/goods-->
{{/if}}
... ...
... ... @@ -74,4 +74,4 @@ module.exports = () => {
}
next();
};
};
\ No newline at end of file
};
... ...
... ... @@ -162,4 +162,4 @@ if ($('#noData').length > 0) {
$mask.on('click', function() {
$mask.hide();
$message.hide();
});
\ No newline at end of file
});
... ...
... ... @@ -258,7 +258,7 @@ function loadMore($container, opt, url) {
delete opt.isTab;
},
error: function() {
console.log('error')
console.log('error');
tip.show('网络断开连接了~');
searching = false;
delete opt.isTab;
... ...
... ... @@ -196,12 +196,12 @@ $('img').on('load', function() {
if ($('.guang-detail-page').hasClass('guang-detail')) {
useIscroll = true;
} else if($('.guang-detail-page').hasClass('guang-ezine')) {
} else if ($('.guang-detail-page').hasClass('guang-ezine')) {
useIscroll = false;
}
$('.main-wrap').css({
position: 'static'
})
});
pageInIscroll = isIphone && useIscroll;
... ...
... ... @@ -2,16 +2,24 @@ var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
Swiper = require('yoho-swiper'),
loading = require('../plugin/loading'),
debounce = require('lodash/debounce'),
lazyLoad = require('yoho-jquery-lazyload');
var plusstar = {},
$footer = $('#yoho-footer');
var windowHeight = $(window).height();
var scrollFn,
scrollTop;
require('../common');
plusstar = {
common: {
codeDefault: ''
codeDefault: '',
page: 1,
pagesize: 20,
productSkns: []
},
init: function() {
var that = this,
... ... @@ -60,6 +68,7 @@ plusstar = {
var that = this;
this.common.codeDefault = code;// 记住最后一次的tab code
this.common.page = 1;// 商品列表从第一页开始
loading.showLoadingMask();
... ... @@ -72,6 +81,8 @@ plusstar = {
},
dataType: 'html',
success: function(data) {
var productSkns = '';
$('.plusstar-resources').html(data);
if (data === '') {
... ... @@ -97,6 +108,13 @@ plusstar = {
if (window.localStorage) {
$(document).scrollTop(localStorage.getItem(code) || 0);
}
productSkns = $(data).find('.product-skns').val();
if (productSkns) {
that.common.productSkns = productSkns.split(',');
}
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -118,11 +136,59 @@ plusstar = {
pagination: '.banner-top .pagination-inner'
});
}
},
goodsList: function() {
var that = this,
skn = [],
len = 0;
len = (that.common.page - 1) * that.common.pagesize;
skn = that.common.productSkns.slice(len, len + that.common.pagesize);
if (skn.length < 1) {
return false;
}
loading.showLoadingMask();
that.common.page++;
$.ajax({
type: 'POST',
url: '/guang/plusstar/resources-goodsList',
data: {
productSkn: skn.join(','),
app_version: window.queryString.app_version || window.queryString.appVersion
},
dataType: 'html',
success: function(data) {
if (data === '') {
return true;
}
$('.plusstar-resources .goods').append(data);
lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])'));
loading.hideLoadingMask();
}
});
}
};
$(function() {
scrollFn = debounce(function() {
scrollTop = $(document).scrollTop();
// 当scroll到最后一列商品的高度后继续请求下一页数据
if (400 + scrollTop >= $(document).height() - windowHeight) {
plusstar.goodsList();
}
if (window.localStorage) {
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
}
}, 200);
$(function() {
if (!(window.queryString.app_version || window.queryString.appVersion)) {
$('.tab-nav').css({
position: 'relative'
... ... @@ -137,9 +203,9 @@ $(function() {
plusstar.init();
if (window.localStorage) {
$(document).scroll(function() {
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
});
}
// 滚动翻页
$(window).scroll(function() {
scrollFn();
});
});
... ...
... ... @@ -33,7 +33,7 @@ $('#nav-tab').on('touchend touchcancel', function(e) {
$navs.toggleClass('focus');
$contents.toggleClass('hide');
$(document).trigger('scroll'); //Trigger lazyLoad
$(document).trigger('scroll'); // Trigger lazyLoad
});
$('#nav-tab').on('touchstart', function(e) {
var target = e.target || e.srcElement;
... ... @@ -41,4 +41,4 @@ $('#nav-tab').on('touchstart', function(e) {
target.className = 'bytouch ' + target.className;
}).on('touchend touchcancel', function() {
$navs.removeClass('bytouch');
});
\ No newline at end of file
});
... ...
... ... @@ -135,8 +135,8 @@ function initFilter(opt) {
var $this = $(e.target),
$cur;
//这行不能注释,iphone下会出现穿透
e.preventDefault();//防止透点
// 这行不能注释,iphone下会出现穿透
e.preventDefault();// 防止透点
if ($this.closest('.filter-body').length > 0) {
$cur = $this.closest('.sub-item');
... ...
... ... @@ -89,7 +89,7 @@ ellipsis.init();
tip.show('网络断开连接了~');
}
});
} else if ($('.shopId').val().length > 0){
} else if ($('.shopId').val().length > 0) {
$.ajax({
url: '/product/index/baseShopFav',
data: {
... ...
... ... @@ -36,7 +36,7 @@ var $subNav = $('.home-sub-nav'),
brand = $('input[name="brand"]').val(),
coverChannel = $('input[name="coverChannel"]').val(),
favId = $('input[name="favId"]').val();
uid = $('input[name="uid"]').val();
uid = $('input[name="uid"]').val();
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
... ...
... ... @@ -20,7 +20,7 @@ const removeHtml = (str) => {
const htmlToEscape = (html) => {
return html.replace(/[<>&"]/g, (e) => {
return _htmlMap[e];
});
});
};
/**
... ... @@ -29,7 +29,7 @@ const htmlToEscape = (html) => {
const escapeToHtml = (str) => {
return str.replace(/&(lt|gt|nbsp|amp|quot);/g, (match, e) => {
return _EscapeMap[e];
});
});
};
module.exports = {
... ...