Authored by 王水玲

Merge branch 'feature/sale' of git.yoho.cn:fe/yohobuywap-node into feature/sale

... ... @@ -40,7 +40,6 @@ const getUserStatus = (param) => {
var dest = {};
dest.code = param.code;
dest.title = param.data.h5Title;
dest.returnCode = param.data.returnCode;
dest.mobile = param.data.mobile;
if (param.data.returnCode === 0) {
... ...
... ... @@ -18,7 +18,7 @@
<div class="page">
<div class="gain-coupon-centent hidden">
<div class="coupon">
<img src={{couponPic}}>
<img src={{image couponPic}}>
</div>
<p class="phone" id="mobile"></p>
<p>登录Yoho!Buy有货客户端即可使用</p>
... ...
<div class="star-page yoho-page">
{{> star/head-tab}}
<div class="swiper-num swiper-num1"></div>
<div class="swiper-num swiper-num2"></div>
<div class="swiper-num swiper-num3"></div>
<div class="loading-tip">下拉刷新</div>
<div class="star-main">
<div class="main-content">
... ...
... ... @@ -26,7 +26,7 @@ function doPassportCallback(openId, nickname, sourceType, req, res) {
refer = `${config.siteUrl}/home`;
}
if (/sign|login/.test(refer)) {
if (/signin|login/.test(refer)) {
refer = `${config.siteUrl}/home`;
}
if (openId && nickname) {
... ... @@ -55,7 +55,7 @@ const common = {
if (!refer) {
refer = req.get('Referer');
}
refer && res.cookie('refer', encodeURI(refer), {
refer && !/signin|login/.test(refer) && res.cookie('refer', encodeURI(refer), {
domain: 'yohobuy.com'
});
next();
... ...
... ... @@ -54,14 +54,16 @@ class Auth {
let uidCookie = `${data.profile_name}::${data.uid}::${data.vip_info.title}::${token}`;
res.cookie('_UID', uidCookie, {
domain: 'yohobuy.com'
domain: 'yohobuy.com',
expires: new Date(Date.now() + 2592000000) // 有效期一年
});
}
req.session._TOKEN = token;
req.session._LOGIN_UID = uid;
res.cookie('_TOKEN', token, {
domain: 'yohobuy.com'
});
domain: 'yohobuy.com',
expires: new Date(Date.now() + 2592000000) // 有效期一年
}); // esline-disable-line
});
}
}
... ...
... ... @@ -11,8 +11,6 @@ const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header');
const saleModel = require(`${mRoot}/sale`);
const helpers = global.yoho.helpers;
// const queryParam = {
// brand: '0',
// gender: '1,2,3',
... ... @@ -47,17 +45,6 @@ const _processPublicData = (req, title, page) => {
};
/**
* 频道转换
* 产品要求,SALE的导航显示 Boy,Girl 单数形式
*/
const channelHash = {
boys: 'Boy',
girls: 'Girl',
kids: 'Kid',
lifestyle: 'Lifestyle'
};
/**
* sale 首页 资源位获取
* @param {[object]} req
* @param {[object]} res
... ... @@ -71,25 +58,10 @@ let index = (req, res, next) => {
}
saleModel.getSaleData(params.channel).then((result) => {
// 扩展头部频道选择数据
Object.assign(params.renderData.pageHeader, {
saleNav: {
channel: channelHash[req.yoho.channel],
list: [
{
title: 'Boy',
url: helpers.urlFormat('/product/sale', {channel: 'boys'})
}, {
title: 'Girl',
url: helpers.urlFormat('/product/sale', {channel: 'girls'})
}, {
title: 'Kid',
url: helpers.urlFormat('/product/sale', {channel: 'kids'})
}, {
title: 'Lifestyle',
url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
}
]
}
saleNav: saleModel.saleNav(req.yoho.channel)
});
res.render('sale/index', Object.assign(params.renderData, {
content: result,
... ... @@ -97,7 +69,8 @@ let index = (req, res, next) => {
title: {
title: '最新降价'
}
}
},
pageChannel: false // 需求中,头部不需要跟随频道变颜色
}));
}).catch(next);
};
... ... @@ -194,8 +167,6 @@ let filter = (req, res, next) => {
*/
let search = (req, res, next) => {
let params = Object.assign({}, req.query);
// uid = 9239279
let uid = req.user.uid || 0;
saleModel.getSearchData(params, uid).then((result) => {
... ...
... ... @@ -15,6 +15,7 @@ const processTime = require(`${utils}/time-process`);
const _ = require('lodash');
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
/**
* 排序转换
... ... @@ -40,6 +41,38 @@ const channelType = {
};
/**
* 频道转换
* 产品要求,SALE的导航显示 Boy,Girl 单数形式
*/
const channelHash = {
boys: 'Boy',
girls: 'Girl',
kids: 'Kid',
lifestyle: 'Lifestyle'
};
const saleNav = (channel) => {
return {
channel: channelHash[channel],
list: [
{
title: 'Boy',
url: helpers.urlFormat('/product/sale', {channel: 'boys'})
}, {
title: 'Girl',
url: helpers.urlFormat('/product/sale', {channel: 'girls'})
}, {
title: 'Kid',
url: helpers.urlFormat('/product/sale', {channel: 'kids'})
}, {
title: 'Lifestyle',
url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
}
]
};
};
/**
* 资源位code码
*/
const contentCode = contentCodeConfig.sale;
... ... @@ -351,5 +384,6 @@ module.exports = {
getDiscountDetailData,
getVipData,
getFilterData,
getSearchData
getSearchData,
saleNav
};
... ...
... ... @@ -41,8 +41,9 @@
{{> common/floor-header}}
{{/floorHeader}}
{{> common/filter-nav}}
<div class="sale-nav-wrap">
{{> common/filter-nav}}
</div>
{{> product/sale/common}}
</div>
... ...
... ... @@ -14,5 +14,3 @@
</div>
{{> common/query-param}}
{{> common/suspend-cart}}
... ...
... ... @@ -78,7 +78,7 @@ if (isProduction) {
Object.assign(module.exports, {
appName: 'm.yohobuy.com for test',
domains: {
api: 'http://testapi.yoho.cn:28078/',
api: 'http://devapi.yoho.cn:58078/',
service: 'http://testservice.yoho.cn:28077/'
},
memcache: {
... ...
{{#pageHeader}}
{{# @root.pageChannel}}
<header id="yoho-header" class="yoho-header{{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
{{^}}
<header id="yoho-header" class="yoho-header">
{{/ @root.pageChannel}}
{{#navBack}}
<a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back">&#xe610;</a>
... ... @@ -36,6 +38,8 @@
{{#navBtn}}
{{# @root.pageChannel}}
<div class="homebuttom hide {{#if boys}} boys{{/if}}{{#if girls}} girls{{/if}}{{#if kids}} kids{{/if}}{{#if lifeStyle}} life-style{{/if}}{{#if lifestyle}} life-style{{/if}}">
{{^}}
<div class="homebuttom hide">
{{/ @root.pageChannel}}
<ul>
<li>
... ...
... ... @@ -2,6 +2,6 @@
{{> common/floor-header-more}}
{{> resources/banner-top}}
{{/data}}
<div class="vip-floor">
<div class="vip-floor clearfix">
</div>
... ...
{
"name": "m-yohobuy-node",
"version": "0.1.9",
"version": "0.1.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -18,7 +18,9 @@ var $window = $(window),
$headTab = $('.head-tab'),
headTabH = $headTab.height(),
scrollH = $(window).height() - headTabH,
$loadingTip = $('.loading-tip');
$loadingTip = $('.loading-tip'),
u = navigator.userAgent,
isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
/*
$swiperView = $('.swiper-view'),
... ... @@ -33,8 +35,11 @@ var mySwiper;
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
$avatarClone, $starArticle, $avatarWrap, starIScroll;
var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
var swiperNum = $('.avatar-wrap .swiper-slide').width() / 2;
if ($window.width() === 375 && isiOS) {
swiperNum = 32;
}
require('../common');
... ... @@ -101,6 +106,7 @@ function setIndexAction() {
if (bannerLen > 1) {
avatarSwiper = new Swiper('.avatar-1', {
loop: true,
initialSlide: 0,
centeredSlides: true,
slidesPerView: 'auto',
loopedSlides: bannerLen,
... ...
... ... @@ -5,13 +5,17 @@
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper');
Swiper = require('yoho-swiper'),
ellipsis = require('yoho-mlellipsis'),
lazyload = require('yoho-jquery-lazyload');
var search = require('./sale/search');
require('../common');
search.start();
lazyload($('img.lazy'));
ellipsis.init();
$('.swiper-container').each(function() {
if ($(this).find('.swiper-slide').length > 1) {
... ... @@ -28,9 +32,57 @@ $('.swiper-container').each(function() {
});
$(function() {
var $body = $('body');
var $saleNavSelect = $('.sale-nav-select');
var $vipFloor = $('.vip-floor');
var $saleNavWrap = $('.sale-nav-wrap');
var $listNav = $saleNavWrap.find('#list-nav');
var $filterMask = $('.filter-mask');
$('.sale-nav').on('click', function() {
$saleNavSelect.toggleClass('show');
});
// 读取会员专享商品
$.ajax({
url: '/product/sale/search',
data: {
channel: window.queryString.channel || 'boys',
yh_channel: window.queryString.channel || 'boys',
saleType: '2',
type: 'all',
order: '0',
limit: '4'
}
}).then(function(res) {
if (/good-info/.test(res)) {
$vipFloor.html(res).addClass('goods-container');
lazyload($vipFloor.find('img.lazy'));
$('.good-detail-text .name').each(function() {
var $this = $(this),
$title = $this.find('a');
$title[0].mlellipsis(2);
});
}
});
$saleNavWrap.css({
height: $saleNavWrap.height()
});
$(window).on('scroll', function() {
if (!$filterMask.length) {
$filterMask = $('.filter-mask');
}
if ($body.scrollTop() > $saleNavWrap.offset().top) {
$listNav.addClass('fixed');
$filterMask.addClass('fixed');
} else {
$listNav.removeClass('fixed');
$filterMask.removeClass('fixed');
}
}).trigger('scroll');
});
... ...
... ... @@ -71,7 +71,6 @@ var $listNav = $('#list-nav'),
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
searching;
require('../../common/suspend-cart'); // 悬浮购物车
require('../../common');
ellipsis.init();
... ...
... ... @@ -147,10 +147,8 @@
margin-top: 36px;
background: #000;
span {
display: block;
width: 100%;
height: 100%;
a {
border-radius: 5px;
}
}
... ... @@ -416,18 +414,6 @@
top: 0;
z-index: -1;
}
.swiper-num1 {
width: 110px;
}
.swiper-num2 {
width: 130px;
}
.swiper-num3 {
width: 180px;
}
}
.star-index-bg {
... ... @@ -438,3 +424,31 @@
background: #000;
}
}
@media screen and (max-width: 375px) and (min-width: 375px) {
.star-page {
.avatar-wrap {
height: 105PX;
}
.avatar-swiper {
li {
width: 64PX;
height: 64PX;
margin-top: 20.5PX;
}
.swiper-slide-active {
width: 105PX;
height: 105PX;
}
.swiper-slide-prev,
.swiper-slide-next {
width: 76PX;
height: 76PX;
margin-top: 14.5PX;
}
}
}
}
... ...
... ... @@ -18,6 +18,7 @@
width: 100%;
height: 90px;
background-color: #000;
background-image: linear-gradient(#323232, #414141);
color: #fff;
line-height: 90px;
... ...
... ... @@ -85,6 +85,36 @@
.category-swiper {
height: auto;
}
.vip-floor {
padding-bottom: 30px;
.good-info {
margin-bottom: 20px;
height: 570px;
}
.tag-container {
display: none;
}
}
.list-nav {
width: 100%;
z-index: 1;
background: #fff;
&.fixed {
position: fixed;
top: 0;
left: 0;
}
}
.filter-mask.fixed {
position: fixed;
top: 70px;
}
}
.sale-vip-page {
... ...
// 获取 UID
exports.getUid = (req) => {
var _uid = 0,
cookie = req.cookies._UID,
cookieList;
if (req.isApp) {
return req.query.uid || 0;
}
if (cookie) {
cookieList = cookie.split('::');
if (cookieList[1] && !isNaN(cookieList[1])) {
_uid = cookieList[1];
}
}
return _uid;
};