Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/release/single' into release/5.1

/**
* 单品日
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/17
*/
'use strict';
const singleDayModel = require('../models/single-day');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const singleDay = (req, res) => {
res.render('single-day/single-day', {
module: 'activity',
page: 'single-day',
title: '超级单品日',
isApp: req.yoho.isApp,
width750: true,
pageHeader: headerModel.setNav({
navTitle: '超级单品日',
navBtn: false
}),
pageFooter: false
});
};
const getSingleData = (req, res) => {
Promise.all([singleDayModel.getResourceData(), singleDayModel.getTabData()]).then((result) => {
res.json(result);
});
};
const getProductData = (req, res) => {
singleDayModel.getProductData(req.query.tab_name).then(result => {
res.json(result);
});
};
module.exports = {
singleDay,
getSingleData,
getProductData
};
... ...
/**
* 单品日
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/17
*/
'use strict';
const utils = '../../../utils';
const logger = global.yoho.logger;
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const resourcesProcess = require(`${utils}/resources-process`);
const getResourceData = () => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: 'c0acf0296a3c329678fb45da958d9951',
platform: 'iphone'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
logger.error('resource code no 200');
return [];
}
});
};
const getProductData = (tabName) => {
return api.get('', {
method: 'app.product.singleDay',
tab_name: tabName
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
result.data = result.data || [];
_.forEach(result.data, (item) => {
item.url = helpers.urlFormat(`/product/pro_${item.productId}_${item.goodsId}/${item.cnAlphabet}.html`); // eslint-disable-line
item.url = helpers.appUrlFormat(item.url, 'go.productDetail', {
product_skn: item.productSkn
});
});
return result.data;
} else {
logger.error('get product data code no 200');
return [];
}
});
};
// 获取活动tab标签
const getTabData = () => {
return api.get('', {
method: 'app.product.singleDayTabNameList'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data || [];
} else {
logger.error('get tab data code no 200');
return [];
}
});
};
module.exports = {
getResourceData,
getProductData,
getTabData
};
... ...
... ... @@ -21,8 +21,11 @@ const auth = require('../../doraemon/middleware/auth');
const vipDay = require(`${cRoot}/vipDay`);
const vipDay1028 = require(`${cRoot}/vipDay10`);
const market = require(`${cRoot}/market`);
const coin = require(`${cRoot}/coin`);
const shopCollect = require(`${cRoot}/shopCollect`);
const singleDay = require(`${cRoot}/single-day`);
const share = require(`${cRoot}/share`);
// routers
... ... @@ -92,12 +95,16 @@ router.post('/vip-day/signin.json', vipDay.beforeIn, vipDay.signin);
router.post('/vip-day/msg/save.json', vipDay.beforeIn, vipDay.saveMsg);
router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg);
router.get('/coin/sendCoin', coin.sendCoin);
router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏
router.get('/shopList', shopCollect.shopList);// 店铺收藏列表
router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航
router.get('/shopfavStatus', shopCollect.shopFav);// 店铺收藏状态
router.get('/single-day', singleDay.singleDay);
router.get('/single-day/getSingleData', singleDay.getSingleData);
router.get('/single-day/getProductData', singleDay.getProductData);
router.get('/share', share.getShareContent);
// 102828会员日
... ...
<div class="single-day-page yoho-page">
<div class="banner"></div>
<div class="swiper-tab"></div>
<div class="product-list"></div>
</div>
... ...
/**
* 单品日
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/17
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
lazyload = require('yoho-jquery-lazyload'),
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 $productList = $('.product-list');
var getFlag = false;
var getProductData = function(index, tabName) {
if (getFlag) {
return;
}
getFlag = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/activity/single-day/getProductData',
data: {
tab_name: tabName
},
success: function(data) {
var $productTab = $('.product-tab');
if (data) {
$productTab.eq(index).append(product(data));
}
$productTab.hide().eq(index).show();
lazyload($('img.lazy'));
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, $swiperTab, $productTab;
var tabNum = window.queryString.tabNum ? window.queryString.tabNum - 1 : 0;
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]));
$swiperTab = $('.swiper-tab li');
new Swiper('.swiper-tab', {
slidesPerView: 'auto'
});
for (i; i < data[1].length; i++) {
$productList.append('<ul class="product-tab"></ul>');
}
$productTab = $('.product-tab');
getProductData(tabNum, tabName(tabNum));
$swiperTab.eq(tabNum).addClass('active');
$swiperTab.on('click', function() {
var index = $(this).index();
$swiperTab.removeClass('active').eq(index).addClass('active');
if ($productTab.eq(index).find('li').length > 0) {
$productTab.hide().eq(index).show();
} else {
getProductData(index, tabName(index));
}
});
}
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
}
});
};
require('../common');
require('../common/share');
$(function() {
loading.showLoadingMask();
getInitData();
});
... ...
... ... @@ -83,7 +83,7 @@ if (qs && qs.share_id) {
dataType: 'jsonp',
success: function(res) {
if (res && res.code === 200 && res.data) {
shareData.desc = res.data.content;
shareData.desc = res.data.content || res.data.title;
shareData.imgUrl = res.data.pic;
shareData.title = res.data.title;
}
... ...
... ... @@ -4,6 +4,7 @@
@import "student";
@import "market/index";
@import "shop-collect/shop-collect";
@import "single-day";
.receive-coupon-page {
* {
... ... @@ -11,16 +12,19 @@
padding: 0;
font-size: 14px;
}
.bg-contain {
width: 100%;
height: 100%;
position: absolute;
background: #c4211a;
img {
width: 100%;
height: auto;
}
}
.page {
width: 100%;
height: auto;
... ... @@ -29,6 +33,7 @@
top: 0;
bottom: 0;
}
.coupon-centent,
.gain-coupon-centent {
margin-top: 428px !important;
... ... @@ -39,8 +44,10 @@
overflow: hidden;
border-radius: 0.3rem;
}
.coupon-centent {
position: relative;
.title {
position: absolute;
top: 40px;
... ... @@ -50,16 +57,19 @@
height: 57px;
background: url("../img/coupon/coupon-title.png");
}
.under-title {
position: absolute;
top: 100px;
width: 100%;
height: 463px;
}
.input-content {
height: 206px;
margin: 30px 30px 0;
position: relative;
input {
height: 88px;
width: 100%;
... ... @@ -72,6 +82,7 @@
text-align: center;
outline: none;
}
div {
height: 88px;
width: 100%;
... ... @@ -82,12 +93,14 @@
color: #e0e0e0;
line-height: 88px;
}
.verification-code,
.get {
background: #fff;
color: #444;
}
}
.clear-input {
position: absolute;
padding: 10px;
... ... @@ -97,11 +110,13 @@
color: #666;
z-index: 1;
}
.coupon-description {
width: 100%;
height: 136px;
position: relative;
background: url("../img/coupon/coupon-footer.png");
span {
position: absolute;
bottom: 0;
... ... @@ -111,6 +126,7 @@
}
}
}
.gain-coupon-centent {
p {
width: 100%;
... ... @@ -120,11 +136,13 @@
color: #fff;
font-size: 17px;
}
p.phone {
margin-top: 10px;
font-size: 30px;
font-weight: bold;
}
.coupon {
padding-top: 50px;
width: 90%;
... ... @@ -132,10 +150,12 @@
height: 220px;
background: #9d1a15;
}
.coupon img {
width: 100%;
height: auto;
}
.use-coupon-btn {
height: 88px;
line-height: 88px;
... ... @@ -145,6 +165,7 @@
text-align: center;
border-radius: 4px;
}
span {
font-weight: bold;
display: inline-block;
... ... @@ -156,11 +177,13 @@
margin: 0 40%;
background: url("../img/coupon/activity-description.png");
}
a {
color: #fff;
font-size: 28px;
}
}
.dialog {
width: 84%;
height: 410px;
... ... @@ -171,6 +194,7 @@
top: 235px;
z-index: 2;
}
.dialog .close {
width: 40px;
height: 40px;
... ... @@ -183,13 +207,16 @@
line-height: 40px;
text-align: center;
}
.hidden {
display: none;
}
.phone-error {
text-align: center;
line-height: 14rem;
}
.mask {
width: 100%;
height: 100%;
... ... @@ -201,11 +228,13 @@
left: 0;
z-index: 1;
}
.activity-message {
width: 100%;
height: 410px;
overflow: scroll;
}
.activity-message h3 {
width: 100%;
height: 40px;
... ... @@ -215,6 +244,7 @@
font-size: 32px;
text-align: center;
}
.activity-message p {
width: 85%;
height: auto;
... ... @@ -225,6 +255,7 @@
padding-left: 26px;
text-indent: -26px;
}
.messages {
width: 84%;
height: 4rem;
... ... @@ -237,10 +268,12 @@
z-index: 2;
color: #fff;
}
.messages p {
line-height: 4rem;
font-size: 24px;
}
.tip-wrap {
width: 100%;
height: 100%;
... ... @@ -250,6 +283,7 @@
left: 0;
z-index: 3;
}
.tip {
width: 100%;
height: 100%;
... ... @@ -257,6 +291,7 @@
position: absolute;
top: 0;
left: 0;
.header {
width: 170px;
height: 170px;
... ... @@ -265,6 +300,7 @@
margin-right: auto;
background: url("../img/coupon/unfortunately.png");
}
.title {
margin-top: 30px;
font-size: 28px;
... ... @@ -273,6 +309,7 @@
margin-left: auto;
margin-right: auto;
}
.logo {
width: 391px;
height: 78px;
... ... @@ -281,10 +318,12 @@
margin-right: auto;
background: url("../img/coupon/logo.png");
}
.desc {
font-size: 24px;
color: #444;
}
.button {
display: block;
margin: 30px auto;
... ...
.single-day-page {
overflow: hidden;
.banner {
width: 100%;
height: 234px;
.swiper-slide {
height: 234px;
}
}
.swiper-tab {
height: 86px;
border-bottom: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0;
ul {
margin-top: 28px;
}
li {
float: left;
padding: 0 50px;
border-right: 1px solid #e0e0e0;
height: 30px;
line-height: 30px;
color: #b0b0b0;
width: auto;
font-size: 28px;
}
li:last-child {
border-right: none;
}
.active {
color: #444;
}
}
.product-list {
ul {
width: 720px;
margin-left: 30px;
padding-top: 30px;
height: auto;
overflow: hidden;
}
li {
margin-bottom: 14px;
height: auto;
overflow: hidden;
.lazy {
width: 322px;
height: 429px;
float: left;
margin-right: 27px;
}
}
.product-info {
width: 370px;
height: 445px;
float: left;
position: relative;
border-bottom: 1px solid #e8e8e8;
padding-right: 30px;
box-sizing: border-box;
}
p {
width: 340px;
}
h3 {
margin-top: 50px;
font-size: 28px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
color: #444;
}
.prompt-info {
font-size: 22px;
margin-top: 29px;
color: #d11226;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.price {
margin-top: 29px;
}
.sale-price {
font-size: 30px;
color: #cf031e;
}
.no-price {
color: #000;
}
.market-price {
font-size: 30px;
color: #b0b0b0;
text-decoration: line-through;
margin-left: 24px;
}
.info-txt {
position: absolute;
bottom: 62px;
font-size: 22px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
color: #454545;
}
}
}
... ...
{{#each this}}
<li >
<a href="{{url}}">
<img class="lazy" data-original="{{image productLink 322 429}}"/>
<div class="product-info">
<h3>{{productTitle}}</h3>
{{#salesPhrase}}
<p class="prompt-info">{{.}}</p>
{{/salesPhrase}}
<p class="price">
<span class="sale-price {{^marketPrice}}no-price{{/marketPrice}}">¥{{salesPrice}}</span>
{{#marketPrice}}
<span class="market-price">¥{{.}}</span>
{{/marketPrice}}
</p>
<p class="info-txt">{{productDesc}}</p>
</div>
</a>
</li>
{{/each}}
... ...
<ul class="swiper-wrapper">
{{#each this}}
<li class="swiper-slide">{{.}}</li>
{{/each}}
</ul>
... ...
<div class="banner-top">
<div class="banner-swiper swiper-container">
<ul class="swiper-wrapper">
{{#each data}}
{{#if @first}}
<li class="swiper-slide">
<a href="{{url}}">
<img src="{{image src 640 240}}">
</a>
</li>
{{^}}
<li class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{image src 640 240}}">
</a>
<div class="swiper-lazy-preloader"></div>
</li>
{{/if}}
{{/each}}
</ul>
</div>
<div class="swiper-pagination">
<div class="pagination-inner">
</div>
</div>
</div>
... ...