Authored by 陈峰

Merge branch 'master' into hotfix/rss-format

... ... @@ -9,12 +9,13 @@ const crypto = global.yoho.crypto;
const shopIndex = (req, res) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = req.user.uid || req.query.uid;
let contentCode = req.query.code || 'ec9eb72eae121fcd6c1b7d1de75caff1';
let parameter = {};
if (!isApp) {
parameter = {
pageHeader: headerModel.setNav({
navTitle: '店铺收藏'
navTitle: req.query.title || '店铺收藏'
})
};
} else {
... ... @@ -32,13 +33,13 @@ const shopIndex = (req, res) => {
}
}
shopModel.banner().then((result) => {
shopModel.banner(contentCode).then((result) => {
res.render('shop-collect/index', Object.assign({
module: 'activity',
page: 'shop-collect',
wechatShare: true,
title: '店铺收藏',
title: req.query.title || '店铺收藏',
width750: true,
showHeader: !req.yoho.isWechat,
shopCollect: {
bannerTop: result
}
... ... @@ -47,27 +48,33 @@ const shopIndex = (req, res) => {
};
const shopNav = (req, res, next) => {
let channelId = req.query.channelId || '';
shopModel.shopNav().then((result) => {
shopModel.shopNav(channelId).then((result) => {
res.json(result);
}).catch(next);
};
const shopList = (req, res, next) => {
let uid = _.trim(crypto.decrypt('', req.query.uid)) || req.user.uid;
let uid = parseInt(crypto.decrypt('', req.query.uid), 10) || req.user.uid;
let tabName = req.query.tabName;
let channelId = req.query.channelId || '';
shopModel.shopList(uid, tabName).then((result) => {
shopModel.shopList(uid, tabName, channelId).then((result) => {
res.json(result);
}).catch(next);
};
// 获取文章收藏状态
// 获取店铺收藏状态
const shopFav = (req, res, next) => {
let uid = req.query.uid ? _.trim(crypto.decrypt('', req.query.uid)) : req.user.uid;
let uid = req.query.uid ? parseInt(crypto.decrypt('', req.query.uid), 10) : req.user.uid;
let shopIds = req.query.shopIds;
if (!uid) {
return;
}
shopModel.shopFav(uid, shopIds).then((result) => {
res.json(result);
}).catch(next);
... ...
... ... @@ -6,16 +6,20 @@
'use strict';
const singleDayModel = require('../models/single-day');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const singleDay = (req, res) => {
let title = req.query.title;
res.render('single-day/single-day', {
module: 'activity',
page: 'single-day',
title: '超级单品日',
title: title || '超级单品日',
isApp: req.yoho.isApp,
width750: true,
showHeader: !req.yoho.isWechat,
pageHeader: headerModel.setNav({
navTitle: '超级单品日',
navTitle: title || '超级单品日',
navBtn: false
}),
pageFooter: false
... ... @@ -23,13 +27,25 @@ const singleDay = (req, res) => {
};
const getSingleData = (req, res) => {
Promise.all([singleDayModel.getResourceData(), singleDayModel.getTabData()]).then((result) => {
Promise.all([
singleDayModel.getResourceData(req.query.contCode),
singleDayModel.getTabData(req.query.channel_id)
]).then((result) => {
_.forEach(result[0], (item) => {
if (item.focus) {
_.forEach(item.data, (banner) => {
banner.url = 'javascript:void(0)'; //eslint-disable-line
});
}
});
res.json(result);
});
};
const getProductData = (req, res) => {
singleDayModel.getProductData(req.query.tab_name).then(result => {
let params = req.query || {};
singleDayModel.getProductData(params).then(result => {
res.json(result);
});
};
... ...
... ... @@ -9,12 +9,24 @@ const _ = require('lodash');
const logger = global.yoho.logger;
const service = global.yoho.ServiceAPI;
const shopList = (uid, tabName) => {
return api.get('', {
method: 'app.shops.promote',
uid: uid,
tab_name: tabName
}, {
const shopList = (uid, tabName, channelId) => {
let params = {
method: 'app.shops.promote'
};
if (uid) {
params.uid = uid;
}
if (tabName) {
params.tab_name = tabName;
}
if (channelId) {
params.channel_id = channelId;
}
return api.get('', params, {
code: 200
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -38,15 +50,20 @@ const shopList = (uid, tabName) => {
});
};
const shopNav = () => {
return api.get('', {
const shopNav = (channelId) => {
let params = {
method: 'app.shops.promoteTabNameList'
}, {
};
if (channelId) {
params.channel_id = channelId;
}
return api.get('', params, {
cache: true,
code: 200
}).then((result) => {
if (result.data) {
if (result.data.length === 1 && result.data[0] === 'NULL') {
if (result.data.length === 0 || (result.data.length === 1 && result.data[0] === 'NULL')) {
return false;
} else {
return result.data;
... ... @@ -55,9 +72,9 @@ const shopNav = () => {
});
};
const banner = () => {
const banner = (contentCode) => {
return service.get('operations/api/v5/resource/get', {
content_code: 'ec9eb72eae121fcd6c1b7d1de75caff1',
content_code: contentCode,
platform: 'iphone'
}, {
cache: true,
... ...
... ... @@ -12,9 +12,9 @@ const helpers = global.yoho.helpers;
const _ = require('lodash');
const resourcesProcess = require(`${utils}/resources-process`);
const getResourceData = () => {
const getResourceData = (contCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: 'c0acf0296a3c329678fb45da958d9951',
content_code: contCode || 'c0acf0296a3c329678fb45da958d9951',
platform: 'iphone'
}, {
cache: true
... ... @@ -28,23 +28,27 @@ const getResourceData = () => {
});
};
const getProductData = (tabName) => {
return api.get('', {
const getProductData = (params) => {
return api.get('', _.assign({
method: 'app.product.singleDay',
tab_name: tabName
}, {
limit: '20'
}, params), {
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
if (result.data.length === 0) {
return '';
} else {
_.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;
return result.data;
}
} else {
logger.error('get product data code no 200');
return [];
... ... @@ -54,9 +58,10 @@ const getProductData = (tabName) => {
// 获取活动tab标签
const getTabData = () => {
const getTabData = (channelId) => {
return api.get('', {
method: 'app.product.singleDayTabNameList'
method: 'app.product.singleDayTabNameList',
channel_id: channelId
}, {
cache: true
}).then((result) => {
... ...
... ... @@ -17,7 +17,6 @@ const live = require(`${cRoot}/live`);
const invite = require(`${cRoot}/invite`);
const couponFloor = require(`${cRoot}/coupon-floor`);
const auth = require('../../doraemon/middleware/auth');
const vipDay = require(`${cRoot}/vipDay`);
const vipDay1028 = require(`${cRoot}/vipDay10`);
const market = require(`${cRoot}/market`);
... ... @@ -117,12 +116,4 @@ router.get('/vip-day1028/crazy-luck', vipDay1028.beforeIn, vipDay1028.crazyLuck)
router.post('/vip-day1028/signin.json', vipDay1028.beforeIn, vipDay1028.signin);
router.post('/vip-day1028/isStudent', vipDay1028.beforeIn, vipDay1028.checkIsStudent);
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('/share', share.getShareContent);
module.exports = router;
... ...
... ... @@ -4,7 +4,9 @@
{{> resources/banner-top}}
{{/ bannerTop}}
<div class="shop-nav nav"></div>
<div class="shop-nav nav">
<div class="shop-area"></div>
</div>
<div class="shop-list"></div>
{{/ shopCollect}}
... ...
<div class="single-day-page yoho-page">
<div class="banner"></div>
<div class="swiper-tab"></div>
<div class="tab-area">
<div class="swiper-tab"></div>
</div>
<div class="product-list"></div>
</div>
... ...
... ... @@ -18,7 +18,7 @@ const hotfix = require(`${cRoot}/hotfix`);
// routers
router.post('/upload/image', multipartMiddleware, uploadApi.uploadImg);
router.post('/api/upload/image', multipartMiddleware, uploadApi.uploadImg);
router.post('/hf/v1', hotfix.v1);
module.exports = router;
... ...
... ... @@ -85,6 +85,8 @@ const _genIntro = (id) => {
result += '<br/>';
}
});
result += `<a href="http://guang.m.yohobuy.com/info/index?id=${id}">查看原文</a>`;
return result;
}
});
... ... @@ -92,4 +94,4 @@ const _genIntro = (id) => {
};
module.exports = {
getRssArticle
};
\ No newline at end of file
};
... ...
... ... @@ -63,6 +63,8 @@ const common = {
if (!refer) {
refer = req.get('Referer');
}
refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), {
domain: 'yohobuy.com'
});
... ...
... ... @@ -28,18 +28,6 @@ class PhoneService {
// 发送 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/发送验证码.md
static sendSMS(mobile, area, type) {
if (process.env.NODE_ENV === 'development') {
return new Promise((resolve, reject) => {
return resolve({
alg: 'SALT_MD5',
code: 200,
data: {},
md5: '6d729d4b35f10fc73531210bd7ecff91',
message: '发送成功.'
});
});
}
return API.get('', {
method: 'app.message.sendSms',
mobile,
... ... @@ -51,20 +39,6 @@ class PhoneService {
// 校验 验证码
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/验证验证码.md
static verifySMS(mobile, area, code, type) {
if (process.env.NODE_ENV === 'development') {
return new Promise((resolve, reject) => {
return resolve({
alg: 'SALT_MD5',
code: 200,
data: {
is_pass: 'Y'
},
md5: '6d729d4b35f10fc73531210bd7ecff91',
message: '发送成功.'
});
});
}
return API.get('', {
method: 'app.message.verifySmsCode',
mobile,
... ...
... ... @@ -36,15 +36,15 @@ router.get('/passport/international', login.common.beforeLogin, login.local.inte
router.post('/passport/login/auth', login.local.login);
// SMS 短信
router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
router.get('/passport/sms_login', smsLogin.loginPage);
router.get('/passport/sms_login/token.json',
smsLogin.tokenBefore,
smsLogin.token); // only ajax;
router.get('/passport/sms_login/check.json',
smsLogin.checkBefore,
smsLogin.check); // only ajax
router.post('/passport/sms_login/password.json', smsLogin.password);
// router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
// router.get('/passport/sms_login', smsLogin.loginPage);
// router.get('/passport/sms_login/token.json',
// smsLogin.tokenBefore,
// smsLogin.token); // only ajax;
// router.get('/passport/sms_login/check.json',
// smsLogin.checkBefore,
// smsLogin.check); // only ajax
// router.post('/passport/sms_login/password.json', smsLogin.password);
// 微信登录
router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login);
... ...
... ... @@ -10,7 +10,7 @@
</div>
<span id="btn-login" class="btn btn-login disable">登录</span>
<p class="op-container">
<a class="sms-login" href={{smsLoginUrl}}>手机号码快捷登录</a>
{{!--<a class="sms-login" href={{smsLoginUrl}}>手机号码快捷登录</a>--}}
<span id="forget-pwd" class="forget-pwd">忘记密码</span>
</p>
<div class="third-party-login">
... ...
... ... @@ -397,7 +397,7 @@ const favoriteBrand = (req, res, next) => {
let opt = req.query.opt || 'ok';
let type = req.query.type || 'product';
let appVersion = req.query.appVersion || false;
let refer = req.get('referer');
let refer = encodeURIComponent(req.get('referer'));
let url = helpers.urlFormat('/signin.html') + '?refer=' + refer;
... ... @@ -405,7 +405,7 @@ const favoriteBrand = (req, res, next) => {
if (appVersion && appVersion !== 'false') {
uid = req.query.uid ? crypto.decrypt('', req.query.uid) : req.cookies.appUid;
uid = _.trim(uid);
uid = parseInt(uid, 10);
if (!uid || uid === 'undefined') {
uid = _getUidFromUserAgent(req);
... ...
... ... @@ -12,6 +12,11 @@ const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header');
const seckillModel = require(`${mRoot}/seckill`);
let headerData = headerModel.setNav({
navTitle: '秒杀活动',
navBtn: true,
});
/**
* [时间缺0补0]
*/
... ... @@ -105,32 +110,31 @@ function fetchProductList(activityInfo, uid) {
/**
* [秒杀列表页面]
*/
const index = (req, res, next) => {
let focusTime = Number.parseInt(req.query.time, 10) || 0;
let headerData = headerModel.setNav({
navTitle: '秒杀活动',
navBtn: true,
const index = (req, res) => {
return res.render('seckill', {
title: '秒杀活动',
pageHeader: headerData,
pageStyle: 'seckill-page',
pageFooter: true,
width750: true,
});
};
if (!req.xhr) {
return res.render('seckill', {
title: '秒杀活动',
pageHeader: headerData,
pageStyle: 'seckill-page',
pageFooter: true,
width750: true,
});
}
/**
* [秒杀列表 页面 初始数据]
*/
const indexData = (req, res, next) => {
let focusTime = Number.parseInt(req.query.time, 10) || 0;
let result = {};
let uid = req.yoho.isApp && req.query.uid;
return seckillModel.queryActivity().then((resultActivity) => {
// console.log(resultActivity)
let focusIndex = false;
// let nowTime = Date.now();
if (!resultActivity.data) {
return next();
return next();
}
result.currentTime = resultActivity.data.currentTime * 1000;
if (resultActivity.code !== 200) {
... ... @@ -226,6 +230,7 @@ const index = (req, res, next) => {
res.json(result);
});
});
};
/**
... ... @@ -331,6 +336,7 @@ const checkAppVer = function(okVersion) {
module.exports = {
index,
indexData,
getProductList,
remind,
checkAppVer
... ...
... ... @@ -276,7 +276,7 @@ const searchKeyActivity = (params) => {
cache: true,
code: 200
}).then(result => {
if (result.data) {
if (result && result.data) {
return result.data;
} else {
return {};
... ...
... ... @@ -95,6 +95,7 @@ router.get('/recommend-for-you/cart', recommendForYou.cart);
router.get('/seckill', seckill.checkAppVer('5.1.0'), seckill.index); // 秒杀列表页
router.get('/seckill/list', seckill.indexData);
router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒
router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表
... ...
... ... @@ -32,7 +32,7 @@ const cachePage = {
// 领券中心
'/activity/coupon/floor': 5 * MINUTE,
'/activity/coupon/floor': 1 * MINUTE,
// 商品列表
'/product/list/index': 1 * MINUTE,
... ...
... ... @@ -11,9 +11,9 @@ module.exports = app => {
// 四个频道页,频道选择页面 /boys,/girls,/,/kids,/lifestyle 等页面,就直接占用路由了
app.use(require('./apps/channel'));
app.use(require('./apps/passport'));
app.use(require('./apps/api')); // 一些只返回json的通用api
// 业务模块
app.use('/api', require('./apps/api')); // 各模块公有 API
app.use('/product', require('./apps/product'));
app.use('/guang', require('./apps/guang'));
app.use('/activity', require('./apps/activity'));
... ... @@ -21,7 +21,4 @@ module.exports = app => {
// 分期付款
app.use('/home', require('./apps/home'));
// 一些只返回json的通用api
app.use('/', require('./apps/api'));
};
... ...
... ... @@ -33,6 +33,7 @@ module.exports = () => {
}
res.locals.cartUrl = helpers.urlFormat('/cart/index/index');
res.locals.showHeader = true;
next();
};
... ...
... ... @@ -56,9 +56,11 @@
{{> updata}}
{{/if}}
{{#unless isApp}}
{{> header}}
{{/unless}}
{{#if showHeader}}
{{#unless isApp}}
{{> header}}
{{/unless}}
{{/if}}
{{{body}}}
... ...
{
"name": "m-yohobuy-node",
"version": "5.1.3",
"version": "5.1.6",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -3,3 +3,4 @@
<li class="swiper-slide">{{.}}</li>
{{/each}}
</ul>
... ...
var $ = require('yoho-jquery'),
loading = require('../../plugin/loading'),
tip = require('../../plugin/tip'),
... ... @@ -21,13 +20,15 @@ inviteObj = {
// 变量
inter: 0, // 定时器变量
ischeckCode: false, // 是否成功发送验证码
actId: $('.invite-group input[name="actId"]').val(), // 活动id
shareUid: $('.invite-group input[name="shareUid"]').val(), // 分享者id
openId: $('.invite-group input[name="openId"]').val(), // 微信openId
actId: $('.invite-group input[name="actId"]').val(), // 活动id
shareUid: $('.invite-group input[name="shareUid"]').val(), // 分享者id
openId: $('.invite-group input[name="openId"]').val(), // 微信openId
nums: $('.invite-group input[name="nums"]').val() // 发送优惠券的次数
},
init: function() {
var $el = this.el, that = this, isreceiveBtn = false;
var $el = this.el,
that = this,
isreceiveBtn = false;
// 设置大背景,因为body只能后来设置,前期设置page里面
if ($('.invite-page').length > 0) {
... ... @@ -91,7 +92,7 @@ inviteObj = {
// 下载app
$el.$downloadBtn.click(function() {
that.downLoadApp();
window.downLoadApp();
});
// 领取福利
... ... @@ -109,7 +110,8 @@ inviteObj = {
// 发送已注册用户参与活动的优惠券
ischeckOldUserCoupon: function(mobile) {
var that = this, $el = this.el;
var that = this,
$el = this.el;
$.ajax({
url: '/activity/invite/checkOldUserCoupon',
... ... @@ -317,15 +319,6 @@ inviteObj = {
$('.invite-dialog-bg').remove();
$el.$inviteDialog.hide();
that.clearGrayInfo();
},
// 下载app
downLoadApp: function() {
var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
setTimeout(function() {
window.location = appUrl;
}, 200);
}
};
... ...
... ... @@ -15,7 +15,8 @@ var searching,
navType,
appVersion = $('input[name="app_version"]').val(),
uid = $('input[name="uid"]').val(),
ids = [];
ids = [],
channelId;
var shopNav = require('shopCollect/shop-nav.hbs'),
shopList = require('shopCollect/shop-list.hbs');
... ... @@ -24,6 +25,7 @@ require('../common');
require('../common/share');
navType = window.queryString;
channelId = window.queryString.channel_id;
function shopFav(shopIds) {
return $.ajax({
... ... @@ -67,7 +69,8 @@ function shopListData(tabName, stoping) {
url: '/activity/shopList',
data: {
tabName: tabName,
uid: uid || ''
uid: uid || '',
channelId: channelId
},
success: function(data) {
... ... @@ -177,34 +180,33 @@ function shopNavData() {
$.ajax({
method: 'get',
url: '/activity/shopNav',
data: {
channelId: channelId
},
success: function(data) {
var navString = shopNav({
navList: data
});
var tabNum;
if (data === false) {
shopListData('null');
$('.shop-nav').hide();
return;
}
$('.shop-nav').html(navString);
// 导航滑动效果
navSwiper = new Swiper('.shop-nav', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
$('.shop-area').html(navString);
// 加载第一页数据
if (navType.id) {
if (navType.tab_name) {
$('.shop-nav').find('li').each(function() {
if (decodeURI(navType.id) === $(this).data('type')) {
if (decodeURI(navType.tab_name) === $(this).data('type')) {
$(this).addClass('active');
shopListData($(this).data('type'));
tabNum = $(this).index();
}
});
} else {
... ... @@ -212,10 +214,33 @@ function shopNavData() {
shopListData($('.shop-nav').find('li').eq(0).data('type'));
}
// 导航滑动效果
navSwiper = new Swiper('.shop-area', {
grabCursor: true,
slidesPerView: 'auto',
initialSlide: tabNum,
slideElement: 'li'
});
if (tabNum < 3) {
$('.shop-area ul').css({
transform: 'translateX(0px)'
});
}
$(window).on('scroll touchmove touchstart touchend', function() {
if ($(window).scrollTop() > $('.shop-nav')[0].offsetTop) {
$('.shop-area').addClass('fixer');
} else {
$('.shop-area').removeClass('fixer');
}
});
// 导航点击事件
$('.shop-nav').find('li').on('click', function() {
var $this = $(this),
tabName = $this.data('type');
tabName = $this.data('type'),
$top = $('.shop-nav')[0].offsetTop;
if ($this.hasClass('active')) {
stoping = true;
... ... @@ -226,6 +251,10 @@ function shopNavData() {
shopListData(tabName, stoping);
$this.addClass('active').siblings().removeClass('active');
if ($('.shop-area').hasClass('fixer')) {
$(window).scrollTop($top);
}
});
},
... ...
... ... @@ -8,119 +8,208 @@ var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
lazyload = require('yoho-jquery-lazyload'),
banner = require('../../hbs/resources/banner-top.hbs'),
tab = require('../../hbs/activity/single-day/tab.hbs'),
product = require('../../hbs/activity/single-day/product-list.hbs');
banner = require('resources/banner-top.hbs'),
tab = require('activity/single-day/tab.hbs'),
product = require('activity/single-day/product-list.hbs');
var singleDay = {
initParams: function() {
var self = this,
opt = {
$productList: $('.product-list'),
$swiper: $('.swiper-tab'),
getFlag: false,
previousScrollTop: 0,
winH: $(window).height(),
noResult: '<p class="no-result">未找到相关商品</p>',
page: 0,
contCode: window.queryString.code || '',
channelId: window.queryString.channel_id
};
self.swiperOTop = opt.$swiper[0].offsetTop;
$.extend(self, opt);
},
getInitData: function() {
var self = this;
var _scrollHandler;
self.initParams();
_scrollHandler = function() {
var curScrollTop = $(window).scrollTop(),
index = $('.swiper-tab .active').index(),
curHeight = self.$productList.find('ul').eq(index).height();
// 当scroll到1/4$goodsContainer高度后继续请求下一页数据
if (curScrollTop > self.previousScrollTop &&
(curScrollTop + self.winH >
$(document).height() - 0.25 * curHeight - 50)) {
self.getProductData({
index: index,
tabName: self.tabName(index),
isScroll: true
});
}
var $productList = $('.product-list');
var getFlag = false;
self.previousScrollTop = curScrollTop;
};
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));
$(window).on('scroll touchmove touchstart touchend', function() {
if ($(window).scrollTop() > self.swiperOTop) {
self.$swiper.addClass('fixer');
} else {
self.$swiper.removeClass('fixer');
}
$productTab.hide().eq(index).show();
window.requestAnimationFrame(_scrollHandler.bind(self));
});
$.ajax({
type: 'GET',
url: '/activity/single-day/getSingleData',
data: {
channel_id: self.channelId,
contCode: self.contCode
},
success: function(data) {
var i = 0, $swiperTab;
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'
});
}
}
lazyload($('img.lazy'));
getFlag = false;
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
loading.hideLoadingMask();
getFlag = false;
}
});
};
if (data[1]) {
$('.swiper-tab').append(tab(data[1]));
var tabName = function(index) {
return $('.swiper-tab li').eq(index).html();
};
$swiperTab = $('.swiper-tab li');
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'
new Swiper('.swiper-tab', {
initialSlide: tabNum,
slidesPerView: 'auto'
});
}
}
if (data[1]) {
$('.swiper-tab').append(tab(data[1]));
if (tabNum < 3) {
$('.swiper-tab ul').css({
transform: 'translateX(0px)'
});
}
$swiperTab = $('.swiper-tab li');
for (i; i < data[1].length; i++) {
self.$productList.append('<ul class="product-tab" data-page="0"></ul>');
}
new Swiper('.swiper-tab', {
slidesPerView: 'auto'
});
self.$productTab = $('.product-tab');
for (i; i < data[1].length; i++) {
$productList.append('<ul class="product-tab"></ul>');
}
self.getProductData({
index: tabNum,
tabName: self.tabName(tabNum)
});
$swiperTab.eq(tabNum).addClass('active');
$productTab = $('.product-tab');
$swiperTab.on('click', function() {
var index = $(this).index();
getProductData(tabNum, tabName(tabNum));
$swiperTab.eq(tabNum).addClass('active');
$swiperTab.removeClass('active').eq(index).addClass('active');
$swiperTab.on('click', function() {
var index = $(this).index();
if (self.$productTab.eq(index).find('li').length > 0) {
self.$productTab.hide().eq(index).fadeIn();
} else {
self.getProductData({
index: index,
tabName: self.tabName(index)
});
}
});
}
$swiperTab.removeClass('active').eq(index).addClass('active');
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
}
});
},
tabName: function(index) {
return $('.swiper-tab li').eq(index).html();
},
getProductData: function(params) {
var self = this;
var page;
var curProductTab = self.$productTab.eq(params.index);
if (self.getFlag) {
return false;
}
if ($productTab.eq(index).find('li').length > 0) {
$productTab.hide().eq(index).show();
page = +curProductTab.attr('data-page') + 1;
self.getFlag = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/activity/single-day/getProductData',
data: {
tab_name: params.tabName || '',
channel_id: self.channelId,
page: page
},
success: function(data) {
if (data) {
curProductTab.find('.no-result').hide();
curProductTab.append(product(data));
curProductTab.attr('data-page', page);
self.getFlag = false;
} else {
if (page === 1) {
if (curProductTab.find('.no-result').length === 0) {
curProductTab.append(self.noResult);
}
self.getFlag = false;
} else {
getProductData(index, tabName(index));
self.getFlag = true;
}
}
if (!params.isScroll) {
self.$productTab.hide().eq(params.index).fadeIn();
}
$('img.lazy').lazyload({
effect: 'fadeIn'
});
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
loading.hideLoadingMask();
self.getFlag = false;
}
loading.hideLoadingMask();
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
};
require('../common');
require('../common/share');
require('yoho-jquery-lazyload');
$(function() {
loading.showLoadingMask();
getInitData();
singleDay.getInitData();
});
... ...
... ... @@ -203,8 +203,8 @@ $.extend({
$footer.removeClass('hide');
// 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息
if (queryString().mkt_code) {
setCookie('unionType', queryString().mkt_code);
if (queryString().union_type) {
setCookie('unionTypeYas', queryString().union_type, {path: '/'});
}
}());
... ... @@ -307,6 +307,31 @@ if ($footer.find('.user-name').text().length === 11) {
$footer.find('.user-name').html(phoneHidden($footer.find('.user-name').text()));
}
// 浮层下载APP
function downLoadApp() {
var appUrl = 'http://union.yoho.cn/union/downapp.html';
var clickedAt = new Date();
setTimeout(function() {
var mkt = queryString().union_type || cookie('unionTypeYas') || false;
if ((new Date()) - clickedAt < 2000) {
if (mkt) {
appUrl += '?union_type=' + mkt;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_DOWNLOAD_C',
param: JSON.stringify({C_ID: _ChannelVary[cookie('_Channel')] || 1, TO_URL: appUrl})
}, true);
}
window.location = appUrl;
}
}, 500);
}
// 为您优选埋点 http://redmine.yoho.cn/issues/10117
function givePoint(parameter) {
var CID = 1;
... ... @@ -398,3 +423,5 @@ window.queryString = queryString();
window.givePoint = givePoint;
window._ChannelVary = _ChannelVary;
window.downLoadApp = downLoadApp;
... ...
... ... @@ -78,7 +78,11 @@ function render(data) {
$chosePanel.find('.text-info>.name').text(cartInfo.name);
$chosePanel.find('.sale-price').text(cartInfo.salePrice);
if (!cartInfo.price) {
$chosePanel.find('.sale-price').addClass('no-price');
if (data.isSecKill === 'Y') {
$('.price').append('<span class="market-price">' + cartInfo.salePrice + '</span>');
} else {
$chosePanel.find('.sale-price').addClass('no-price');
}
} else {
$chosePanel.find('.market-price').text(cartInfo.price).removeClass(dbClass);
}
... ...
... ... @@ -7,37 +7,10 @@
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer');
var floatLayerBtnHammer,
C_ID;
var floatLayerBtnHammer;
require('../common');
C_ID = window._ChannelVary[window.cookie('_Channel')] || 1;
function downLoadApp() {
var appUrl = 'http://union.yoho.cn/union/downapp.html';
var clickedAt = new Date();
setTimeout(function() {
var mkt = window.queryString.mkt_code || window.cookie('mkt_code') || false;
if ((new Date()) - clickedAt < 2000) {
if (mkt) {
appUrl += '?union_type=' + mkt;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_DOWNLOAD_C',
param: JSON.stringify({C_ID: C_ID, TO_URL: appUrl})
}, true);
}
window.location = appUrl;
}
}, 500);
}
$('#float-layer-close').on('touchend', function() {
$('#float-layer-app').hide();
window.setCookie('_float-layer-app', 'id490655927',
... ... @@ -55,7 +28,7 @@ $('#float-layer-close').on('touchend', function() {
if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
floatLayerBtnHammer.on('tap', function(e) {
downLoadApp('bottom');
window.downLoadApp('bottom');
e.srcEvent.stopPropagation();
});
... ...
... ... @@ -24,30 +24,6 @@ function getQueryString(name) {
return null;
}
function downLoadApp() {
var appUrl = 'http://union.yoho.cn/union/downapp.html';
var clickedAt = new Date();
setTimeout(function() {
var mkt = window.queryString.mkt_code || window.cookie('unionType') || false;
if ((new Date()) - clickedAt < 2000) {
if (mkt) {
appUrl += '?union_type=' + mkt;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_DOWNLOAD_C',
param: JSON.stringify({C_ID: window._ChannelVary[window.cookie('_Channel')] || 1, TO_URL: appUrl})
}, true);
}
window.location = appUrl;
}
}, 500);
}
$('#float-layer-close').on('touchend', function(e) {
$('#float-layer-app').hide();
window.setCookie('_float-layer-app', 'id490655927',
... ... @@ -65,7 +41,7 @@ $('#float-layer-close').on('touchend', function(e) {
if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
floatLayerBtnHammer.on('tap', function(e) {
downLoadApp('bottom');
window.downLoadApp('bottom');
e.srcEvent.stopPropagation();
});
... ...
... ... @@ -18,6 +18,7 @@ module.exports = function(callback) {
productSkn: productSkn
},
success: function(data) {
// 如果当前是秒杀商品,且不在秒杀路径下,跳到该商品的秒杀详情页
var reg = /\/product\/show_([\d]+)/;
var regPro = /\/product\/pro_([\d]+)_([\d]+)/;
... ... @@ -27,9 +28,12 @@ module.exports = function(callback) {
var thisHref = window.location.href;
var thisRefer = document.referrer;
if (regSeckill.test(thisRefer)) {
// 如果秒杀商品没有吊牌价,显示原销售价
if (data.isSecKill === 'Y' && !data.cartInfo.price) {
$('.previous-price').text(data.cartInfo.salePrice);
}
} else {
if (!regSeckill.test(thisRefer)) {
if (data.isSecKill === 'Y' && (reg.test(thisHref) || regPro.test(thisHref))) {
window.location.replace('/product/seckill/show_' + $('#productSkn').val() + '.html');
}
... ...
... ... @@ -397,8 +397,7 @@ seckillObj = {
loading.show();
$xhr = $.ajax({
url: location.href,
cache: false
url: '/product/seckill/list' + location.search,
})
.done(function(result) {
self.$container.replaceWith(
... ... @@ -417,6 +416,12 @@ seckillObj = {
})
.error(function() {
self.$container.replaceWith(
self.pageTemplate({
error: '系统繁忙.....',
isApp: yoho.isApp
})
);
})
.always(function() {
loading.hide();
... ...
... ... @@ -74,6 +74,7 @@ seckillObj = {
$(
function() {
$('#goodsDiscount').hide();// 隐藏折扣楼层
$('.cart-bar').hide();
$('.current-price').hide();
var ajaxUrl = '/product/seckillDetail/seckillData/' + $('#productSkn').val();
... ... @@ -94,7 +95,6 @@ $(
// $('.current-price').show();
} else {
getMarketPrice();// 获取市场价
// 秒杀开始前
if (data.status === 1) {
$('.cart-bar').before(
... ... @@ -207,6 +207,9 @@ $(
newDay = newDate.getDate();
newHour = newDate.getHours();
newMinus = newDate.getMinutes();
if (newMinus === 0) {
newMinus = '00';
}
$('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus);
seckillObj.startTick(timeObj, offsetTime);
}
... ... @@ -263,32 +266,6 @@ function seckHide() {
);
}
function getMarketPrice() {
var productId = $('#productId').val();
var goodsId = $('#goodsId').val();
var productSkn = $('#productSkn').val();
if (productId && (goodsId || productSkn)) {
$.ajax({
type: 'POST',
url: '/product/detail/info',
data: {
id: productId,
goodsId: goodsId,
productSkn: productSkn
},
success: function(data) {
if (data.goodsPrice.previousPrice) {
$('.previous-price').text(data.goodsPrice.previousPrice);
} else {
$('.previous-price').text(data.goodsPrice.currentPrice);
}
}
});
}
}
function addTimeout(obj) {
obj.append(
'<div class="seckill-time seckill-time-border">' +
... ...
... ... @@ -38,13 +38,13 @@
.main-left {
float: left;
width: 450px;
width: 78%;
height: 160px;
}
.main-right-receive, .main-right-use, .main-right-go {
float: right;
width: 113px;
width: 18%;
height: 160px;
position: relative;
... ... @@ -68,7 +68,7 @@
}
&.received {
width: 113px;
width: 100%;
height: 132px;
background-image: resolve('activity/received.png');
position: absolute;
... ... @@ -77,7 +77,7 @@
}
&.zero {
width: 111px;
width: 100%;
height: 132px;
background-image: resolve('activity/zero.png');
position: absolute;
... ...
... ... @@ -10,28 +10,50 @@
}
}
.swiper-tab {
.fixer {
position: fixed;
top: 0;
z-index: 2;
}
.tab-area {
width: 100%;
height: 86px;
background: #fff;
border-bottom: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0;
}
ul {
margin-top: 28px;
}
.swiper-tab {
width: 100%;
height: 80px;
//border-bottom: 1px solid #e0e0e0;
//border-top: 1px solid #e0e0e0;
//background: #fff;
li {
float: left;
padding: 0 50px;
border-right: 1px solid #e0e0e0;
height: 30px;
line-height: 30px;
height: 80px;
line-height: 80px;
color: #b0b0b0;
width: auto;
font-size: 28px;
background: #fff;
}
li:after {
content: "";
height: 30px;
width: 2px;
border-left: 1px solid #e0e0e0;
position: absolute;
right: 0;
top: 28px;
}
li:last-child {
border-right: none;
li:last-child:after {
border-left: none;
}
.active {
... ... @@ -64,17 +86,30 @@
.product-info {
width: 370px;
height: 445px;
float: left;
float: right;
position: relative;
border-bottom: 1px solid #e8e8e8;
padding-right: 30px;
box-sizing: border-box;
}
li:last-child .product-info {
border-bottom: none;
}
p {
width: 340px;
}
.no-result {
width: 100%;
text-align: center;
vertical-align: middle;
color: #ccc;
font-size: 1.2em;
margin-top: 320px;
}
h3 {
margin-top: 50px;
font-size: 28px;
... ... @@ -100,7 +135,7 @@
}
.sale-price {
font-size: 30px;
font-size: 34px;
color: #cf031e;
}
... ... @@ -118,7 +153,7 @@
.info-txt {
position: absolute;
bottom: 62px;
font-size: 22px;
font-size: 26px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
... ...
... ... @@ -6,8 +6,6 @@
background: #fff;
box-sizing: border-box;
overflow: hidden;
background: #fff;
border-bottom: 1px solid #e0e0e0;
margin-bottom: 30px;
li {
... ... @@ -30,11 +28,16 @@
.active {
color: #000;
}
.shop-area {
background: #fff;
border-bottom: 1px solid #e0e0e0;
min-width: 750px;
}
}
.shop-list {
width: 100%;
/* padding-top: 30px;*/
.shop-info {
background: #fff;
... ... @@ -124,8 +127,15 @@
.content {
width: 750px;
height: 330px;
height: 329px;
}
}
}
.fixer {
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
}
... ...