Authored by 王水玲

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

@@ -40,7 +40,6 @@ const getUserStatus = (param) => { @@ -40,7 +40,6 @@ const getUserStatus = (param) => {
40 var dest = {}; 40 var dest = {};
41 41
42 dest.code = param.code; 42 dest.code = param.code;
43 - dest.title = param.data.h5Title;  
44 dest.returnCode = param.data.returnCode; 43 dest.returnCode = param.data.returnCode;
45 dest.mobile = param.data.mobile; 44 dest.mobile = param.data.mobile;
46 if (param.data.returnCode === 0) { 45 if (param.data.returnCode === 0) {
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <div class="page"> 18 <div class="page">
19 <div class="gain-coupon-centent hidden"> 19 <div class="gain-coupon-centent hidden">
20 <div class="coupon"> 20 <div class="coupon">
21 - <img src={{couponPic}}> 21 + <img src={{image couponPic}}>
22 </div> 22 </div>
23 <p class="phone" id="mobile"></p> 23 <p class="phone" id="mobile"></p>
24 <p>登录Yoho!Buy有货客户端即可使用</p> 24 <p>登录Yoho!Buy有货客户端即可使用</p>
1 <div class="star-page yoho-page"> 1 <div class="star-page yoho-page">
2 {{> star/head-tab}} 2 {{> star/head-tab}}
3 - <div class="swiper-num swiper-num1"></div>  
4 - <div class="swiper-num swiper-num2"></div>  
5 - <div class="swiper-num swiper-num3"></div>  
6 <div class="loading-tip">下拉刷新</div> 3 <div class="loading-tip">下拉刷新</div>
7 <div class="star-main"> 4 <div class="star-main">
8 <div class="main-content"> 5 <div class="main-content">
@@ -26,7 +26,7 @@ function doPassportCallback(openId, nickname, sourceType, req, res) { @@ -26,7 +26,7 @@ function doPassportCallback(openId, nickname, sourceType, req, res) {
26 refer = `${config.siteUrl}/home`; 26 refer = `${config.siteUrl}/home`;
27 } 27 }
28 28
29 - if (/sign|login/.test(refer)) { 29 + if (/signin|login/.test(refer)) {
30 refer = `${config.siteUrl}/home`; 30 refer = `${config.siteUrl}/home`;
31 } 31 }
32 if (openId && nickname) { 32 if (openId && nickname) {
@@ -55,7 +55,7 @@ const common = { @@ -55,7 +55,7 @@ const common = {
55 if (!refer) { 55 if (!refer) {
56 refer = req.get('Referer'); 56 refer = req.get('Referer');
57 } 57 }
58 - refer && res.cookie('refer', encodeURI(refer), { 58 + refer && !/signin|login/.test(refer) && res.cookie('refer', encodeURI(refer), {
59 domain: 'yohobuy.com' 59 domain: 'yohobuy.com'
60 }); 60 });
61 next(); 61 next();
@@ -54,14 +54,16 @@ class Auth { @@ -54,14 +54,16 @@ class Auth {
54 let uidCookie = `${data.profile_name}::${data.uid}::${data.vip_info.title}::${token}`; 54 let uidCookie = `${data.profile_name}::${data.uid}::${data.vip_info.title}::${token}`;
55 55
56 res.cookie('_UID', uidCookie, { 56 res.cookie('_UID', uidCookie, {
57 - domain: 'yohobuy.com' 57 + domain: 'yohobuy.com',
  58 + expires: new Date(Date.now() + 2592000000) // 有效期一年
58 }); 59 });
59 } 60 }
60 req.session._TOKEN = token; 61 req.session._TOKEN = token;
61 req.session._LOGIN_UID = uid; 62 req.session._LOGIN_UID = uid;
62 res.cookie('_TOKEN', token, { 63 res.cookie('_TOKEN', token, {
63 - domain: 'yohobuy.com'  
64 - }); 64 + domain: 'yohobuy.com',
  65 + expires: new Date(Date.now() + 2592000000) // 有效期一年
  66 + }); // esline-disable-line
65 }); 67 });
66 } 68 }
67 } 69 }
@@ -11,8 +11,6 @@ const mRoot = '../models'; @@ -11,8 +11,6 @@ const mRoot = '../models';
11 const headerModel = require('../../../doraemon/models/header'); 11 const headerModel = require('../../../doraemon/models/header');
12 const saleModel = require(`${mRoot}/sale`); 12 const saleModel = require(`${mRoot}/sale`);
13 13
14 -const helpers = global.yoho.helpers;  
15 -  
16 // const queryParam = { 14 // const queryParam = {
17 // brand: '0', 15 // brand: '0',
18 // gender: '1,2,3', 16 // gender: '1,2,3',
@@ -47,17 +45,6 @@ const _processPublicData = (req, title, page) => { @@ -47,17 +45,6 @@ const _processPublicData = (req, title, page) => {
47 }; 45 };
48 46
49 /** 47 /**
50 - * 频道转换  
51 - * 产品要求,SALE的导航显示 Boy,Girl 单数形式  
52 - */  
53 -const channelHash = {  
54 - boys: 'Boy',  
55 - girls: 'Girl',  
56 - kids: 'Kid',  
57 - lifestyle: 'Lifestyle'  
58 -};  
59 -  
60 -/**  
61 * sale 首页 资源位获取 48 * sale 首页 资源位获取
62 * @param {[object]} req 49 * @param {[object]} req
63 * @param {[object]} res 50 * @param {[object]} res
@@ -71,25 +58,10 @@ let index = (req, res, next) => { @@ -71,25 +58,10 @@ let index = (req, res, next) => {
71 } 58 }
72 59
73 saleModel.getSaleData(params.channel).then((result) => { 60 saleModel.getSaleData(params.channel).then((result) => {
  61 +
  62 + // 扩展头部频道选择数据
74 Object.assign(params.renderData.pageHeader, { 63 Object.assign(params.renderData.pageHeader, {
75 - saleNav: {  
76 - channel: channelHash[req.yoho.channel],  
77 - list: [  
78 - {  
79 - title: 'Boy',  
80 - url: helpers.urlFormat('/product/sale', {channel: 'boys'})  
81 - }, {  
82 - title: 'Girl',  
83 - url: helpers.urlFormat('/product/sale', {channel: 'girls'})  
84 - }, {  
85 - title: 'Kid',  
86 - url: helpers.urlFormat('/product/sale', {channel: 'kids'})  
87 - }, {  
88 - title: 'Lifestyle',  
89 - url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'})  
90 - }  
91 - ]  
92 - } 64 + saleNav: saleModel.saleNav(req.yoho.channel)
93 }); 65 });
94 res.render('sale/index', Object.assign(params.renderData, { 66 res.render('sale/index', Object.assign(params.renderData, {
95 content: result, 67 content: result,
@@ -97,7 +69,8 @@ let index = (req, res, next) => { @@ -97,7 +69,8 @@ let index = (req, res, next) => {
97 title: { 69 title: {
98 title: '最新降价' 70 title: '最新降价'
99 } 71 }
100 - } 72 + },
  73 + pageChannel: false // 需求中,头部不需要跟随频道变颜色
101 })); 74 }));
102 }).catch(next); 75 }).catch(next);
103 }; 76 };
@@ -194,8 +167,6 @@ let filter = (req, res, next) => { @@ -194,8 +167,6 @@ let filter = (req, res, next) => {
194 */ 167 */
195 let search = (req, res, next) => { 168 let search = (req, res, next) => {
196 let params = Object.assign({}, req.query); 169 let params = Object.assign({}, req.query);
197 -  
198 - // uid = 9239279  
199 let uid = req.user.uid || 0; 170 let uid = req.user.uid || 0;
200 171
201 saleModel.getSearchData(params, uid).then((result) => { 172 saleModel.getSearchData(params, uid).then((result) => {
@@ -15,6 +15,7 @@ const processTime = require(`${utils}/time-process`); @@ -15,6 +15,7 @@ const processTime = require(`${utils}/time-process`);
15 const _ = require('lodash'); 15 const _ = require('lodash');
16 const api = global.yoho.API; 16 const api = global.yoho.API;
17 const serviceAPI = global.yoho.ServiceAPI; 17 const serviceAPI = global.yoho.ServiceAPI;
  18 +const helpers = global.yoho.helpers;
18 19
19 /** 20 /**
20 * 排序转换 21 * 排序转换
@@ -40,6 +41,38 @@ const channelType = { @@ -40,6 +41,38 @@ const channelType = {
40 }; 41 };
41 42
42 /** 43 /**
  44 + * 频道转换
  45 + * 产品要求,SALE的导航显示 Boy,Girl 单数形式
  46 + */
  47 +const channelHash = {
  48 + boys: 'Boy',
  49 + girls: 'Girl',
  50 + kids: 'Kid',
  51 + lifestyle: 'Lifestyle'
  52 +};
  53 +
  54 +const saleNav = (channel) => {
  55 + return {
  56 + channel: channelHash[channel],
  57 + list: [
  58 + {
  59 + title: 'Boy',
  60 + url: helpers.urlFormat('/product/sale', {channel: 'boys'})
  61 + }, {
  62 + title: 'Girl',
  63 + url: helpers.urlFormat('/product/sale', {channel: 'girls'})
  64 + }, {
  65 + title: 'Kid',
  66 + url: helpers.urlFormat('/product/sale', {channel: 'kids'})
  67 + }, {
  68 + title: 'Lifestyle',
  69 + url: helpers.urlFormat('/product/sale', {channel: 'lifestyle'})
  70 + }
  71 + ]
  72 + };
  73 +};
  74 +
  75 +/**
43 * 资源位code码 76 * 资源位code码
44 */ 77 */
45 const contentCode = contentCodeConfig.sale; 78 const contentCode = contentCodeConfig.sale;
@@ -351,5 +384,6 @@ module.exports = { @@ -351,5 +384,6 @@ module.exports = {
351 getDiscountDetailData, 384 getDiscountDetailData,
352 getVipData, 385 getVipData,
353 getFilterData, 386 getFilterData,
354 - getSearchData 387 + getSearchData,
  388 + saleNav
355 }; 389 };
@@ -41,8 +41,9 @@ @@ -41,8 +41,9 @@
41 {{> common/floor-header}} 41 {{> common/floor-header}}
42 {{/floorHeader}} 42 {{/floorHeader}}
43 43
  44 + <div class="sale-nav-wrap">
44 {{> common/filter-nav}} 45 {{> common/filter-nav}}
45 - 46 + </div>
46 {{> product/sale/common}} 47 {{> product/sale/common}}
47 48
48 </div> 49 </div>
@@ -14,5 +14,3 @@ @@ -14,5 +14,3 @@
14 </div> 14 </div>
15 15
16 {{> common/query-param}} 16 {{> common/query-param}}
17 -  
18 -{{> common/suspend-cart}}  
@@ -78,7 +78,7 @@ if (isProduction) { @@ -78,7 +78,7 @@ if (isProduction) {
78 Object.assign(module.exports, { 78 Object.assign(module.exports, {
79 appName: 'm.yohobuy.com for test', 79 appName: 'm.yohobuy.com for test',
80 domains: { 80 domains: {
81 - api: 'http://testapi.yoho.cn:28078/', 81 + api: 'http://devapi.yoho.cn:58078/',
82 service: 'http://testservice.yoho.cn:28077/' 82 service: 'http://testservice.yoho.cn:28077/'
83 }, 83 },
84 memcache: { 84 memcache: {
1 {{#pageHeader}} 1 {{#pageHeader}}
2 {{# @root.pageChannel}} 2 {{# @root.pageChannel}}
3 <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}}"> 3 <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}}">
  4 +{{^}}
  5 +<header id="yoho-header" class="yoho-header">
4 {{/ @root.pageChannel}} 6 {{/ @root.pageChannel}}
5 {{#navBack}} 7 {{#navBack}}
6 <a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back">&#xe610;</a> 8 <a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back">&#xe610;</a>
@@ -36,6 +38,8 @@ @@ -36,6 +38,8 @@
36 {{#navBtn}} 38 {{#navBtn}}
37 {{# @root.pageChannel}} 39 {{# @root.pageChannel}}
38 <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}}"> 40 <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}}">
  41 +{{^}}
  42 +<div class="homebuttom hide">
39 {{/ @root.pageChannel}} 43 {{/ @root.pageChannel}}
40 <ul> 44 <ul>
41 <li> 45 <li>
@@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
2 {{> common/floor-header-more}} 2 {{> common/floor-header-more}}
3 {{> resources/banner-top}} 3 {{> resources/banner-top}}
4 {{/data}} 4 {{/data}}
5 -<div class="vip-floor"> 5 +<div class="vip-floor clearfix">
6 6
7 </div> 7 </div>
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "0.1.9", 3 + "version": "0.1.11",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -18,7 +18,9 @@ var $window = $(window), @@ -18,7 +18,9 @@ var $window = $(window),
18 $headTab = $('.head-tab'), 18 $headTab = $('.head-tab'),
19 headTabH = $headTab.height(), 19 headTabH = $headTab.height(),
20 scrollH = $(window).height() - headTabH, 20 scrollH = $(window).height() - headTabH,
21 - $loadingTip = $('.loading-tip'); 21 + $loadingTip = $('.loading-tip'),
  22 + u = navigator.userAgent,
  23 + isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
22 24
23 /* 25 /*
24 $swiperView = $('.swiper-view'), 26 $swiperView = $('.swiper-view'),
@@ -33,8 +35,11 @@ var mySwiper; @@ -33,8 +35,11 @@ var mySwiper;
33 var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, 35 var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
34 $avatarClone, $starArticle, $avatarWrap, starIScroll; 36 $avatarClone, $starArticle, $avatarWrap, starIScroll;
35 37
36 -var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +  
37 - ($('.swiper-num3').width() - $('.swiper-num1').width()) / 2; 38 +var swiperNum = $('.avatar-wrap .swiper-slide').width() / 2;
  39 +
  40 +if ($window.width() === 375 && isiOS) {
  41 + swiperNum = 32;
  42 +}
38 43
39 require('../common'); 44 require('../common');
40 45
@@ -101,6 +106,7 @@ function setIndexAction() { @@ -101,6 +106,7 @@ function setIndexAction() {
101 if (bannerLen > 1) { 106 if (bannerLen > 1) {
102 avatarSwiper = new Swiper('.avatar-1', { 107 avatarSwiper = new Swiper('.avatar-1', {
103 loop: true, 108 loop: true,
  109 + initialSlide: 0,
104 centeredSlides: true, 110 centeredSlides: true,
105 slidesPerView: 'auto', 111 slidesPerView: 'auto',
106 loopedSlides: bannerLen, 112 loopedSlides: bannerLen,
@@ -5,13 +5,17 @@ @@ -5,13 +5,17 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Swiper = require('yoho-swiper'); 8 + Swiper = require('yoho-swiper'),
  9 + ellipsis = require('yoho-mlellipsis'),
  10 + lazyload = require('yoho-jquery-lazyload');
9 11
10 var search = require('./sale/search'); 12 var search = require('./sale/search');
11 13
12 require('../common'); 14 require('../common');
13 15
14 search.start(); 16 search.start();
  17 +lazyload($('img.lazy'));
  18 +ellipsis.init();
15 19
16 $('.swiper-container').each(function() { 20 $('.swiper-container').each(function() {
17 if ($(this).find('.swiper-slide').length > 1) { 21 if ($(this).find('.swiper-slide').length > 1) {
@@ -28,9 +32,57 @@ $('.swiper-container').each(function() { @@ -28,9 +32,57 @@ $('.swiper-container').each(function() {
28 }); 32 });
29 33
30 $(function() { 34 $(function() {
  35 + var $body = $('body');
31 var $saleNavSelect = $('.sale-nav-select'); 36 var $saleNavSelect = $('.sale-nav-select');
  37 + var $vipFloor = $('.vip-floor');
  38 + var $saleNavWrap = $('.sale-nav-wrap');
  39 + var $listNav = $saleNavWrap.find('#list-nav');
  40 + var $filterMask = $('.filter-mask');
32 41
33 $('.sale-nav').on('click', function() { 42 $('.sale-nav').on('click', function() {
34 $saleNavSelect.toggleClass('show'); 43 $saleNavSelect.toggleClass('show');
35 }); 44 });
  45 +
  46 + // 读取会员专享商品
  47 + $.ajax({
  48 + url: '/product/sale/search',
  49 + data: {
  50 + channel: window.queryString.channel || 'boys',
  51 + yh_channel: window.queryString.channel || 'boys',
  52 + saleType: '2',
  53 + type: 'all',
  54 + order: '0',
  55 + limit: '4'
  56 + }
  57 + }).then(function(res) {
  58 + if (/good-info/.test(res)) {
  59 + $vipFloor.html(res).addClass('goods-container');
  60 + lazyload($vipFloor.find('img.lazy'));
  61 +
  62 + $('.good-detail-text .name').each(function() {
  63 + var $this = $(this),
  64 + $title = $this.find('a');
  65 +
  66 + $title[0].mlellipsis(2);
  67 + });
  68 + }
  69 + });
  70 +
  71 + $saleNavWrap.css({
  72 + height: $saleNavWrap.height()
  73 + });
  74 +
  75 + $(window).on('scroll', function() {
  76 + if (!$filterMask.length) {
  77 + $filterMask = $('.filter-mask');
  78 + }
  79 +
  80 + if ($body.scrollTop() > $saleNavWrap.offset().top) {
  81 + $listNav.addClass('fixed');
  82 + $filterMask.addClass('fixed');
  83 + } else {
  84 + $listNav.removeClass('fixed');
  85 + $filterMask.removeClass('fixed');
  86 + }
  87 + }).trigger('scroll');
36 }); 88 });
@@ -71,7 +71,6 @@ var $listNav = $('#list-nav'), @@ -71,7 +71,6 @@ var $listNav = $('#list-nav'),
71 $pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项 71 $pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
72 searching; 72 searching;
73 73
74 -require('../../common/suspend-cart'); // 悬浮购物车  
75 require('../../common'); 74 require('../../common');
76 75
77 ellipsis.init(); 76 ellipsis.init();
@@ -147,10 +147,8 @@ @@ -147,10 +147,8 @@
147 margin-top: 36px; 147 margin-top: 36px;
148 background: #000; 148 background: #000;
149 149
150 - span {  
151 - display: block;  
152 - width: 100%;  
153 - height: 100%; 150 + a {
  151 + border-radius: 5px;
154 } 152 }
155 } 153 }
156 154
@@ -416,18 +414,6 @@ @@ -416,18 +414,6 @@
416 top: 0; 414 top: 0;
417 z-index: -1; 415 z-index: -1;
418 } 416 }
419 -  
420 - .swiper-num1 {  
421 - width: 110px;  
422 - }  
423 -  
424 - .swiper-num2 {  
425 - width: 130px;  
426 - }  
427 -  
428 - .swiper-num3 {  
429 - width: 180px;  
430 - }  
431 } 417 }
432 418
433 .star-index-bg { 419 .star-index-bg {
@@ -438,3 +424,31 @@ @@ -438,3 +424,31 @@
438 background: #000; 424 background: #000;
439 } 425 }
440 } 426 }
  427 +
  428 +@media screen and (max-width: 375px) and (min-width: 375px) {
  429 + .star-page {
  430 + .avatar-wrap {
  431 + height: 105PX;
  432 + }
  433 +
  434 + .avatar-swiper {
  435 + li {
  436 + width: 64PX;
  437 + height: 64PX;
  438 + margin-top: 20.5PX;
  439 + }
  440 +
  441 + .swiper-slide-active {
  442 + width: 105PX;
  443 + height: 105PX;
  444 + }
  445 +
  446 + .swiper-slide-prev,
  447 + .swiper-slide-next {
  448 + width: 76PX;
  449 + height: 76PX;
  450 + margin-top: 14.5PX;
  451 + }
  452 + }
  453 + }
  454 +}
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 width: 100%; 18 width: 100%;
19 height: 90px; 19 height: 90px;
20 background-color: #000; 20 background-color: #000;
  21 + background-image: linear-gradient(#323232, #414141);
21 color: #fff; 22 color: #fff;
22 line-height: 90px; 23 line-height: 90px;
23 24
@@ -85,6 +85,36 @@ @@ -85,6 +85,36 @@
85 .category-swiper { 85 .category-swiper {
86 height: auto; 86 height: auto;
87 } 87 }
  88 +
  89 + .vip-floor {
  90 + padding-bottom: 30px;
  91 +
  92 + .good-info {
  93 + margin-bottom: 20px;
  94 + height: 570px;
  95 + }
  96 +
  97 + .tag-container {
  98 + display: none;
  99 + }
  100 + }
  101 +
  102 + .list-nav {
  103 + width: 100%;
  104 + z-index: 1;
  105 + background: #fff;
  106 +
  107 + &.fixed {
  108 + position: fixed;
  109 + top: 0;
  110 + left: 0;
  111 + }
  112 + }
  113 +
  114 + .filter-mask.fixed {
  115 + position: fixed;
  116 + top: 70px;
  117 + }
88 } 118 }
89 119
90 .sale-vip-page { 120 .sale-vip-page {
1 -// 获取 UID  
2 -exports.getUid = (req) => {  
3 - var _uid = 0,  
4 - cookie = req.cookies._UID,  
5 - cookieList;  
6 -  
7 - if (req.isApp) {  
8 - return req.query.uid || 0;  
9 - }  
10 -  
11 - if (cookie) {  
12 - cookieList = cookie.split('::');  
13 - if (cookieList[1] && !isNaN(cookieList[1])) {  
14 - _uid = cookieList[1];  
15 - }  
16 - }  
17 -  
18 - return _uid;  
19 -};