Authored by 王水玲

单品日

... ... @@ -21,18 +21,19 @@ const singleDay = (req, res) => {
};
const getSingleData = (req, res) => {
Promise.all([singleDayModel.getResourceData(), singleDayModel.getProductData()]).then((result) => {
Promise.all([singleDayModel.getResourceData(), singleDayModel.getTabData()]).then((result) => {
res.json(result);
});
};
// const getProductData = (req, res) => {
// singleDayModel.getProductData().then(result => {
// res.json(result);
// });
// };
const getProductData = (req, res) => {
singleDayModel.getProductData(req.query.tab_name).then(result => {
res.json(result);
});
};
module.exports = {
singleDay,
getSingleData
getSingleData,
getProductData
};
... ...
... ... @@ -25,9 +25,10 @@ const getResourceData = () => {
});
};
const getProductData = () => {
const getProductData = (tabName) => {
return api.get('', {
method: ''
method: '',
tab_name: tabName
}, {
cache: true
}).then((result) => {
... ... @@ -40,7 +41,23 @@ const getProductData = () => {
});
};
const getTabData = () => {
return api.get('', {
method: ''
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result;
} else {
logger.error('get tab data code no 200');
return [];
}
});
};
module.exports = {
getResourceData,
getProductData
getProductData,
getTabData
};
... ...
... ... @@ -85,6 +85,7 @@ router.post('/vip-day/msg/save.json', vipDay.beforeIn, vipDay.saveMsg);
router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg);
router.get('/single-day', singleDay.singleDay);
router.get('/single-day/getSingleData', singleDay.getSingleData);
router.get('/single-day/getProductData', singleDay.getProductData);
module.exports = router;
... ...
<div class="single-day-page yoho-page">
<div class="banner"></div>
<div class="swiper-tab">
<ul class="swiper-wrapper">
<li class="swiper-slide">联名限定</li>
<li class="swiper-slide">首发</li>
<li class="swiper-slide">热卖</li>
<li class="swiper-slide">明星单品</li>
</ul>
</div>
<div class="swiper-tab"></div>
<div class="product-list">
<ul>
<li>
<a href="">
<img src=""/>
<div class="product-info">
<h3>AVIREX L-2 PATCH YING TIGERS男款上海别注夹克</h3>
<p class="prompt-info">下单后25个工作日发货</p>
<p class="price"><span class="sale-price">¥589</span><span class="market-price">¥1234</span></p>
<p class="info-txt">#Yoho!Buy限定联名T恤#</p>
</div>
</a>
</li>
<li>
<a href="">
<img src=""/>
<div class="product-info">
<h3>AVIREX L-2 PATCH YING TIGERS男款上海别注夹克</h3>
<p class="prompt-info">下单后25个工作日发货</p>
<p class="price"><span class="sale-price">¥589</span><span class="market-price">¥1234</span></p>
<p class="info-txt">#Yoho!Buy限定联名T恤#</p>
</div>
</a>
</li>
</ul>
<!--<ul>-->
<!--<li>-->
<!--<a href="">-->
<!--<img src=""/>-->
<!--<div class="product-info">-->
<!--<h3>AVIREX L-2 PATCH YING TIGERS男款上海别注夹克</h3>-->
<!--<p class="prompt-info">下单后25个工作日发货</p>-->
<!--<p class="price"><span class="sale-price">¥589</span><span class="market-price">¥1234</span></p>-->
<!--<p class="info-txt">#Yoho!Buy限定联名T恤#</p>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--<li>-->
<!--<a href="">-->
<!--<img src=""/>-->
<!--<div class="product-info">-->
<!--<h3>AVIREX L-2 PATCH YING TIGERS男款上海别注夹克</h3>-->
<!--<p class="prompt-info">下单后25个工作日发货</p>-->
<!--<p class="price"><span class="sale-price">¥589</span><span class="market-price">¥1234</span></p>-->
<!--<p class="info-txt">#Yoho!Buy限定联名T恤#</p>-->
<!--</div>-->
<!--</a>-->
<!--</li>-->
<!--</ul>-->
</div>
</div>
... ...
... ... @@ -4,53 +4,110 @@
* @date: 2016/10/17
*/
var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
Swiper = require('yoho-swiper'),
share = require('../common/share'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
banner = require('../../template/resources/banner-top.hbs'),
tab = require('../../template/activity/single-day/tab.hbs'),
product = require('../../template/activity/single-day/product-list.hbs');
var hash = window.location.hash.replace('#', '');
var $productList = $('.product-list');
var getFlag = false;
share({
title: '有货【会员日】潮集狂欢,限时六大福利,还不快参与起来?!',
link: location.href,
desc: '每月28日,尽情释放!',
imgUrl: 'http://img10.static.yhbimg.com/taobaocms/2016/09/23/18/010ccac2955e7e50ffb66b75110e73e3e1.png'
});
var getProductData = function(index, tabName) {
if (getFlag) {
return;
}
getFlag = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '',
data: {
tab_name: tabName
},
success: function(data) {
if (data) {
$('.product-tab').eq(index).append(product(data));
}
$.ajax({
type: 'GET',
url: '/activity/single-day/getSingleData',
success: function(data) {
if (data[0]) {
$('.banner').append(banner(data[0][0]));
if ($('.banner-swiper').find('li').size() > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
getFlag = false;
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
loading.hideLoadingMask();
getFlag = false;
}
});
};
var tabName = function(index) {
return $('.swiper-tab li').eq(index).html();
};
var getInitData = function() {
$.ajax({
type: 'GET',
url: '/activity/single-day/getSingleData',
success: function(data) {
var i = 0;
data[1] = ['限定名额', '首发', '热卖', '明星单品'];
if (data[0]) {
$('.banner').append(banner(data[0][0]));
if ($('.banner-swiper').find('li').size() > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
}
if (data[1]) {
$('.swiper-tab').append(tab(data[1]));
new Swiper('.swiper-tab', {
slidesPerView: 'auto'
});
for (i; i < data[1].length; i++) {
$productList.append('<ul class="product-tab"></ul>');
}
getProductData(hash, tabName(hash));
$('.swiper-tab li')
.eq(hash)
.addClass('active')
.on('click', function() {
var index = $(this).index();
if ($('.product-tab').eq(index).find('li').length > 0) {
return false;
} else {
getProductData(index, tabName(index));
}
});
}
}
if (data[1]) {
$('.product-list').append(product(data[1]));
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
$('.swiper-tab li').eq(hash).addClass('active');
});
};
new Swiper('.swiper-tab', {
slidesPerView: 'auto'
$(function() {
loading.showLoadingMask();
getInitData();
});
... ...
<ul>
{{#each data}}
<li>
<a href="{{url}}">
<img src="{{image src 274 368}}"/>
<div class="product-info">
<h3>{{title}}</h3>
{{#intro}}<p class="prompt-info">{{intro}}</p>{{/intro}}
<p class="price"><span class="sale-price {{^marketPrice}}no-price{{/marketPrice}}">¥{{salePrice}}</span><span class="market-price">¥{{marketPrice}}</span></p>
<p class="info-txt">#{{cont}}#</p>
</div>
</a>
</li>
{{/each}}
</ul>
{{#each data}}
<li>
<a href="{{url}}">
<img src="{{image src 274 368}}"/>
<div class="product-info">
<h3>{{title}}</h3>
{{#intro}}<p class="prompt-info">{{intro}}</p>{{/intro}}
<p class="price"><span class="sale-price {{^marketPrice}}no-price{{/marketPrice}}">¥{{salePrice}}</span><span class="market-price">¥{{marketPrice}}</span></p>
<p class="info-txt">#{{cont}}#</p>
</div>
</a>
</li>
{{/each}}
... ...
<ul class="swiper-wrapper">
{{#each this}}
<li class="swiper-slide">{{.}}</li>
{{/each}}
</ul>
... ...